/* ==========================================
   VARIABLES CSS
   ========================================== */
:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #16a085;
    
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --sidebar-bg: #2c3e50;
    --text-color: #333333;
    --text-light: #7f8c8d;
    
    --border-radius: 8px;
    --box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
    
    --sidebar-width: 250px;
}

/* ==========================================
   RESET Y BASE
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* ==========================================
   PÁGINA DE LOGIN
   ========================================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    padding: 50px 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header i {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.login-header h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.login-header p {
    color: var(--text-light);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.login-form input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.login-footer {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    text-align: center;
    font-size: 13px;
    color: var(--text-light);
}

.login-footer strong {
    color: var(--text-color);
}

/* ==========================================
   LAYOUT PRINCIPAL
   ========================================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ==========================================
   SIDEBAR
   ========================================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    position: fixed;
    height: 100vh;
    z-index: 1000;
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
}

.sidebar-header i {
    font-size: 32px;
    color: var(--primary-color);
}

.sidebar-header h2 {
    font-size: 20px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: var(--transition);
}

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

.nav-item.active {
    background-color: rgba(52, 152, 219, 0.2);
    color: white;
    border-left: 3px solid var(--primary-color);
}

.nav-item i {
    width: 20px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    padding: 10px;
    margin-bottom: 15px;
    background: rgba(255,255,255,0.1);
    border-radius: var(--border-radius);
    font-size: 14px;
}

/* ==========================================
   CONTENIDO PRINCIPAL
   ========================================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.content-header {
    background: white;
    padding: 20px 30px;
    box-shadow: var(--box-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-header h1 {
    font-size: 28px;
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.alertas-badge {
    position: relative;
    cursor: pointer;
    padding: 10px;
}

.alertas-badge i {
    font-size: 20px;
    color: var(--warning-color);
}

.alertas-badge .badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.content-body {
    flex: 1;
    padding: 40px;
}

/* ==========================================
   TARJETAS DE ESTADÍSTICAS
   ========================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-ingresos .stat-icon {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
}

.stat-gastos .stat-icon {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger-color);
}

.stat-balance .stat-icon {
    background: rgba(52, 152, 219, 0.1);
    color: var(--primary-color);
}

.stat-total .stat-icon {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning-color);
}

.stat-content h3 {
    font-size: 14px;
    color: var(--text-light);
    font-weight: 500;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
}

/* ==========================================
   GRÁFICOS
   ========================================== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.chart-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.chart-card h3 {
    margin-bottom: 20px;
    font-size: 18px;
}

/* ==========================================
   TARJETAS GENERALES
   ========================================== */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}

.card-header {
    padding: 20px 30px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 18px;
}

.card-body {
    padding: 30px;
}

/* ==========================================
   BOTONES
   ========================================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

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

.btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

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

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

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

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

/* ==========================================
   FORMULARIOS
   ========================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* ==========================================
   MODAL
   ========================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: slideIn 0.3s;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.modal form {
    padding: 25px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    position: sticky;
    bottom: -25px;
    background: white;
    padding-top: 15px;
    padding-bottom: 25px;
    border-top: 1px solid #eee;
    z-index: 10;
}

/* ==========================================
   ALERTAS
   ========================================== */
.alert {
    padding: 12px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* ==========================================
   LISTAS
   ========================================== */
.transacciones-lista {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.transaccion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    border-left: 4px solid;
}

.transaccion-item.ingreso {
    border-left-color: var(--success-color);
}

.transaccion-item.gasto {
    border-left-color: var(--danger-color);
}

.transaccion-info {
    flex: 1;
}

.transaccion-info h4 {
    font-size: 14px;
    margin-bottom: 3px;
}

.transaccion-info p {
    font-size: 12px;
    color: var(--text-light);
}

.transaccion-monto {
    font-size: 18px;
    font-weight: bold;
}

.transaccion-monto.ingreso {
    color: var(--success-color);
}

.transaccion-monto.gasto {
    color: var(--danger-color);
}

.presupuestos-lista {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.presupuesto-item {
    padding: 15px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
}

.presupuesto-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.presupuesto-progress {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.presupuesto-bar {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s;
}

.presupuesto-bar.warning {
    background: var(--warning-color);
}

.presupuesto-bar.danger {
    background: var(--danger-color);
}

.btn-menu-mobile {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--primary-color);
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 990;
}
.sidebar-overlay.open {
    display: block;
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 768px) {
    .btn-menu-mobile {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .stats-grid,
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .content-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 15px 20px;
    }
    
    .content-header h1 {
        font-size: 20px;
    }
    
    .content-body {
        padding: 20px;
    }
}

/* ==========================================
   UTILIDADES
   ========================================== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
