/* === RESET & VARIÁVEIS === */
:root {
    --primary: #09275C;
    --accent: #C30C42;
    --bg: #F3F4F6;
    --text: #1F2937;
    --white: #FFFFFF;
    --border: #E5E7EB;
    --input-bg: #F9FAFB;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    margin: 0;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.container { max-width: 1400px; margin: 0 auto; padding: 0 20px; }

/* === HEADER (COMPACTO) === */
header {
    background-color: var(--primary);
    color: var(--white);
    padding: 1rem 0; /* Altura do azul um pouco maior para não ficar apertado */
    box-shadow: 0 4px 12px rgba(9, 39, 92, 0.15);
    position: relative;
    z-index: 10;
    
    /* AQUI ESTÁ O ESPAÇO: Empurra tudo que vem embaixo */
    margin-bottom: 50px; 
}

.header-content { display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo-img { height: 35px; background: white; padding: 4px; border-radius: 6px; } /* Logo ajustada */
.brand-text h1 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.brand-text p { margin: 0; opacity: 0.8; font-size: 0.75rem; display: none; } /* Oculta slogan em telas pequenas se precisar */
.date-info { text-align: right; font-size: 0.75rem; opacity: 0.9; }

/* === LAYOUT PRINCIPAL === */
main {
    display: grid;
    grid-template-columns: 1fr 380px; 
    gap: 30px;
    
    /* AQUI TAMBÉM: Garante respiro interno extra se precisar */
    padding-top: 10px; 
    
    padding-bottom: 50px;
    align-items: start;
}

/* === ABAS === */
.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    color: #6B7280;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}
.tab-btn:hover { background: #F9FAFB; border-color: #D1D5DB; }
.tab-btn.active {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
    box-shadow: 0 3px 6px rgba(195, 12, 66, 0.2);
}

/* === GRID DE PRODUTOS === */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

/* === CARDS === */
.card {
    background: var(--white);
    border-radius: 10px;
    padding: 18px;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.05); border-color: #cbd5e1; }

.card-header h3 { margin: 0; color: var(--primary); font-size: 1rem; font-weight: 700; }
.card-header .desc { margin: 4px 0 12px 0; color: #6B7280; font-size: 0.85rem; }

/* Inputs dentro do Card */
.card-inputs-area {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.card-inputs-area label {
    display: block; font-size: 0.65rem; text-transform: uppercase; font-weight: 700; color: #6B7280; margin-bottom: 4px; margin-top: 10px;
}
.card-inputs-area label:first-child { margin-top: 0; }

.full-width-input, select, input[type="text"], input[type="number"] {
    width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: 0.85rem; background: white; box-sizing: border-box;
}
.full-width-input:focus, select:focus, input:focus { outline: none; border-color: var(--primary); }

.row-checkbox {
    display: flex; align-items: center; gap: 8px; margin: 8px 0; padding: 8px; background: white; border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.row-checkbox input { width: auto; margin: 0; }
.row-checkbox label { margin: 0; cursor: pointer; color: var(--primary); font-weight: 600; text-transform: none; font-size: 0.8rem; }

/* Discos */
.disk-section { margin-top: 10px; }
.section-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.btn-add-disk-sm { background: #EFF6FF; color: var(--primary); border: 1px solid #BFDBFE; padding: 4px 10px; border-radius: 4px; font-size: 0.7rem; font-weight: 700; cursor: pointer; }
.disk-row { display: grid; grid-template-columns: 70px 1fr 24px; gap: 6px; margin-bottom: 6px; align-items: center; }
.remove-disk { color: #EF4444; cursor: pointer; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; height: 24px; width: 24px; }

/* Snapshot */
.snapshot-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; background: white; padding: 8px; border: 1px dashed #cbd5e1; border-radius: 6px; }

.price-row { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding-top: 12px; border-top: 1px solid var(--border); }
.price { font-size: 1.2rem; font-weight: 800; color: var(--accent); }
.price-display { display: flex; flex-direction: column; /* Para empilhar o riscado em cima do novo se quiser, ou row */}
.add-btn { background: var(--primary); color: white; border: none; width: 36px; height: 36px; border-radius: 50%; font-size: 1.4rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.add-btn:hover { background: #0c357a; transform: scale(1.05); }

/* === SIDEBAR (CARRINHO) === */
.proposal-summary {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
    border: 1px solid var(--border);
    
    /* Sticky Desktop */
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    display: flex; flex-direction: column; overflow: hidden;
}

.proposal-header { padding: 15px; border-bottom: 1px solid var(--border); background: white; z-index: 5; }
.proposal-header h2 { margin: 0 0 10px 0; color: var(--primary); font-size: 1.1rem; }

.input-wrapper label { display: block; font-size: 0.65rem; font-weight: 700; color: #6B7280; margin-bottom: 4px; text-transform: uppercase; }
#cliente-input { width: 100%; padding: 10px; font-size: 0.95rem; border: 1px solid #D1D5DB; border-radius: 6px; }

.wl-switch-container { padding: 10px 15px 0 15px; display: flex; align-items: center; gap: 10px; }
.switch { position: relative; display: inline-block; width: 36px; height: 18px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(18px); }
.wl-label { font-size: 0.85rem; font-weight: 600; color: var(--text); }

.proposal-body { flex: 1; overflow-y: auto; padding: 0; }
.items-list { padding: 0 15px; }
.item-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid #F3F4F6; gap: 10px; }
.item-info { flex: 1; }
.item-info strong { display: block; color: var(--primary); font-size: 0.85rem; line-height: 1.3; }
.item-info small { color: #6B7280; font-size: 0.75rem; display: block; margin-top: 2px; }
.item-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.item-actions span { font-weight: 700; font-size: 0.9rem; color: #111827; white-space: nowrap; }
.btn-trash { background: white; border: 1px solid #FECACA; color: #EF4444; width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 0.9rem; }
.btn-trash:hover { background: #FEF2F2; }
.empty-state { text-align: center; color: #9CA3AF; padding: 30px 0; font-style: italic; font-size: 0.9rem; }

.proposal-footer { padding: 15px; background: #F9FAFB; border-top: 1px solid var(--border); z-index: 5; }
.totals-area { margin-bottom: 12px; }
.subtotal-row, .discount-row, .setup-row { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 4px; color: #4B5563; }
.discount-row { color: var(--accent); }
.total-section { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px dashed #D1D5DB; }
.total-section span:first-child { font-size: 1rem; font-weight: 700; color: var(--primary); }
.total-section span:last-child { font-size: 1.4rem; font-weight: 800; color: var(--primary); }

.btn-finalize { width: 100%; background: var(--primary); color: white; padding: 12px; border: none; border-radius: 8px; font-weight: 700; font-size: 0.95rem; cursor: pointer; transition: 0.2s; }
.btn-finalize:hover { background: #0c357a; }
.btn-clear { width: 100%; background: white; border: 1px solid #D1D5DB; color: #6B7280; padding: 8px; border-radius: 8px; font-weight: 600; cursor: pointer; margin-top: 8px; font-size: 0.85rem; }

/* Custom Forms */
.custom-ui { background: white; border-radius: 12px; padding: 20px; border: 1px solid var(--border); }
.custom-header h2 { margin: 0 0 5px 0; color: var(--primary); font-size: 1.1rem; }
.custom-block label { display: block; font-size: 0.75rem; font-weight: 700; margin-top: 12px; color: #4B5563; text-transform: uppercase; }
.dual-input { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.custom-footer { margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.btn-add-custom { background: var(--accent); color: white; border: none; padding: 10px 20px; border-radius: 8px; font-weight: 700; cursor: pointer; }

/* === RESPONSIVIDADE (MOBILE/TABLET) === */
@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr; /* Coluna única */
        gap: 20px;
        padding-bottom: 20px;
    }

    .proposal-summary {
        position: static; /* Remove fixação */
        max-height: none;
        width: 100%;
        order: -1; /* Opcional: Coloca o carrinho no topo se quiser, senão remova essa linha */
        margin-bottom: 20px;
    }

    .proposal-body {
        max-height: 300px; /* Limita altura da lista no mobile */
        overflow-y: auto;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(100%, 1fr)); /* Cards ocupam largura total */
    }
}

/* === PRINT LAYOUT (PDF) === */
#print-layout { display: none; }

@media print {
    @page { margin: 1cm; size: A4; }
    body { background: white; font-family: 'Arial', sans-serif; color: #333; -webkit-print-color-adjust: exact; print-color-adjust: exact; height: auto; }
    #web-app { display: none !important; }
    #print-layout { display: block !important; }

    .pdf-header { display: flex; justify-content: space-between; padding-bottom: 10px; border-bottom: 3px solid var(--accent); margin-bottom: 20px; }
    .pdf-brand { display: flex; align-items: center; gap: 10px; }
    .pdf-logo-img { height: 45px; }
    .pdf-brand-txt h1 { margin: 0; color: var(--primary); font-size: 20px; text-transform: uppercase; }
    .pdf-brand-txt p { margin: 0; font-size: 10px; color: #666; }
    .pdf-meta { text-align: right; font-size: 10px; line-height: 1.4; color: #444; }
    
    .pdf-client-box { background: #F3F4F6; padding: 10px 12px; border-radius: 6px; margin-bottom: 20px; font-size: 12px; border-left: 5px solid var(--primary); }
    #pdf-wl-badge { margin-top: 4px; font-weight: bold; color: var(--accent); font-size: 10px; text-transform: uppercase; }

    .pdf-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
    .pdf-table th { background: var(--primary); color: white; padding: 8px; text-align: left; font-size: 10px; text-transform: uppercase; font-weight: bold; }
    .pdf-table td { padding: 8px; border-bottom: 1px solid #E5E7EB; font-size: 11px; vertical-align: top; color: #374151; }
    .text-right { text-align: right; }

    .pdf-summary-block { margin-left: auto; width: 55%; margin-top: 5px; page-break-inside: avoid; border-top: 2px solid #333; padding-top: 5px; }
    .summary-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 11px; }
    .summary-row.discount { color: var(--accent); }
    .summary-row.total-final { background: var(--primary); color: white; padding: 8px 12px; font-weight: bold; font-size: 13px; border-radius: 4px; margin-top: 8px; margin-bottom: 8px; }
    .setup-box { margin-top: 5px; border: 1px dashed #9CA3AF; padding: 6px; background: #F9FAFB; font-size: 10px; display: flex; justify-content: space-between; align-items: center; }

    .pdf-footer { margin-top: 15px; padding-top: 10px; border-top: 2px solid #E5E7EB; page-break-inside: avoid; font-size: 9px; color: #4B5563; }
    .footer-intro h4 { color: var(--primary); margin: 0 0 3px 0; font-size: 11px; }
    .footer-intro p { margin-bottom: 8px; text-align: justify; line-height: 1.3; }
    
    .footer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 10px; }
    .footer-grid h5 { color: var(--primary); border-bottom: 1px solid #D1D5DB; margin-bottom: 4px; font-size: 10px; font-weight: bold; text-transform: uppercase; }
    .footer-grid ul { padding-left: 15px; margin: 0; line-height: 1.5; }
    
    .copyright-note { text-align: center; margin-top: 20px; font-size: 8px; color: #9CA3AF; }
}