:root {
    --brand-blue-start: #133c8e;
    --brand-blue-end: #0f2e6e;
    --brand-text: #0d3584;
    --text-color: #111827;
    --muted-color: #6b7280;
    --card-bg: #f5f5f5;
    --card-border: #d9d9d9;
    --base-font-size: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: #f5f5f5;
    color: var(--text-color);
    line-height: 1.6;
    font-size: var(--base-font-size, 16px);
}

/* Garantir que todos os elementos usem rem baseado em --base-font-size */
html {
    font-size: var(--base-font-size, 16px);
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--brand-blue-start) 0%, var(--brand-blue-end) 100%);
    color: white;
    padding: 24px 0 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-content {
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-image {
    max-height: 64px; /* aumento do tamanho da logo no topo */
    width: auto;
    object-fit: contain;
}

.action-btn {
    background: rgba(255,255,255,0.12);
    color: #103175;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    font-size: 16px;
    font-weight: 700;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto; /* manter em linha única no flex container */
}

.action-btn:hover {
    background: rgba(255,255,255,0.18);
}

.action-btn:active {
    transform: scale(0.98);
}

/* Loading */
.loading-container, .error-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 40px 20px;
    text-align: center;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1a3a5f;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-container h2 {
    color: #e53e3e;
    margin-bottom: 10px;
}

/* Content */
.content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
    background: white;
    min-height: calc(100vh - 200px);
    padding-bottom: 120px; /* espaço para o botão flutuante */
}

/* Orçamento Info */
.orcamento-info {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e5e7eb;
}

.info-row {
    display: block;
}

.toolbar-actions,
.toolbar-actions-row {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;            /* manter em uma linha */
    white-space: nowrap;          /* evitar quebra dos botões */
    overflow-x: auto;             /* rolagem lateral se faltar espaço */
    -webkit-overflow-scrolling: touch;
    margin-top: 10px;
}

.info-line {
    display: block;               /* orçamento e cliente em linhas separadas */
    margin-bottom: 10px;
}

.info-label {
    font-weight: 700;
    color: var(--text-color);
    font-size: 1rem;
}

.info-value {
    color: var(--brand-text);
    font-size: 1rem;
    font-weight: 600;
}

/* Fórmulas */
.formulas-container {
    margin-bottom: 30px;
}

.formula-item {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.formula-item:hover {
    border-color: var(--brand-text);
    box-shadow: 0 3px 5px rgba(0,0,0,0.06);
}

.formula-item.selecionada {
    border-color: #c4cee1;
    background: #f3f6f9;
}

.formula-checkbox {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox-custom {
    width: 22px;
    height: 22px;
    border: 2px solid var(--brand-text);
    border-radius: 6px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.checkbox-custom.checked {
    background: var(--brand-text);
}

.checkbox-custom.checked::after {
    content: '✓';
    color: white;
    font-size: 16px;
    font-weight: bold;
}

.formula-content {
    flex: 1;
}

.formula-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 15px;
}

.formula-numero {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-color);
}

.formula-valor {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--brand-text);
    white-space: nowrap;
}

.formula-quantidade {
    color: var(--muted-color);
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.formula-descricao {
    color: #374151;
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Resumo */
.resumo-container {
    background: white;
    border-top: 2px solid #e5e7eb;
    padding-top: 20px;
    margin-top: 30px;
}

.resumo-line {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 12px 0;
    gap: 15px;
}

.resumo-frete-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.resumo-frete-obs {
    font-size: 0.85rem;
    color: var(--muted-color);
    font-style: italic;
    line-height: 1.4;
}

.resumo-icon {
    font-size: 20px;
    width: 30px;
    text-align: center;
    color: var(--brand-text);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resumo-icon svg {
    width: 100%;
    height: 100%;
    color: inherit;
}

.resumo-label {
    flex: 1;
    color: var(--muted-color);
    font-size: 1rem;
}

.resumo-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

.resumo-value.frete-gratis {
    color: #10b981;
    font-weight: 700;
}


.resumo-total {
    background: linear-gradient(135deg, var(--brand-blue-start) 0%, var(--brand-blue-end) 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.total-label {
    font-size: 1.25rem;
    font-weight: 700;
}

.total-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Botão Finalizar */
.finalizar-container {
    margin: 30px 0;
    text-align: center;
}

.finalizar-flutuante {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: min(640px, calc(100% - 32px));
    z-index: 1000;
}

.btn-finalizar {
    background: linear-gradient(135deg, var(--brand-blue-start) 0%, var(--brand-blue-end) 100%);
    color: white;
    border: none;
    padding: 18px 60px;
    font-size: 1.125rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.btn-finalizar:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.btn-finalizar:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-finalizar:active:not(:disabled) {
    transform: translateY(0);
}

/* Validade */
.validade-message {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin: 30px 0;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

/* Badges */
.badges-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid #e2e8f0;
    max-width: 100%;
    overflow: hidden;
}

.badge {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    transition: transform 0.2s ease;
}

.badge:hover {
    transform: none;
    box-shadow: none;
}

.badge-image {
    max-height: 120px; /* dobrado */
    max-width: 100%;  /* não estoura o container */
    width: auto;
    height: auto;
    object-fit: contain;
}

.badge-opinioes {
    background: transparent;
    border: none;
}

.badge-gptw {
    background: transparent;
    border: none;
}

.badge-abf {
    background: transparent;
    border: none;
}

.badge-qrcode {
    background: transparent;
    border: none;
}

.qrcode-link {
    display: inline-block;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.qrcode-link:hover {
    transform: scale(1.05);
}

.qrcode-image {
    max-height: 50px !important;
    max-width: 100%;  /* não estoura o container */
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Zoom do conteúdo (A-/A+) */
.no-print { }
.hide-export { }

/* Impressão: manter cores de fundo e garantir visibilidade da logo */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    body {
        background: white !important;
    }
    
    .content {
        background: white !important;
        max-width: 100% !important;
        padding: 20px !important;
    }
    
    .header {
        background: linear-gradient(135deg, var(--brand-blue-start) 0%, var(--brand-blue-end) 100%) !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Não imprimir toolbar e botão */
    .no-print { 
        display: none !important; 
    }
    .hide-export { 
        display: none !important; 
    }
    .toolbar-actions {
        display: none !important;
    }
    
    /* Logo branca sobre fundo azul */
    .logo-image { 
        filter: none !important;
    }
    
    /* Header com mesma largura do content */
    .header {
        max-width: 1200px !important;
        margin: 0 auto !important;
        padding: 24px 20px 16px !important;
    }
    
    .header-wrapper {
        max-width: 100% !important;
        padding: 0 !important;
    }
    
    /* Garantir que badges fiquem em linha na impressão */
    .badges-container {
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 15px !important;
        page-break-inside: avoid;
    }
    
    .badge {
        page-break-inside: avoid;
        flex-shrink: 1;
        flex-grow: 0;
    }
    
    .badge-image {
        max-height: 80px !important;
        max-width: 150px !important;
    }
    
    .qrcode-image {
        max-height: 100px !important;
        max-width: 100px !important;
    }
}

/* Estilos durante exportação (imagem/PDF) */
body.exportando .badges-container {
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 15px !important;
}

body.exportando .badge {
    flex-shrink: 1;
    flex-grow: 0;
}

body.exportando .badge-image {
    max-height: 80px !important;
    max-width: 150px !important;
}

body.exportando .qrcode-image {
    max-height: 100px !important;
    max-width: 100px !important;
}

body.exportando .header {
    max-width: 1200px !important;
    margin: 0 auto !important;
    padding: 24px 20px 16px !important;
}
    
    /* Remover fundos cinzas */
    .formula-item {
        background: #f5f5f5 !important;
        border: 1px solid #d9d9d9 !important;
    }
}

/* Responsivo */
@media (max-width: 768px) {
    .logo-text {
        font-size: 14px;
    }

    .logo-image {
        max-height: 52px;
    }

    .logo-capsule {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    .content {
        padding: 20px 15px;
    }

    .formula-item {
        flex-direction: column;
        padding: 15px;
    }

    .formula-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .formula-checkbox {
        width: 30px;
        height: 30px;
    }

    .resumo-line {
        font-size: 14px;
    }

    .resumo-total {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .total-value {
        font-size: 28px;
    }

    .badges-container {
        flex-direction: column;
        align-items: center;
    }

    .badge {
        width: 100%;
        max-width: 300px;
    }

    /* Garantir botão flutuante também no mobile */
    .finalizar-flutuante {
        position: fixed !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        bottom: calc(12px + env(safe-area-inset-bottom)) !important;
        width: calc(100% - 24px) !important;
        z-index: 1000 !important;
    }
}

/* Splash */
.splash-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.splash-card {
    background: linear-gradient(135deg, var(--brand-blue-start) 0%, var(--brand-blue-end) 100%);
    color: #fff;
    border-radius: 12px;
    padding: 40px 24px;
    text-align: center;
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.splash-logo-image {
    max-height: 64px;
    width: auto;
    object-fit: contain;
    margin-bottom: 16px;
}

.splash-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.splash-description {
    font-size: 1rem;
    opacity: 0.95;
}

@media (max-width: 480px) {
    .header-content {
        padding: 0 15px;
    }

    .toolbar-actions-row {
        gap: 8px;
    }

    .action-btn {
        min-width: 36px;
        padding: 6px 10px;
    }

    .logo {
        flex-direction: column;
        gap: 8px;
    }

    .logo-text {
        font-size: 12px;
        text-align: center;
    }

    .formula-numero {
        font-size: 16px;
    }

    .formula-valor {
        font-size: 16px;
    }

    .info-label, .info-value {
        font-size: 14px;
    }
}
