/**
 * Sistema de Caixa - Tema Limpo e Hierárquico
 * Foco: Clareza visual e hierarquia de informação
 * Atualizado: Novembro/2025
 */

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

:root {
    /* Cores Principais */
    --primary: #1e3a5f;
    --primary-light: #2d4a6f;
    
    /* Accent */
    --accent: #0d9488;
    --accent-hover: #0f766e;
    
    /* Funcionais */
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #2563eb;
    
    /* Neutros */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Texto */
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06);
    
    /* Bordas */
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.5;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 16px;
}

/* ==================== NAVBAR ==================== */
.navbar {
    background: var(--primary);
    padding: 10px 16px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px 14px;
    flex-wrap: wrap;
    min-height: 56px;
    border-radius: var(--radius-lg);
}

.nav-brand {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--white);
    text-decoration: none;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-left: auto;
}

.nav-links a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 7px 10px;
    border-radius: var(--radius);
    font-size: 0.82em;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
}

.nav-links a:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,0.9);
    font-size: 0.85em;
    margin-left: 8px;
    padding-left: 10px;
    border-left: 1px solid rgba(255,255,255,0.2);
    white-space: nowrap;
}

/* ==================== CARDS ==================== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h2 {
    font-size: 1em;
    font-weight: 600;
    color: var(--text-secondary);
}

.card-header small {
    color: var(--text-muted);
    font-size: 0.8em;
}

/* ==================== SALDO PRINCIPAL ==================== */
.saldo-card {
    text-align: center;
    padding: 32px 24px;
}

.saldo-label {
    font-size: 0.85em;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.saldo-valor {
    font-size: 3em;
    font-weight: 700;
    margin: 8px 0 24px;
    letter-spacing: -1px;
}

.saldo-positivo { color: var(--success); }
.saldo-negativo { color: var(--danger); }

/* Stats inline */
.stats-inline {
    display: flex;
    justify-content: center;
    gap: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-100);
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.1em;
    font-weight: 600;
}

.stat-value.entrada { color: var(--success); }
.stat-value.saida { color: var(--danger); }

.stat-label {
    font-size: 0.75em;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ==================== ALERTAS ==================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
}

.alert a {
    color: inherit;
    font-weight: 600;
}

/* ==================== FORMS ==================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9em;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.95em;
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13,148,136,0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ==================== BUTTONS ==================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
}

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8em;
}

.btn-link {
    background: none;
    color: var(--accent);
    padding: 6px 12px;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-group {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* ==================== TABLES ==================== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9em;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.table tr:hover {
    background: var(--gray-50);
}

.table tr.entrada { border-left: 3px solid var(--success); }
.table tr.saida { border-left: 3px solid var(--danger); }

/* ==================== BADGES ==================== */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
}

.badge-success { background: #ecfdf5; color: #065f46; }
.badge-danger { background: #fef2f2; color: #991b1b; }
.badge-warning { background: #fffbeb; color: #92400e; }
.badge-info { background: #eff6ff; color: #1e40af; }
.badge-auto { background: #f0fdf4; color: #166534; font-size: 0.7em; }

/* ==================== AUTH ==================== */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--primary);
}

.auth-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-md);
}

.auth-title {
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-primary);
    font-size: 1.5em;
}

.auth-links {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.auth-links a {
    color: var(--accent);
    text-decoration: none;
}

/* ==================== IA RESPONSE ==================== */
.ia-response {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
    border-left: 3px solid var(--accent);
    font-size: 0.9em;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* ==================== ACOES ==================== */
.acoes,
.acoes-conta,
.acoes-usuario {
    display: flex;
    gap: 4px;
}

.btn-icon {
    padding: 6px 8px;
    font-size: 0.85em;
    background: var(--gray-100);
    color: var(--text-secondary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-icon:hover {
    background: var(--gray-200);
}

.btn-icon.danger:hover {
    background: #fef2f2;
    color: var(--danger);
}

/* Botões de ação legados */
.btn-toggle {
    background: var(--warning);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75em;
}

.btn-toggle:hover { background: #b45309; }

.btn-editar {
    background: var(--info);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75em;
    text-decoration: none;
}

.btn-editar:hover { background: #1d4ed8; }

.btn-excluir {
    background: var(--danger);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75em;
}

.btn-excluir:hover { background: #b91c1c; }
.btn-excluir:disabled { background: var(--gray-400); cursor: not-allowed; }

/* ==================== STATUS ==================== */
.status-ativo { color: var(--success); font-weight: 500; }
.status-inativo { color: var(--text-muted); }
.status-pago { color: var(--success); font-weight: 500; }
.status-pendente { color: var(--warning); font-weight: 500; }

/* ==================== FILE UPLOAD ==================== */
.file-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-input {
    display: none;
}

.file-label {
    padding: 10px 16px;
    background: var(--gray-100);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9em;
    color: var(--text-secondary);
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.file-label:hover {
    background: var(--gray-200);
}

.file-name {
    font-size: 0.85em;
    color: var(--success);
    font-weight: 500;
}

/* ==================== QUICK ACTIONS ==================== */
.quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ==================== CARD CALCULO (Carnê Leão) ==================== */
.card-calculo {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    text-align: center;
    padding: 32px;
    border-radius: var(--radius-lg);
    margin: 16px 0;
}

.card-calculo h3 {
    opacity: 0.9;
    font-weight: 500;
    font-size: 0.9em;
}

.valor-destaque {
    font-size: 2.5em;
    font-weight: 700;
    margin: 8px 0;
}

.info-calculo {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.info-item {
    background: rgba(255,255,255,0.15);
    padding: 12px;
    border-radius: var(--radius);
    font-size: 0.85em;
}

.info-item strong {
    display: block;
    font-size: 0.8em;
    opacity: 0.8;
    margin-bottom: 4px;
}

/* ==================== STATS GRID (legado) ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.stat-card {
    background: var(--gray-50);
    padding: 16px;
    border-radius: var(--radius);
    text-align: center;
}

.stat-number {
    font-size: 1.4em;
    font-weight: 600;
    color: var(--primary);
}

/* ==================== SALDO CONTAINER (legado) ==================== */
.saldo-container {
    text-align: center;
    padding: 24px;
}

/* ==================== RESUMO PERIODO ==================== */
.resumo-periodo {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.resumo-card {
    background: var(--gray-50);
    padding: 16px;
    border-radius: var(--radius);
    text-align: center;
}

.resumo-card.entradas { border-left: 3px solid var(--success); }
.resumo-card.saidas { border-left: 3px solid var(--danger); }
.resumo-card.saldo { border-left: 3px solid var(--warning); }

.resumo-valor {
    font-size: 1.3em;
    font-weight: 600;
    margin: 4px 0;
}

/* ==================== TABELA HISTORICO ==================== */
.tabela-historico {
    margin-top: 16px;
}

/* ==================== VENCIMENTO ==================== */
.vencimento-proximo {
    background: #fffbeb;
}

/* ==================== USUARIO ATUAL ==================== */
.usuario-atual {
    background: var(--gray-50);
}

/* ==================== NOTA FISCAL ==================== */
.btn-nota-fiscal {
    display: inline-block;
    padding: 4px 8px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.75em;
}

.btn-nota-fiscal:hover {
    background: var(--primary-light);
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 2.5em;
    margin-bottom: 12px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .navbar {
        display: block;
        padding: 12px 16px;
    }

    .nav-brand {
        display: block;
        margin-bottom: 10px;
    }

    .nav-links {
        width: 100%;
        margin-left: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .nav-links a {
        text-align: center;
        padding: 9px 10px;
    }

    .user-info {
        grid-column: 1 / -1;
        width: 100%;
        justify-content: space-between;
        margin-left: 0;
        padding: 9px 10px;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.2);
        background: rgba(255,255,255,0.08);
        border-radius: var(--radius);
    }

    .user-info .btn {
        margin-left: auto;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-inline {
        flex-wrap: wrap;
        gap: 16px;
    }

    .saldo-valor {
        font-size: 2.2em;
    }

    .table {
        font-size: 0.85em;
    }

    .table th,
    .table td {
        padding: 8px;
    }

    .file-upload-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    .card {
        padding: 16px;
    }

    .quick-actions {
        flex-direction: column;
    }

    .quick-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .nav-links {
        grid-template-columns: 1fr;
    }

    .user-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .user-info .btn {
        margin-left: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .info-calculo {
        grid-template-columns: 1fr 1fr;
    }
}

/* ==================== PRINT ==================== */
@media print {
    body { background: white; }
    .navbar, .btn, .quick-actions { display: none; }
    .card { box-shadow: none; border: 1px solid var(--gray-200); }
}
.nav-links a.active {
    background: rgba(255,255,255,0.16);
    color: var(--white);
}
