/* ==========================================================================
   carrinho.css
   Estilos da página do carrinho (Meu Carrinho), incluindo o sistema de
   mensagens de tickets do usuário (modal 'Ver conversa').

   Paleta e tipografia alinhadas com inicio.css / produto.css /
   profile-pages.css / shared-products-dimona.css (roxo #712bf5, fundo
   #f5f4f0, fonte Figtree, cantos bem arredondados).
   ========================================================================== */

:root {
    --purple:         #712bf5;
    --purple-light:   #ede9fe;
    --purple-dark:    #5b3fd4;
    --bg:             #f5f4f0;
    --white:          #ffffff;
    --text-dark:      #1a1a1a;
    --text-mid:       #444444;
    --text-light:     #888888;
    --border:         #e0dfd9;
    --danger-color:   #e63946;
    --success-color:  #2a9d8f;
    --purchased-bg:   #f2eeff;
    --radius-sm:      8px;
    --radius-md:      14px;
    --radius-lg:      22px;

    /* aliases mantidos para compatibilidade com nomes antigos usados abaixo */
    --primary-color:   var(--purple);
    --secondary-color: var(--purple-dark);
}

body.bg-light {
    background-color: var(--bg) !important;
    font-family: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-dark);
}

.cart-item-img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.empty-cart, .empty-purchased {
    padding: 60px 20px;
    text-align: center;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin: 20px 0;
}

.empty-cart i, .empty-purchased i {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    color: #c9c5df;
}

.cart-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--white);
}

.cart-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(113, 43, 245, 0.1);
}

.purchased-item {
    background-color: var(--purchased-bg);
    border-left: 4px solid var(--status-color, var(--purple));
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.purchased-item:hover {
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(113, 43, 245, 0.15);
}

.cart-header {
    background: var(--purple);
    color: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin-bottom: 1.5rem;
}

.purchased-header {
    background: var(--purple);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.price-breakdown {
    font-size: 0.85rem;
    color: var(--text-light);
}

.cart-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.summary-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 42px rgba(22, 18, 28, 0.06);
}

.summary-card .card-body {
    padding: 2rem;
}

.badge-variant {
    background-color: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-mid);
    font-weight: normal;
    padding: 0.35em 0.65em;
    margin-right: 0.3em;
    margin-bottom: 0.3em;
    border-radius: var(--radius-sm);
}

.remove-btn {
    transition: all 0.2s ease;
}

.remove-btn:hover {
    transform: scale(1.1);
    background-color: var(--danger-color) !important;
    color: white !important;
}

.continue-shopping {
    background: var(--white);
    border: 2px dashed #cfc9e8;
    color: var(--text-mid);
    font-weight: 500;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
}

.continue-shopping:hover {
    background: var(--purple-light);
    border-color: var(--purple);
    color: var(--purple-dark);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 30px 0 20px;
}

.section-title h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-dark);
}

.badge-count {
    background: var(--purple);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

.purchase-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.purchase-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.status-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.tracking-info {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    font-size: 0.8rem;
}

/* Cabeçalhos de seção com botões lado a lado */
.purchased-header-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.purchased-header {
    flex: 1;
    margin-bottom: 0;
}

.purchased-actions-buttons {
    display: flex;
    gap: 10px;
}

.btn-sync {
    background-color: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.35);
    color: white;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.btn-sync:hover {
    background-color: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
    color: white;
    transform: scale(1.02);
}

.btn-sync:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Botões primários no tom roxo da marca ── */
.btn-primary {
    background-color: var(--purple) !important;
    border-color: var(--purple) !important;
}
.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--purple-dark) !important;
    border-color: var(--purple-dark) !important;
}
.btn-primary:disabled {
    background-color: #cabdf2 !important;
    border-color: #cabdf2 !important;
}

.btn-outline-primary {
    color: var(--purple);
    border-color: var(--purple);
}
.btn-outline-primary:hover {
    background-color: var(--purple);
    border-color: var(--purple);
    color: white;
}

.text-primary { color: var(--purple) !important; }

@media (max-width: 768px) {
    .cart-item-img {
        width: 80px;
        height: 80px;
    }

    .summary-card .card-body {
        padding: 1.5rem;
    }

    .purchase-actions {
        justify-content: flex-start;
        margin-top: 10px;
    }

    .purchased-header-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .purchased-actions-buttons {
        justify-content: flex-end;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cart-item, .purchased-item {
    animation: slideIn 0.3s ease;
}

.section-divider {
    margin: 40px 0;
    border: 0;
    border-top: 2px dashed var(--border);
}

/* Animação do botão sincronizar */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.fa-spin-fast {
    animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   Utilitários gerais (substituem estilos que estavam soltos no HTML/JS)
   ========================================================================== */

.cursor-pointer {
    cursor: pointer;
}

.summary-card-sticky {
    top: 20px;
}

.app-toast-container {
    z-index: 1050;
}

.app-toast-container-high {
    z-index: 1060;
}

.select-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--purple);
}

.item-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--purple);
}

.badge-eta {
    background: #f59e0b;
    color: #fff;
}

/* Miniatura de produto (cor de fundo e tamanho vêm de dados do item,
   por isso usam variáveis CSS definidas inline em cada card) */
.product-thumb {
    display: inline-block;
    line-height: 0;
    border-radius: var(--radius-sm);
    background-color: var(--thumb-bg, var(--bg));
}

.product-thumb-img {
    display: block;
    width: auto;
    height: auto;
    object-fit: contain;
}

.product-thumb-img--sm {
    max-width: 100px;
    max-height: 100px;
}

.product-thumb-img--lg {
    max-width: 100%;
    max-height: 150px;
}

.color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid #ccc;
    background-color: var(--dot-color, #ccc);
}

.progress-step-circle {
    width: 28px;
    height: 28px;
    font-size: 12px;
    color: #fff;
    background: var(--step-bg, #dee2e6);
}

.progress-step-label {
    font-size: 10px;
    color: var(--step-color, #adb5bd);
}

.progress-step-divider {
    height: 0;
    align-self: start;
    margin-top: 14px !important;
    border-color: var(--divider-color, #dee2e6) !important;
}

.tracking-info {
    font-size: 13px;
}

.hold-alert {
    font-size: 12px;
}

.checkout-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(245, 244, 240, .92);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner-lg {
    width: 3rem;
    height: 3rem;
    color: var(--purple) !important;
}

.ticket-image-preview {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.ticket-remove-image {
    transform: translate(25%, -25%);
}

/* ==========================================================================
   Aviso de "faça login" (carrinho indisponível para visitantes deslogados)
   ========================================================================== */

.login-required-message {
    padding: 60px 20px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin: 20px 0;
    color: var(--text-mid);
}

.login-required-message i.fa-lock {
    color: var(--purple);
    background: var(--purple-light);
    width: 110px;
    height: 110px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 2.4rem !important;
    margin-bottom: 1.5rem !important;
}

.login-required-message h5 {
    color: var(--text-dark);
    font-weight: 800;
    font-size: 1.3rem;
}

.login-required-message p {
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
}

.btn-login-required {
    background: var(--purple);
    color: var(--white);
    border: none;
    border-radius: 999px;
    padding: 0.85rem 2rem;
    font-weight: 700;
    box-shadow: 0 18px 28px rgba(113, 43, 245, 0.22);
    transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}

.btn-login-required:hover {
    background: var(--purple-dark);
    color: var(--white);
    box-shadow: 0 22px 30px rgba(113, 43, 245, 0.24);
    transform: translateY(-1px);
}

.btn-login-required:active {
    transform: translateY(1px);
}

/* ==========================================================================
   Sistema de mensagens — Meus Tickets (visão do usuário)
   ========================================================================== */

.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 440px;
    overflow-y: auto;
    padding: 1.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    scrollbar-width: thin;
    scrollbar-color: #cfc9e8 transparent;
}

.chat-thread::-webkit-scrollbar {
    width: 8px;
}

.chat-thread::-webkit-scrollbar-thumb {
    background-color: #cfc9e8;
    border-radius: 8px;
}

.chat-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 100%;
}

.chat-row--out {
    justify-content: flex-end;
}

.chat-row--in {
    justify-content: flex-start;
}

.chat-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.chat-avatar--user {
    background: var(--purple);
}

.chat-avatar--admin {
    background: #6c757d;
}

.chat-bubble {
    max-width: 78%;
    padding: 0.7rem 1rem;
    border-radius: 16px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

.chat-row--out .chat-bubble {
    background: var(--purple);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-row--in .chat-bubble {
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--text-dark);
    border-bottom-left-radius: 4px;
}

.chat-sender {
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.chat-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-size: 0.92rem;
    line-height: 1.4;
}

.chat-time {
    font-size: 0.7rem;
    margin-top: 0.4rem;
}

.chat-row--out .chat-time {
    color: rgba(255, 255, 255, 0.75);
}

.chat-row--in .chat-time {
    color: var(--text-light);
}

.chat-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-light);
}

.chat-empty i {
    font-size: 2.2rem;
    color: #c9c5df;
    margin-bottom: 0.75rem;
}