@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
    --primary: #10B981;
    --primary-dark: #059669;
    --secondary: #3B82F6;
    --dark: #1E293B;
    --gray: #64748B;
    --light-gray: #F1F5F9;
    --border: #E2E8F0;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 16px;
}

/* ============================================
   BARRA DE AÇÕES - COMPACTA
============================================ */
.action-bar {
    max-width: 210mm;
    margin: 0 auto 12px auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.action-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-back {
    padding: 6px 12px;
    background: #f1f5f9;
    color: #0F172A;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
}

.action-bar h1 {
    font-size: 16px;
    color: #0F172A;
    font-weight: 700;
}

.action-bar-right {
    display: flex;
    gap: 6px;
}

.btn-action {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    color: white;
    transition: all 0.3s;
    font-size: 12px;
}

.btn-whatsapp { background: #25D366; }
.btn-pdf { background: #8B5CF6; }
.btn-print { background: #3B82F6; }

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ============================================
   CONTAINER DO RECIBO
============================================ */
.recibo-container {
    max-width: 210mm;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
    overflow: hidden;
}

/* ============================================
   CABEÇALHO - BEM COMPACTO
============================================ */
.recibo-header {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.empresa-info {
    display: flex;
    gap: 10px;
    flex: 1;
    align-items: center;
}

.logo-empresa {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 6px;
    padding: 4px;
    object-fit: contain;
}

.empresa-dados h2 {
    font-size: 15px;
    font-weight: 800;
    margin-bottom: 2px;
}

.empresa-dados p {
    font-size: 9px;
    opacity: 0.95;
    margin: 1px 0;
    line-height: 1.2;
}

.recibo-info {
    background: rgba(255,255,255,0.2);
    padding: 8px 12px;
    border-radius: 6px;
    text-align: center;
    min-width: 150px;
    border: 1px solid rgba(255,255,255,0.3);
}

.recibo-titulo {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    opacity: 0.95;
}

.recibo-numero {
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 2px;
}

.recibo-numero .label,
.recibo-data .label {
    font-size: 9px;
    font-weight: 600;
    opacity: 0.9;
}

.recibo-data {
    font-size: 10px;
    opacity: 0.9;
}

/* ============================================
   SEÇÕES - MUITO COMPACTAS
============================================ */
.section {
    padding: 8px 16px;
    margin-bottom: 0;
    border-bottom: 1px solid #E2E8F0;
}

.section:last-child {
    border-bottom: none;
}

.section h3 {
    font-size: 11px;
    font-weight: 700;
    color: #0F172A;
    margin-bottom: 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid #E2E8F0;
}

/* ============================================
   DADOS DO CLIENTE - COMPACTO
============================================ */
.cliente-section {
    background: #F8FAFC;
}

.cliente-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.cliente-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cliente-item .label {
    font-size: 10px;
    font-weight: 600;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.cliente-item .value {
    font-size: 12px;
    color: #1E293B;
    font-weight: 600;
}

/* ============================================
   TABELA - COMPACTA
============================================ */
.tabela-wrapper {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid #E2E8F0;
}

.itens-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.itens-table thead {
    background: linear-gradient(135deg, #1E293B 0%, #334155 100%);
    color: white;
}

.itens-table th {
    padding: 6px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.itens-table th:nth-child(2),
.itens-table th:nth-child(3),
.itens-table th:nth-child(4) {
    text-align: right;
}

.itens-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #E2E8F0;
    background: white;
}

.itens-table tbody tr:nth-child(even) td {
    background: #F8FAFC;
}

.itens-table td:nth-child(2),
.itens-table td:nth-child(3),
.itens-table td:nth-child(4) {
    text-align: right;
    font-weight: 600;
    color: #1E293B;
}

.itens-table td:nth-child(4) {
    color: var(--primary);
    font-weight: 700;
}

/* ============================================
   PAGAMENTO E TOTAIS - LADO A LADO COMPACTO
============================================ */
.pagamento-e-totais {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.pagamento-box {
    flex: 0 0 120px;
    min-width: 0;
}

.pagamento-box h3 {
    font-size: 11px;
    font-weight: 700;
    color: #0F172A;
    margin-bottom: 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid #E2E8F0;
}

.pagamento-info {
    background: linear-gradient(135deg, #DBEAFE 0%, #BFDBFE 100%);
    border: 1px solid #93C5FD;
    border-radius: 6px;
    padding: 8px;
}

.pagamento-item {
    display: flex;
    justify-content: space-between;
    margin: 3px 0;
    font-size: 11px;
}

.pagamento-item .label {
    font-weight: 600;
    color: #1E40AF;
}

.pagamento-item .value {
    color: #1E293B;
    font-weight: 600;
}

.totais-box {
    flex: 0 0 280px;
    min-width: 240px;
}

.totais-grid {
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    border: 1px solid #E2E8F0;
    border-radius: 6px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.totais-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
}

.totais-item .label {
    font-size: 11px;
    color: #64748B;
    font-weight: 500;
}

.totais-item .value {
    font-size: 11px;
    color: #1E293B;
    font-weight: 600;
}

.totais-item .value.desconto {
    color: var(--danger);
}

.totais-item.total-final {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 4px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.totais-item.total-final .label {
    color: white;
    font-size: 11px;
    font-weight: 700;
}

.totais-item.total-final .value {
    color: white;
    font-size: 16px;
    font-weight: 800;
}

/* ============================================
   OBSERVAÇÕES - UMA LINHA
============================================ */
.observacoes-texto {
    font-size: 11px;
    color: #1E293B;
    line-height: 1.3;
    padding: 6px 10px;
    background: #FEF3C7;
    border: 1px solid #FCD34D;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   ASSINATURAS - COMPACTAS
============================================ */
.assinaturas {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 15px;
    padding: 12px 16px;
    border-top: 1px dashed #E2E8F0;
}

.assinatura-box {
    text-align: center;
}

.linha-assinatura {
    border-top: 1px solid #1E293B;
    margin-top: 25px;
    padding-top: 4px;
}

.assinatura-label {
    font-size: 11px;
    font-weight: 700;
    color: #1E293B;
}

/* ============================================
   RODAPÉ - COMPACTO
============================================ */
.recibo-footer {
    background: #F8FAFC;
    padding: 10px 16px;
    text-align: center;
    border-top: 1px solid #E2E8F0;
}

.recibo-footer p {
    font-size: 9px;
    color: #64748B;
    margin: 1px 0;
}

.recibo-footer strong {
    color: #1E293B;
    font-size: 10px;
}

/* ============================================
   LOADING E ERRO
============================================ */
.loading-screen,
.error-screen {
    max-width: 210mm;
    margin: 80px auto;
    background: white;
    border-radius: 10px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
}

.loading-screen i,
.error-screen i {
    font-size: 36px;
    color: var(--primary);
    margin-bottom: 15px;
}

.error-screen i {
    color: var(--danger);
}

.loading-screen p,
.error-screen p {
    font-size: 13px;
    color: #64748B;
    margin-top: 8px;
}

.error-screen h2 {
    font-size: 18px;
    color: #1E293B;
    margin-bottom: 8px;
}

/* ============================================
   RESPONSIVO
============================================ */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .action-bar {
        flex-direction: column;
        gap: 8px;
        padding: 8px 12px;
    }
    
    .action-bar-left,
    .action-bar-right {
        width: 100%;
        justify-content: center;
    }
    
    .action-bar-right {
        flex-wrap: wrap;
    }
    
    .recibo-header {
        flex-direction: column;
        padding: 10px 12px;
        text-align: center;
    }
    
    .empresa-info {
        flex-direction: column;
        align-items: center;
    }
    
    .section {
        padding: 6px 10px;
    }
    
    .cliente-grid {
        grid-template-columns: 1fr;
    }
    
    .pagamento-e-totais {
        flex-direction: column;
    }
    
    .totais-box {
        flex: 1;
        width: 100%;
    }
    
    .assinaturas {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 10px 12px;
    }
}

/* ============================================
   ✅ IMPRESSÃO - CORRIGIDA (IGUAL À TELA)
============================================ */
@media print {
    @page {
        size: A4;
        margin: 6mm;
    }
    
    /* ✅ FORÇAR CORES DE FUNDO E GRADIENTES NA IMPRESSÃO */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    body {
        background: white !important;
        padding: 0 !important;
        min-height: auto !important;
    }
    
    /* ✅ ESCONDER APENAS BOTÕES E BARRA DE AÇÃO */
    .no-print,
    .action-bar {
        display: none !important;
    }
    
    /* ✅ CONTAINER SEM SOMBRA */
    .recibo-container {
        box-shadow: none !important;
        border-radius: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
    }
    
    /* ✅ CABEÇALHO VERDE COM GRADIENTE */
    .recibo-header {
        background: linear-gradient(135deg, #10B981 0%, #059669 100%) !important;
        padding: 8px 12px !important;
        color: white !important;
    }
    
    .recibo-header * {
        color: white !important;
    }
    
    .logo-empresa {
        width: 35px !important;
        height: 35px !important;
    }
    
    .empresa-dados h2 {
        font-size: 13px !important;
        color: white !important;
    }
    
    .empresa-dados p {
        font-size: 8px !important;
        color: white !important;
    }
    
    .recibo-info {
        background: rgba(255,255,255,0.2) !important;
        padding: 6px 10px !important;
        min-width: 130px !important;
        border: 1px solid rgba(255,255,255,0.3) !important;
    }
    
    .recibo-titulo {
        font-size: 8px !important;
    }
    
    .recibo-numero {
        font-size: 12px !important;
    }
    
    /* ✅ SEÇÕES */
    .section {
        padding: 6px 12px !important;
    }
    
    .section h3 {
        font-size: 10px !important;
        margin-bottom: 4px !important;
    }
    
    /* ✅ DADOS DO CLIENTE */
    .cliente-section {
        background: #F8FAFC !important;
    }
    
    .cliente-grid {
        gap: 6px !important;
    }
    
    .cliente-item .value {
        font-size: 10px !important;
    }
    
    /* ✅ TABELA DE ITENS COM CABEÇALHO ESCURO */
    .itens-table {
        font-size: 9px !important;
    }
    
    .itens-table thead {
        background: linear-gradient(135deg, #1E293B 0%, #334155 100%) !important;
        color: white !important;
    }
    
    .itens-table th {
        color: white !important;
        padding: 4px 8px !important;
        background: #1E293B !important;
    }
    
    .itens-table td {
        padding: 4px 8px !important;
    }
    
    .itens-table tbody tr:nth-child(even) td {
        background: #F8FAFC !important;
    }
    
    .itens-table td:nth-child(4) {
        color: #10B981 !important;
    }
    
    /* ✅ PAGAMENTO COM FUNDO AZUL */
    .pagamento-e-totais {
        gap: 10px !important;
    }
    
    .pagamento-info {
        background: linear-gradient(135deg, #DBEAFE 0%, #BFDBFE 100%) !important;
        border: 1px solid #93C5FD !important;
        padding: 6px !important;
    }
    
    .pagamento-item {
        font-size: 10px !important;
    }
    
    /* ✅ TOTAIS COM FUNDO CINZA */
    .totais-box {
        flex: 0 0 220px !important;
        min-width: 180px !important;
    }
    
    .totais-grid {
        background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%) !important;
        padding: 6px !important;
    }
    
    .totais-item {
        font-size: 10px !important;
    }
    
    /* ✅ TOTAL FINAL VERDE COM GRADIENTE */
    .totais-item.total-final {
        background: linear-gradient(135deg, #10B981 0%, #059669 100%) !important;
        color: white !important;
        padding: 6px 10px !important;
        box-shadow: none !important;
    }
    
    .totais-item.total-final .label,
    .totais-item.total-final .value {
        color: white !important;
    }
    
    .totais-item.total-final .value {
        font-size: 14px !important;
    }
    
    /* ✅ OBSERVAÇÕES AMARELAS */
    .observacoes-texto {
        background: #FEF3C7 !important;
        border: 1px solid #FCD34D !important;
        font-size: 9px !important;
        padding: 4px 8px !important;
    }
    
    /* ✅ ASSINATURAS */
    .assinaturas {
        margin-top: 12px !important;
        padding: 10px 12px !important;
        gap: 20px !important;
    }
    
    .linha-assinatura {
        margin-top: 20px !important;
    }
    
    /* ✅ RODAPÉ */
    .recibo-footer {
        background: #F8FAFC !important;
        padding: 8px 12px !important;
    }
    
    .recibo-footer p {
        font-size: 8px !important;
    }
}