@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ==========================================================================
   VARIABLES DE TEMA (DISEÑO CORPORATIVO ENTERPRISE)
   ========================================================================== */
:root {
    /* Tema Dark Executive (Por defecto) */
    --bg-main: #0a0a0c;
    --bg-surface: #121216;
    --bg-surface-elevated: #1a1a22;
    --border-color: #22222a;
    --border-light: rgba(255, 255, 255, 0.08);

    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --primary: #0d6efd;
    --primary-hover: #0b5ed7;
    --primary-rgb: 13, 110, 253;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-rgb: 239, 68, 68;

    --shadow-main: rgba(0, 0, 0, 0.5);
    --shadow-glow: rgba(13, 110, 253, 0.15);

    --transition-speed: 0.25s;
    --border-radius-sm: 6px;
    --border-radius-md: 10px;
    --border-radius-lg: 16px;
}

/* Tema Light Executive (Alternativo) */
body.theme-light {
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f1f5f9;
    --border-color: #e2e8f0;
    --border-light: rgba(0, 0, 0, 0.06);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-rgb: 2, 132, 199;

    --shadow-main: rgba(15, 23, 42, 0.05);
    --shadow-glow: rgba(2, 132, 199, 0.08);
}

/* ==========================================================================
   ESTILOS GENERALES Y CONFIGURACIÓN DE PÁGINA
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: none;
}

/* ==========================================================================
   ESTILOS DEL PORTAL DE AUTENTICACIÓN (LOGIN, RECUPERACIÓN)
   ========================================================================== */
.auth-wrapper {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-color: var(--bg-main);
    position: relative;
    z-index: 1;
}

/* Gradientes sutiles de fondo para crear profundidad en Tema Dark */
body:not(.theme-light) .auth-wrapper::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 20%;
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.12) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -1;
    pointer-events: none;
    border-radius: 50%;
}

body:not(.theme-light) .auth-wrapper::after {
    content: '';
    position: absolute;
    bottom: 15%;
    right: 20%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.08) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -1;
    pointer-events: none;
    border-radius: 50%;
}

/* Panel Premium con efecto Glassmorphism */
.auth-card {
    background-color: rgba(18, 18, 22, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 20px 40px var(--shadow-main);
    width: 100%;
    max-width: 440px;
    padding: 40px;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease;
}

body.theme-light .auth-card {
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
}

.auth-card:hover {
    box-shadow: 0 24px 48px var(--shadow-main), 0 0 40px var(--shadow-glow);
}

/* Encabezado del login */
.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo h2 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.auth-logo span {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
}

.auth-logo p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Inputs de Formulario Modernos */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-container {
    position: relative;
    width: 100%;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
    transition: color var(--transition-speed) ease;
}

.auth-input {
    width: 100%;
    padding: 13px 14px 13px 44px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.auth-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.15);
}

.auth-input:focus~.input-icon {
    color: var(--primary);
}

/* Botones Premium con Micro-animación */
.btn-auth {
    width: 100%;
    padding: 13px;
    background-color: var(--primary);
    border: none;
    border-radius: var(--border-radius-md);
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color var(--transition-speed) ease, transform 0.15s ease, box-shadow var(--transition-speed) ease;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.2);
}

.btn-auth:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.35);
}

.btn-auth:active {
    transform: scale(0.98);
}

.btn-auth:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Footer del Login y Varios */
.auth-footer-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    font-size: 13px;
}

.auth-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 24px;
    transition: color var(--transition-speed) ease;
}

.auth-back-link:hover {
    color: var(--text-primary);
}

/* Alertas de Notificación Estilizadas */
.auth-alert {
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: slideInDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.auth-alert-success {
    background-color: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: var(--success);
}

.auth-alert-danger {
    background-color: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: var(--danger);
}

/* Indicador de Fuerza de Contraseña */
.password-strength-meter {
    height: 4px;
    width: 100%;
    background-color: var(--border-color);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
    position: relative;
}

.password-strength-bar {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.password-strength-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 5px;
    display: block;
    text-align: right;
}

/* Toggle del Tema de Color (Dark/Light) en la esquina */
.theme-toggle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px var(--shadow-main);
    z-index: 10;
    transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease, transform 0.15s ease;
}

.theme-toggle-btn:hover {
    transform: scale(1.05);
    background-color: var(--bg-surface-elevated);
}

/* Spinner de carga */
.auth-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: auth-spin 0.6s linear infinite;
    display: none;
}

/* Animaciones */
@keyframes auth-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Icono Ojo Interactivo para Contraseñas */
.password-toggle-icon {
    transition: color var(--transition-speed) ease;
}

.password-toggle-icon:hover {
    color: var(--text-primary) !important;
}

/* ==========================================================================
   ESTILOS DE MAQUETACIÓN DEL DASHBOARD (INDEX.PHP)
   ========================================================================== */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    width: 100vw;
    overflow-x: hidden;
}

/* Sidebar Lateral Fijo Elegante */
.sidebar {
    width: 280px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

.sidebar-header {
    padding: 20px 24px 15px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.sidebar-header h3 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.sidebar-header h3 span {
    color: var(--primary);
    font-weight: 800;
}

/* POWERED BY Logo Styles */
.powered-by-link {
    text-decoration: none;
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.powered-by-text {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-right: 8px;
    transition: color var(--transition-speed) ease;
}

.powered-by-logo {
    height: 32px;
    border: none;
    object-fit: contain;
    transition: filter var(--transition-speed) ease;
}

/* Light Theme Adjustments for Logo */
body.theme-light .powered-by-text {
    color: #64748b;
}

body.theme-light .powered-by-logo {
    /* Convierte la imagen blanca en un gris oscuro, adecuado para tema claro */
    filter: brightness(0) opacity(0.65);
}

.sidebar-menu {
    list-style: none;
    padding: 10px 16px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--border-radius-md);
    transition: all var(--transition-speed) ease;
}

.sidebar-item a i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    color: var(--text-muted);
    transition: color var(--transition-speed) ease;
}

.sidebar-item.active a,
.sidebar-item a:hover {
    color: #ffffff !important;
    background-color: var(--primary);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.25);
}

body.theme-light .sidebar-item.active a,
body.theme-light .sidebar-item a:hover {
    color: #ffffff !important;
    background-color: var(--primary);
}

.sidebar-item.active a i,
.sidebar-item a:hover i {
    color: #ffffff !important;
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-profile-summary {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #00c6ff 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    box-shadow: 0 4px 8px rgba(var(--primary-rgb), 0.15);
}

.user-info-text {
    display: flex;
    flex-direction: column;
}

.user-info-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.user-info-role {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--danger);
    font-size: 13px;
    font-weight: 600;
    background-color: transparent;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.btn-logout:hover {
    background-color: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.25);
}

/* Área de Contenido Principal */
.main-dashboard {
    margin-left: 280px;
    flex: 1;
    min-width: 0; /* Fix flexbox blowout */
    min-height: 100vh;
    padding: 16px;
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: background-color var(--transition-speed) ease;
}

/* Header del Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
}

.welcome-msg h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0px;
}

.welcome-msg p {
    font-size: 13px;
    color: var(--text-secondary);
}

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

.date-badge {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: var(--border-radius-md);
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-speed) ease;
}

/* Grid de Analíticas KPI */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
}

.kpi-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 10px 20px var(--shadow-main);
    transition: all var(--transition-speed) ease;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 30px var(--shadow-main), 0 0 20px var(--shadow-glow);
    border-color: rgba(var(--primary-rgb), 0.2);
}

.kpi-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kpi-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-icon-wrapper {
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.kpi-card:nth-child(1) .kpi-icon-wrapper {
    background-color: rgba(13, 110, 253, 0.12);
    color: var(--primary);
}

.kpi-card:nth-child(2) .kpi-icon-wrapper {
    background-color: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.kpi-card:nth-child(3) .kpi-icon-wrapper {
    background-color: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.kpi-card:nth-child(4) .kpi-icon-wrapper {
    background-color: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.kpi-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.kpi-trend-up {
    color: var(--success);
    font-weight: 600;
}

.kpi-trend-neutral {
    color: var(--text-muted);
}

.kpi-desc {
    color: var(--text-secondary);
}

/* Banner Premium de Bienvenida / Fase 2 */
.welcome-banner {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.15) 0%, rgba(var(--primary-rgb), 0.03) 100%);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 20px var(--shadow-main);
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
}

.banner-content {
    max-width: 60%;
    z-index: 1;
}

.banner-badge {
    background-color: var(--primary);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
    margin-bottom: 16px;
    box-shadow: 0 4px 8px rgba(var(--primary-rgb), 0.2);
}

.banner-content h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.banner-content p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 8px;
}

.btn-banner-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: var(--primary);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--border-radius-md);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.25);
    transition: all var(--transition-speed) ease;
}

.btn-banner-action:hover {
    color: #ffffff;
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(var(--primary-rgb), 0.35);
}

.banner-graphic {
    z-index: 1;
    font-size: 80px;
    color: rgba(var(--primary-rgb), 0.25);
    animation: float-graphic 4s ease-in-out infinite;
}

@keyframes float-graphic {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@media (max-width: 992px) {
    .sidebar {
        width: 80px;
    }

    .sidebar-header h3,
    .user-info-text,
    .btn-logout span {
        display: none;
    }

    .sidebar-item a span {
        display: none;
    }

    .sidebar-item a {
        justify-content: center;
        padding: 12px;
    }

    .main-dashboard {
        margin-left: 80px;
        padding: 24px;
    }

    .welcome-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: 24px;
    }

    .banner-content {
        max-width: 100%;
    }

    .banner-graphic {
        display: none;
    }
}

/* Estilos para ítems deshabilitados del menú lateral */
.sidebar-item.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.sidebar-item.disabled a {
    cursor: not-allowed !important;
}

/* Optimización de espacios para DataTables y Tablas (hacerlas más angostas) */
table.dataTable td,
table.dataTable th,
.table td,
.table th {
    padding: 0.4rem 0.5rem !important;
    vertical-align: middle;
}

.dataTables_wrapper .row {
    margin-bottom: 0.25rem !important;
}