/* Variáveis CSS para um tema claro e profissional */
:root {
    --primary-color: #0f62fe; /* Azul forte moderno (IBM style) */
    --primary-hover: #0353e9;
    --background: #f4f7f9; /* Fundo cinza suave */
    --surface: #ffffff;
    --text-main: #161616;
    --text-muted: #525252;
    --border: #e0e0e0;
    
    /* Cores de KPI / Semânticas */
    --success: #198038;
    --warning: #f1c21b;
    --error: #da1e28;
    --kpi-users: #e5f0ff;
    --kpi-users-icon: #0f62fe;
    --kpi-retention: #defbe6;
    --kpi-retention-icon: #198038;
    --kpi-money: #fff1f1;
    --kpi-money-icon: #da1e28;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 24px rgba(0,0,0,0.1);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --font-family: 'Inter', -apple-system, system-ui, sans-serif;
    --transition: 0.2s ease-in-out;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Tipografia */
h1, h2, h3, h4 {
    font-weight: 600;
    color: var(--text-main);
}

h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; color: var(--text-muted); }

/* Containers */
.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    font-size: 28px;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font-family);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-sm);
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--background);
    border-color: var(--text-muted);
}

.btn-whatsapp {
    color: #25D366;
    border-color: #25d36640;
    background: transparent;
}

.btn-whatsapp:hover {
    background: #25d3661a;
    color: #128C7E;
    border-color: #25D366;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--background);
    color: var(--text-main);
}

.btn-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}
.btn-close:hover { color: var(--error); }

/* Dashboard Cards */
.dashboard {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.card {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 24px;
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: var(--kpi-users);
    color: var(--kpi-users-icon);
}

.kpi-icon.retention {
    background: var(--kpi-retention);
    color: var(--kpi-retention-icon);
}

.kpi-icon.cash {
    background: var(--kpi-money);
    color: var(--kpi-money-icon);
}

.kpi-info {
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

/* Gráfico / Chart Card */
.chart-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 16px;
}

.chart-wrapper {
    position: relative;
    width: 90px;
    height: 90px;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot.stay { background: #198038; }
.dot.left { background: #e0e0e0; }

/* Formulário e Seções */
.form-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

.card-header {
    margin-bottom: 20px;
}

.card-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.card-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
}

input[type="text"],
input[type="tel"],
select {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.95rem;
    font-family: var(--font-family);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fafafa;
    transition: var(--transition);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.15);
}

.error-text {
    display: none;
    color: var(--error);
    font-size: 0.75rem;
    margin-top: 4px;
}
.input-error input {
    border-color: var(--error);
}
.input-error .error-text {
    display: block;
}

.form-row-checkboxes {
    display: flex;
    align-items: center;
    gap: 40px;
}

.plano-group {
    flex-direction: row;
    align-items: center;
    gap: 12px;
}
.plano-group select {
    width: auto;
    min-width: 160px;
}

/* Custom Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    user-select: none;
}

.checkbox-label input {
    display: none;
}

.custom-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.custom-checkbox i {
    font-size: 14px;
    color: white;
    opacity: 0;
    transform: scale(0.5);
    transition: var(--transition);
}

.checkbox-label input:checked + .custom-checkbox {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-label input:checked + .custom-checkbox i {
    opacity: 1;
    transform: scale(1);
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 30px 0;
}

.items-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    color: var(--text-main);
}

/* Lista de Itens Cashback */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.item-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fafafa;
    transition: var(--transition);
}

.item-box:focus-within {
    border-color: var(--primary-color);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.1);
}

.item-info {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 130px;
}

.item-info i {
    font-size: 20px;
    color: var(--text-muted);
}

.item-info span {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

.item-input {
    display: flex;
    align-items: center;
    gap: 12px;
}

.input-money {
    position: relative;
    width: 100px;
}
.input-money::before {
    content: "R$";
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: var(--text-muted);
}
.input-money input {
    padding-left: 32px;
    width: 100%;
}

.item-cb-badge {
    background: var(--kpi-retention);
    color: var(--kpi-retention-icon);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Rodapé / Footer do App */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    padding: 24px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}
.app-footer p {
    font-size: 0.95rem;
}
.footer-zap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #25D366;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 16px;
    border-radius: 50px;
    border: 1px solid #25d36640;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.footer-zap:hover {
    background: #25d3661a;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.footer-zap i {
    font-size: 20px;
}

/* Modal Relatório ... */
.modal {
    display: none; /* hidden state */
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
    z-index: 999;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}
.modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}
.table-responsive {
    overflow-y: auto;
    padding: 0 20px 20px 20px;
    max-height: 60vh;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}
.table th, .table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.table th {
    font-weight: 600;
    color: var(--text-muted);
    background: #fdfdfd;
    position: sticky;
    top: 0;
}

.modal-footer {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}
.modal-footer i {
    font-size: 32px;
    margin-bottom: 8px;
    color: #d0d0d0;
}

/* Toasts / Notificações */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
}

.toast {
    background: var(--surface);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 250px;
    max-width: 350px;
    border-left: 4px solid var(--primary-color);
    animation: toastIn 0.3s ease-out forwards;
}

.toast.error { border-left-color: var(--error); }
.toast.success { border-left-color: var(--success); }
.toast i { font-size: 20px; }
.toast.error i { color: var(--error); }
.toast.success i { color: var(--success); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(50px); }
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    .dashboard {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .form-row-checkboxes {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }
    .plano-group {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 6px;
    }
    .plano-group select {
        width: 100%;
    }
    .dashboard {
        grid-template-columns: 1fr;
    }
    .header-actions span {
        display: none; 
    }
    .btn i { margin-right: 0;}
}

/* Área exclusiva para impressão (escondida no uso normal) */
.print-only { display: none; }

/* Estilos de impressão - Somente 1 página limpa */
@media print {
    @page { size: A4 portrait; margin: 15mm; }
    
    body, html { 
        width: 100%; 
        height: auto; 
        margin: 0; 
        padding: 0; 
    }
    
    body { 
        background: white !important; 
        color: black !important; 
        font-size: 14pt; 
    }
    
    /* Esconde a Interface Web da tela (menos papel) */
    .header, .container, .modal, .toast-container { display: none !important; }
    
    /* Mostra Apenas a Área de Impressão Semântica */
    .print-only { 
        display: block !important; 
        font-family: Arial, Helvetica, sans-serif;
        color: black !important;
    }
    
    .print-header { 
        border-bottom: 2px solid #000; 
        padding-bottom: 15px; 
        margin-bottom: 30px; 
        text-align: center; 
    }
    .print-header h2 { font-size: 26pt; margin: 0; color: #000; }
    .print-header p { font-size: 16pt; margin: 8px 0 0; color: #333; }
    
    .print-body { margin-bottom: 40px; }
    
    /* Layouts dentro da print-body */
    .print-body p { font-size: 16pt; margin: 12px 0; color: #000 !important; }
    .print-body strong { font-size: 20pt; color: #000 !important; }

    /* Configuração perfeita pra tabela do relatório não quebrar feio e ficar limpa */
    .print-body .table { 
        width: 100%; 
        border-collapse: collapse; 
        margin-top: 10px; 
    }
    .print-body .table th, .print-body .table td { 
        padding: 10px; 
        border-bottom: 1px solid #ccc; 
        text-align: left; 
        font-size: 12pt;
    }
    .print-body .table th { 
        border-bottom: 2px solid #000; 
        font-weight: bold; 
        color: #000; 
    }
    /* Zera os badges da tag SIM e NÃO para o print */
    .print-body .table td span { 
        background: none !important; 
        color: #000 !important; 
        font-weight: bold; 
        padding: 0 !important;
    }
    
    .print-body tr { page-break-inside: avoid; }

    .print-footer { 
        text-align: center; 
        border-top: 1px solid #000; 
        padding-top: 15px; 
        font-size: 12pt; 
        color: #333; 
        margin-top: 50px;
    }
}
