/* Estilos específicos da Área Restrita / Tesouraria */

body.admin-bg {
    background-color: var(--color-bg-light);
    /* Iniciar invisível para evitar vazamento de tela antes do firebase Auth validar */
    display: none; 
}

body.login-bg {
    background-color: var(--color-bg-light);
    display: block;
}

.login-container {
    max-width: 400px;
    margin: 10vh auto;
    padding: 3rem 2.5rem;
    background: white;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    border-top: 4px solid var(--color-primary);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--color-dark);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius-md);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.error-message {
    color: var(--color-secondary);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: none;
}

/* Dashboard Layout */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--color-dark);
    color: white;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: #94a3b8;
    gap: 1rem;
    border-left: 4px solid transparent;
    transition: all var(--transition-fast);
}

.sidebar-link:hover, .sidebar-link.active {
    color: white;
    background: rgba(255,255,255,0.05);
}

.sidebar-link.active {
    border-left-color: var(--color-primary);
    color: white;
}

.main-content {
    flex: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

/* Financial Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    padding: 1.5rem 2rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid #f1f5f9;
}

.stat-card-title {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-card-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--color-dark);
}

.stat-card.positive .stat-card-value { color: #16a34a; } /* Verde/Positivo */
.stat-card.negative .stat-card-value { color: var(--color-secondary); } /* Vermelho/Despesa */
.stat-card.neutral .stat-card-value { color: var(--color-primary); } /* Azul/Saldo */

/* Tables */
.table-container {
    background: white;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid #f1f5f9;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
}

tr:hover td {
    background: #f8fafc;
}

/* Badge */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-income { background: #dcfce7; color: #16a34a; border: 1px solid #bbf7d0; }
.badge-expense { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 550px;
    border-radius: var(--border-radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--color-secondary);
}

/* ==================================
   Responsividade: Celulares e Tablets
   ================================== */
@media (max-width: 768px) {
    .dashboard-wrapper { flex-direction: column; }
    .sidebar { width: 100%; height: auto; }
    .sidebar-header { text-align: center; }
    
    /* Menu inferiro ou de scroll na verticalidade mobile */
    .sidebar-nav { display: flex; flex-direction: row; overflow-x: auto; padding: 0.5rem; }
    .sidebar-link { padding: 0.75rem; white-space: nowrap; border-left: none; border-bottom: 4px solid transparent; }
    .sidebar-link.active { border-bottom-color: var(--color-primary); }
    
    .top-bar { flex-direction: column; align-items: flex-start; gap: 1.5rem; margin-bottom: 2rem; }
    .top-bar .btn { width: 100%; }
    
    .stats-grid { grid-template-columns: 1fr; gap: 1rem; margin-bottom: 2rem; }
    .main-content { padding: 1.5rem; }
    .stat-card { padding: 1.5rem; }
    .stat-card-value { font-size: 2rem; }
    
    .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 650px; } /* Força o scroll horizontal para a tabela não esmagar textos como data e valores no celular */
    
    .login-container { margin: 5vh 1rem; padding: 2rem 1.5rem; }
    
    .modal-content { max-height: 85vh; padding: 1.5rem; }
    .grid-2 { grid-template-columns: 1fr; } /* Modal usa o grid-2 mas precisa quebrar no celular */
    .modal-content label { font-size: 0.85rem; }
}
