/**
 * Vana V19 - Titanium UI Styles
 * Versão: 2.3.0
 */

:root {
    --vana-primary: #6b21a8; /* Roxo Profundo */
    --vana-success: #059669; /* Verde Esmeralda */
    --vana-bg: #f9fafb;
    --vana-text: #1f2937;
    --vana-muted: #6b7280;
}

/* 1. GRID CONTAINER */
.v19-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

/* 2. CARD DESIGN */
.v19-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.v19-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.v19-card-body {
    padding: 16px;
    flex-grow: 1;
}

.v19-card-body h3 {
    font-size: 1.1rem;
    margin: 0 0 8px 0;
    color: var(--vana-text);
}

.v19-meta-info {
    font-size: 0.85rem;
    color: var(--vana-muted);
    margin-bottom: 15px;
}

/* 3. PROGRESS BAR */
.v19-progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0;
}

.v19-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--vana-primary), #a855f7);
    transition: width 0.5s ease-out;
}

/* 4. BUTTONS */
.v19-btn-primary {
    background: var(--vana-primary);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    width: auto; /* Deixa o botão do tamanho do texto */
    min-width: 120px;
    transition: opacity 0.2s;
}

/* Botão "X" discreto no topo do carrinho */
.v19-btn-link {
    background: none;
    border: none;
    color: #fff; /* Branco para contrastar com o cabeçalho roxo */
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.8;
}
.v19-btn-link:hover {
    opacity: 1;
}

/* Botão "X" do Modal */
.v19-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.v19-btn-primary:hover { opacity: 0.9; }
.v19-btn-primary:disabled { background: #ccc; cursor: not-allowed; }

/* 5. TRAY (CARRINHO FLUTUANTE) */
.v19-tray-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: none; /* Ativado via JS */
    border: 1px solid var(--vana-primary);
}

.v19-tray-header {
    background: var(--vana-primary);
    color: #fff;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    border-radius: 11px 11px 0 0;
}

.v19-tray-scroll {
    max-height: 250px;
    overflow-y: auto;
    padding: 10px;
}

.v19-tray-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.9rem;
}

.v19-tray-footer { padding: 15px; background: #f9fafb; }

/* 6. MODAL OVERLAY */
.v19-overlay-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: none;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.v19-modal-box-sm {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.v19-modal-total-header {
    text-align: center;
    font-size: 1.2rem;
    color: var(--vana-success);
    font-weight: bold;
    margin-bottom: 20px;
    padding: 10px;
    background: #ecfdf5;
    border-radius: 8px;
}

/* Força a exibição das setas (spinners) em campos numéricos */
input[type=number].v19-item-qty::-webkit-inner-spin-button, 
input[type=number].v19-item-qty::-webkit-outer-spin-button { 
    opacity: 1 !important;
}

.v19-item-qty {
    width: 60px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 2px 5px;
    margin-left: 10px;
    font-size: 14px;
}

/* Esconde os botões de valores fixos e o seletor de rádio no modal v19 */
#v19-modal-content .donation-amount-buttons,
#v19-modal-content .charitable-donation-amount-form > p:first-of-type,
#v19-modal-content .charitable-custom-amount-wrapper > label {
    display: none !important;
}

/* Deixa o campo de valor (que as setinhas do lote preencheram) visível mas discreto */
#v19-modal-content .charitable-custom-amount-input {
    display: block;
    width: 100%;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    color: var(--vana-primary);
    background: #f3f4f6;
    border: none;
    pointer-events: none; /* Opcional: impede mudar no modal, forçando mudar no lote */
}

/* Força a exibição das setas de aumento/diminuição */
.charitable-custom-amount-input, 
.v19-item-qty {
    -moz-appearance: textfield !important; /* Firefox */
}

.charitable-custom-amount-input::-webkit-outer-spin-button,
.charitable-custom-amount-input::-webkit-inner-spin-button,
.v19-item-qty::-webkit-outer-spin-button,
.v19-item-qty::-webkit-inner-spin-button {
    -webkit-appearance: inner-spin-button !important;
    opacity: 1 !important;
    display: block !important;
}

/* Estiliza a caixa do lote para parecer um seletor numérico real */
.v19-item-qty {
    width: 70px !important;
    height: 30px !important;
    border: 2px solid var(--v19-primary) !important;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
}

/* Esconde botões de valor fixo e textos redundantes no modal */
#v19-modal-content .donation-amount-buttons,
#v19-modal-content .charitable-donation-amount-form > p,
#v19-modal-content .charitable-custom-amount-wrapper > label {
    display: none !important;
}

/* Estiliza o campo de valor do Charitable para ser o checkout do lote */
.charitable-custom-amount-input {
    display: block !important;
    width: 100%;
    margin-top: 10px;
    padding: 15px !important;
    font-size: 28px !important;
    text-align: center;
    color: var(--vana-primary);
    border: 2px solid #e5e7eb !important;
    border-radius: 8px;
    background: #fff !important;
}

/* Garante que as setinhas apareçam em todos os campos numéricos */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
    opacity: 1 !important;
    display: block !important;
}

/* Esconde a escolha de valores nativa do Charitable no Modal V19 */
#v19-modal-content .charitable-donation-amount-form,
#v19-modal-content .donation-amount-buttons,
#v19-modal-content .charitable-custom-amount-wrapper > label,
#v19-modal-content .charitable-donation-amount-form > p {
    display: none !important;
}

/* Transforma o campo de valor sincronizado no destaque do Modal */
#v19-modal-content input.charitable-custom-amount-input {
    display: block !important;
    visibility: visible !important;
    width: 100% !important;
    margin: 15px 0 !important;
    padding: 15px !important;
    font-size: 28px !important;
    text-align: center !important;
    font-weight: bold !important;
    color: #6b21a8 !important; /* Roxo Vana */
    background: #f3f4f6 !important;
    border: 2px solid #e5e7eb !important;
    border-radius: 8px !important;
}

/* Layout Principal */
/* Container Principal: Força a separação horizontal */
.v19-inventory-layout {
    display: flex !important; /* !important necessário para vencer o tema Astra */
    gap: 30px;
    align-items: flex-start;
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 15px;
}

/* Sidebar: Garante largura fixa no desktop */
/* Sidebar: Garante largura fixa e visual de card */
.v19-sidebar {
    width: 280px !important;
    flex-shrink: 0;
    background: #ffffff;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.v19-filter-group {
    margin-bottom: 25px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 15px;
}
.v19-filter-group:last-child { border: none; }

.v19-filter-group h4 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 10px;
    font-weight: 700;
}

/* Lista de Facetas */
.v19-facet-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
}

/* Ajuste dos itens de faceta para o contador ficar na direita */
.v19-facet-item {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
}

.v19-facet-count {
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--vana-muted);
    font-weight: bold;
}


/* Conteúdo Principal */
.v19-main-content {
    flex-grow: 1;
}

.v19-top-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

/* Mobile: Transforma Sidebar em Bottom Sheet */
@media (max-width: 768px) {
    .v19-inventory-layout {
        display: block; /* Remove colunas */
    }

    .v19-sidebar {
        /* Estilos de Sheet (Off-canvas) */
        position: fixed;
        top: 0; left: -100%; /* Escondido */
        width: 85%;
        height: 100%;
        background: white;
        z-index: 99999;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    }

    /* Classe ativa via JS para abrir */
    body.v19-filters-open .v19-sidebar {
        left: 0;
    }

    /* Classes auxiliares mobile */
    .mobile-only { display: block; }
    .v19-facet-list { max-height: none; } /* Scroll total no mobile */
}

@media (min-width: 769px) {
    .mobile-only { display: none !important; }
}