/* -------------------------------------------------------------
 * Nexis System - Estilos Globales & Dashboard Premium
 * ------------------------------------------------------------- */

/* 1. Variables de Diseño (Tokens) */
:root {
    --bg-primary: #090d16;
    --bg-secondary: #111827;
    --glass-bg: rgba(20, 27, 45, 0.5);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-highlight: rgba(255, 255, 255, 0.02);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-purple: #8b5cf6;
    --accent-purple-glow: rgba(139, 92, 246, 0.3);
    --accent-blue: #3b82f6;
    --accent-blue-glow: rgba(59, 130, 246, 0.3);
    
    --color-success: #10b981;
    --color-error: #ef4444;
    --color-warning: #f59e0b;
    --color-success-bg: rgba(16, 185, 129, 0.15);
    --color-error-bg: rgba(239, 68, 68, 0.15);
    --color-warning-bg: rgba(245, 158, 11, 0.15);
    
    --font-main: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. Reset Global */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-main);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Enlaces globales */
a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--accent-purple);
    text-decoration: underline;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: #1f2937;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #374151;
}

/* 3. Estilos de Autenticación (Login & Registro) */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 20px;
    background: radial-gradient(circle at top left, #0e1628, var(--bg-primary));
}

/* Luces de neón difusas de fondo */
.glow-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
    pointer-events: none;
}
.ball-1 {
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--accent-purple-glow) 0%, transparent 70%);
    top: -100px;
    left: -100px;
    filter: blur(40px);
}
.ball-2 {
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent-blue-glow) 0%, transparent 70%);
    bottom: -150px;
    right: -100px;
    filter: blur(50px);
}

/* Tarjeta Glassmorphism */
.auth-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    width: 100%;
    max-width: 440px;
    border-radius: var(--radius-lg);
    padding: 40px;
    z-index: 2;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}
.brand-logo {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px auto;
    filter: drop-shadow(0 0 10px var(--accent-purple-glow));
}
.auth-header h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}
.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Formularios de Autenticación */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.input-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.input-container {
    position: relative;
    display: flex;
    align-items: center;
}
.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}
.input-container input {
    width: 100%;
    padding: 14px 14px 14px 44px;
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    transition: var(--transition);
}
.input-container input:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
    background: rgba(17, 24, 39, 0.85);
}
.helper-text {
    font-size: 11px;
    color: var(--text-muted);
}

/* Botones */
.btn {
    padding: 14px 20px;
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
}
.btn-primary:active {
    transform: translateY(0);
}

.auth-footer {
    text-align: center;
    margin-top: 25px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* 4. Notificaciones Flash (Alertas flotantes) */
.flash-messages-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
    width: 100%;
}
.flash-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 16px rgba(0,0,0,0.25);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.flash-message.success {
    background: var(--color-success-bg);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--color-success);
}
.flash-message.error {
    background: var(--color-error-bg);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--color-error);
}
.flash-message.warning {
    background: var(--color-warning-bg);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--color-warning);
}
.flash-icon {
    display: flex;
    align-items: center;
}
.flash-text {
    flex: 1;
    font-size: 13.5px;
    font-weight: 500;
}
.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.6;
    transition: var(--transition);
}
.flash-close:hover {
    opacity: 1;
}

/* 5. DISEÑO DE DASHBOARD */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar / Menú Lateral */
.sidebar {
    width: 260px;
    background: var(--glass-bg);
    border-right: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    position: fixed;
    height: 100vh;
    z-index: 10;
}
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding-left: 5px;
}
.sidebar-header .brand-logo {
    width: 32px;
    height: 32px;
    margin: 0;
}
.brand-name {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    flex: 1;
}
.sidebar-menu ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14.5px;
    text-decoration: none;
    transition: var(--transition);
}
.sidebar-menu li a svg {
    color: var(--text-muted);
    transition: var(--transition);
}
.sidebar-menu li a:hover,
.sidebar-menu li.active a {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}
.sidebar-menu li.active a {
    border-left: 3px solid var(--accent-purple);
    background: rgba(139, 92, 246, 0.08);
}
.sidebar-menu li.active a svg {
    color: var(--accent-purple);
}
.sidebar-menu li a:hover svg {
    color: var(--text-primary);
}
/* Links deshabilitados mock */
.disabled-link {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Perfil de Usuario en Sidebar */
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 10px;
    border-top: 1px solid var(--glass-border);
    margin-top: auto;
}
.profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 100%);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 15px;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.25);
}
.profile-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.profile-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.profile-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.logout-btn {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: var(--transition);
}
.logout-btn:hover {
    color: var(--color-error);
    transform: translateX(2px);
}

/* Área de Contenido del Dashboard */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 40px;
    max-width: 1400px;
    width: calc(100% - 260px);
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 35px;
}
.header-greeting h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}
.header-greeting p {
    color: var(--text-secondary);
    font-size: 14.5px;
}
.date-badge {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Contenedores Genéricos Glass */
.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Grid de KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 35px;
}
.kpi-card {
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}
.kpi-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}
.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: center;
    align-items: center;
}
.icon-users {
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-purple);
}
.icon-active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent-blue);
}
.icon-conversion {
    background: rgba(16, 185, 129, 0.12);
    color: var(--color-success);
}
.icon-bounce {
    background: rgba(245, 158, 11, 0.12);
    color: var(--color-warning);
}
.kpi-details h3 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.kpi-value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}
.kpi-subtext {
    font-size: 11px;
    color: var(--text-muted);
}
.trend-up {
    color: var(--color-success);
    font-weight: 600;
}
.trend-down {
    color: var(--color-warning);
    font-weight: 600;
}

/* Fila de Gráfico + Tabla */
.dashboard-grid-row {
    display: grid;
    grid-template-columns: 1.8fr 1.2fr;
    gap: 30px;
}

.chart-container, .users-panel {
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
}
.panel-header {
    margin-bottom: 20px;
}
.panel-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}
.panel-header p {
    color: var(--text-secondary);
    font-size: 13px;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tabla de Usuarios Recientes */
.users-table-wrapper {
    flex: 1;
    overflow-x: auto;
}
.users-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
.users-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 12px;
    border-bottom: 1px solid var(--glass-border);
}
.users-table td {
    padding: 12px;
    border-bottom: 1px solid var(--glass-border);
    font-size: 13.5px;
}
.users-table tr:last-child td {
    border-bottom: none;
}
.table-user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.table-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
}
.username-text {
    font-weight: 500;
}
.date-cell {
    color: var(--text-secondary);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    text-align: center;
    gap: 12px;
}
.empty-icon {
    opacity: 0.4;
}

/* 6. Media Queries para Responsividad */
@media (max-width: 1024px) {
    .dashboard-grid-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 70px;
        padding: 20px 10px;
    }
    .brand-name, .sidebar-menu span, .profile-info {
        display: none;
    }
    .sidebar-header {
        justify-content: center;
        margin-bottom: 30px;
    }
    .sidebar-menu li a {
        justify-content: center;
        padding: 12px;
    }
    .sidebar-profile {
        justify-content: center;
        padding: 16px 0;
    }
    .logout-btn {
        display: none;
    }
    .main-content {
        margin-left: 70px;
        width: calc(100% - 70px);
        padding: 25px;
    }
    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}
