
/* ==========================================================================
   1. VARIABLES DE DISEÑO Y PALETA DE COLORES (PROFESIONAL / MODERNO)
   ========================================================================== */
:root {


    /* Colores Principales */
    --primary-color: #2563eb;       /* Azul Eléctrico ERP */
    --primary-hover: #1d4ed8;
    --secondary-color: #10b981;     /* Verde Éxito / Créditos */
    --secondary-hover: #059669;
    --danger-color: #ef4444;        /* Rojo Alertas / Cuentas Vencidas */
    --danger-hover: #dc2626;
    --warning-color: #f59e0b;       /* Amarillo Pendientes */
    --warning-hover: #d97706;
    --info-color: #06b6d4;
    
    /* Superficies y Fondos */
    --bg-main: #f8fafc;             /* Gris claro ultra limpio */
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    
    /* Tipografía y Texto */
    --text-main: #0f172a;           /* Slate 900 profundo */
    --text-muted: #64748b;          /* Gris para etiquetas secundarias */
    
    /* Sombras y Bordes */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 10px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   2. RESETEO GENERAL Y ANIMACIONES NATIVAS
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Animación de entrada para vistas y formularios */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeInUp 0.35s ease-out forwards;
}

/* ==========================================================================
   3. MAQUETACIÓN RESPONSIVA (LAYOUT DASHBOARD)
   ========================================================================== */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Barra lateral de escritorio */
.sidebar {
    width: 260px;
    background-color: #0f172a;
    color: #ffffff;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: var(--transition);
    flex-shrink: 0;
}

.sidebar-brand {
    padding-bottom: 1rem;
    border-bottom: 1px solid #1e293b;
}

.sidebar-brand h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
}

.user-badge-role {
    font-size: 0.75rem;
    background-color: var(--primary-color);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 6px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Menú de Navegación */
.sidebar-nav {
    flex: 1;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sidebar-divider {
    font-size: 0.7rem;
    font-weight: 700;
    color: #475569;
    padding: 1rem 0.75rem 0.25rem 0.75rem;
    letter-spacing: 1px;
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-item a:hover {
    background-color: rgba(255, 255, 255, 0.04);
    color: #ffffff;
}

.sidebar-item.active a {
    background-color: rgba(37, 99, 235, 0.15);
    color: #3b82f6;
    font-weight: 600;
    border-left: 4px solid var(--primary-color);
}

/* Pie de la Barra Lateral */
.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid #1e293b;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.btn-logout {
    color: var(--danger-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    transition: var(--transition);
}

.btn-logout:hover {
    color: var(--danger-hover);
    transform: translateX(2px);
}

/* Contenedor de Contenido Principal */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Barra de Navegación Móvil (Oculta por defecto) */
.mobile-navbar {
    display: none;
    background-color: #0f172a;
    padding: 1rem 1.5rem;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid #1e293b;
}

.mobile-brand {
    color: #ffffff;
    font-weight: 700;
    font-size: 1.1rem;
}

.mobile-menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mobile-menu-toggle span {
    display: block;
    width: 24px;
    height: 3px;
    background-color: white;
    border-radius: 2px;
    transition: var(--transition);
}

/* ==========================================================================
   4. TARJETAS (CARDS) Y VISTAS DE RESUMEN (STATS GRID)
   ========================================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* Cuadrícula de estadísticas rápidas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.stat-card.success { border-left-color: var(--secondary-color); }
.stat-card.danger { border-left-color: var(--danger-color); }
.stat-card.warning { border-left-color: var(--warning-color); }

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 0.25rem;
}

/* ==========================================================================
   5. FORMULARIOS ELEMENTOS MODERNOS Y FOCUS ANIMADO
   ========================================================================== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-main);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

/* Deshabilitados y lecturas */
.form-control:disabled, .form-control[readonly] {
    background-color: #f1f5f9;
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Manejo en filas de inputs (ej: Precio y Cantidad juntos) */
.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

/* Contenedores de autenticación (Login) con Glassmorphism */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: calc(var(--radius) * 1.5);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   6. BOTONES (ESTADOS, TAMAÑOS Y ANIMACIONES)
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
}

.btn:active {
    transform: scale(0.97);
}

/* Variaciones de Color */
.btn-primary { background-color: var(--primary-color); color: #ffffff; }
.btn-primary:hover { background-color: var(--primary-hover); box-shadow: 0 4px 12px rgba(37,99,235,0.2); }

.btn-secondary { background-color: var(--secondary-color); color: #ffffff; }
.btn-secondary:hover { background-color: var(--secondary-hover); box-shadow: 0 4px 12px rgba(16,185,129,0.2); }

.btn-danger { background-color: var(--danger-color); color: #ffffff; }
.btn-danger:hover { background-color: var(--danger-hover); box-shadow: 0 4px 12px rgba(239,68,68,0.2); }

.btn-warning { background-color: var(--warning-color); color: #ffffff; }
.btn-warning:hover { background-color: var(--warning-hover); box-shadow: 0 4px 12px rgba(245,158,11,0.2); }

/* Botones pequeños para acciones en tablas */
.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* ==========================================================================
   7. TABLAS DE DATOS PERSONALIZADAS
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.table-custom {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
    min-width: 600px;
}

.table-custom th {
    background-color: #f8fafc;
    color: var(--text-muted);
    padding: 1rem;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.table-custom td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    transition: var(--transition);
}

.table-custom tr:last-child td {
    border-bottom: none;
}

.table-custom tr:hover td {
    background-color: #f1f5f9;
}

/* Componentes Badge de Estados del Crédito */
.badge {
    display: inline-flex;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50px;
    text-transform: uppercase;
}

.badge-warning { background-color: #fef3c7; color: #d97706; }
.badge-success { background-color: #d1fae5; color: #059669; }
.badge-danger { background-color: #fee2e2; color: #dc2626; }

/* ==========================================================================
   8. MEDIA QUERIES (SOPORTE TOTAL RESPONSIVE)
   ========================================================================== */
@media (max-width: 768px) {
    /* Cambiar el comportamiento de la caja contenedora general */
    .dashboard-container {
        flex-direction: column;
    }

    /* Mostrar barra superior */
    .mobile-navbar {
        display: flex;
    }

    /* Ocultar barra lateral por defecto y transformarla en menú flotante */
    .sidebar {
        position: fixed;
        top: 57px; /* Altura aproximada de la barra móvil superior */
        left: -100%;
        width: 280px;
        height: calc(100vh - 57px);
        z-index: 999;
        box-shadow: var(--shadow-lg);
        background-color: #0f172a;
    }

    /* Clase activa controlada por el JS del menu.php */
    .sidebar.active {
        left: 0;
    }

    /* Ajustar el espaciado del contenido */
    .main-content {
        padding: 1.25rem;
    }

    /* Los elementos en fila de formularios pasan a ser bloques verticales */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Animación visual dinámica del botón de hamburguesa a cruz (X) */
    .mobile-menu-toggle.open span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 6px);
    }
    .mobile-menu-toggle.open span:nth-child(2) {
        opacity: 0;
    }
    .mobile-menu-toggle.open span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -6px);
    }
}

```