/* ============================================================
   PORTAL MULTI-PROYECTO — Estilos Principales
   Temas: Dark (Cyber) | Light (Clean)
   ============================================================ */

/* ============================================================
   1. VARIABLES DE TEMA
   ============================================================ */

/* ============================================================
   REGLAS DE COLOR — PALETA INSTITUCIONAL
   ─────────────────────────────────────────────────────────────
   Primario:    Azul institucional  #2563eb / #60a5fa
   Secundario:  Gris pizarra        #475569 / #94a3b8
   Fondo dark:  Azul noche suave    #1a2332 → #243447
   Fondo light: Gris perla suave    #f1f5f9 → #e8eef5
   Éxito:       Verde esmeralda     #059669 / #34d399
   Alerta:      Ámbar               #d97706 / #fbbf24
   Error:       Rojo suave          #dc2626 / #f87171
   ============================================================ */

/* --- TEMA OSCURO — Azul Noche Profesional --- */
[data-theme="dark"] {
    /* Fondos: azul pizarra oscuro, no negro puro */
    --bg-primary:      #1a2332;
    --bg-secondary:    #1e2a3a;
    --bg-tertiary:     #243447;
    --bg-card:         rgba(30, 42, 58, 0.92);
    --bg-card-hover:   rgba(36, 52, 71, 0.98);
    --bg-input:        rgba(255, 255, 255, 0.06);
    --bg-navbar:       rgba(26, 35, 50, 0.97);
    --bg-sidebar:      #1a2332;
    --bg-hover:        rgba(255, 255, 255, 0.04);

    /* Texto: blanco suave con buen contraste */
    --text-primary:    #e8edf4;
    --text-secondary:  #94a3b8;
    --text-muted:      #64748b;
    --text-inverse:    #0f172a;

    /* Acento: azul institucional suave (no neon) */
    --accent-cyan:     #60a5fa;
    --accent-purple:   #a78bfa;
    --accent-green:    #34d399;
    --accent-orange:   #fb923c;
    --accent-pink:     #f472b6;

    /* Bordes: sutiles, no brillantes */
    --border-color:    rgba(148, 163, 184, 0.12);
    --border-hover:    rgba(96, 165, 250, 0.35);
    --border-input:    rgba(148, 163, 184, 0.18);

    /* Sombras: más suaves */
    --shadow-sm:       0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md:       0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg:       0 16px 40px rgba(0, 0, 0, 0.45);
    --shadow-glow:     0 4px 20px rgba(96, 165, 250, 0.12);
    --shadow-glow-lg:  0 8px 32px rgba(96, 165, 250, 0.18);

    /* Gradiente: azul institucional → violeta suave */
    --gradient-primary: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --gradient-bg:      linear-gradient(135deg, #1a2332 0%, #1e2a3a 100%);

    --scrollbar-track: #1e2a3a;
    --scrollbar-thumb: #334155;
}

/* --- TEMA CLARO — Azul Neblina Profesional --- */
[data-theme="light"] {
    /* Fondos: azul pizarra claro, espejo del dark pero invertido */
    --bg-primary:      #dce8f5;
    --bg-secondary:    #e8f0f9;
    --bg-tertiary:     #cfdded;
    --bg-card:         rgba(232, 240, 249, 0.95);
    --bg-card-hover:   rgba(220, 232, 245, 0.98);
    --bg-input:        rgba(255, 255, 255, 0.65);
    --bg-navbar:       rgba(215, 228, 244, 0.97);
    --bg-sidebar:      #d4e3f2;
    --bg-hover:        rgba(37, 99, 235, 0.07);

    /* Texto: azul oscuro profundo con buen contraste */
    --text-primary:    #0f1e32;
    --text-secondary:  #2d4a6b;
    --text-muted:      #5a7a9e;
    --text-inverse:    #e8f0f9;

    /* Acento: misma paleta que el dark pero saturada */
    --accent-cyan:     #1d6fd4;
    --accent-purple:   #6d28d9;
    --accent-green:    #047857;
    --accent-orange:   #c2620a;
    --accent-pink:     #be185d;

    /* Bordes: azul pizarra suave */
    --border-color:    rgba(29, 111, 212, 0.14);
    --border-hover:    rgba(29, 111, 212, 0.40);
    --border-input:    rgba(29, 111, 212, 0.22);

    /* Sombras: azules suaves como el dark pero invertido */
    --shadow-sm:       0 2px 8px rgba(15, 30, 50, 0.10);
    --shadow-md:       0 8px 24px rgba(15, 30, 50, 0.14);
    --shadow-lg:       0 16px 40px rgba(15, 30, 50, 0.18);
    --shadow-glow:     0 4px 20px rgba(29, 111, 212, 0.14);
    --shadow-glow-lg:  0 8px 32px rgba(29, 111, 212, 0.22);

    /* Gradiente: azul institucional → violeta suave (igual al dark) */
    --gradient-primary: linear-gradient(135deg, #2563eb, #7c3aed);
    --gradient-bg:      linear-gradient(135deg, #d4e3f2 0%, #cfdded 100%);

    --scrollbar-track: #cfdded;
    --scrollbar-thumb: #8ab0d4;
}

/* ============================================================
   2. RESET Y BASE
   ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* Scrollbar personalizada */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-cyan); }

/* Selección de texto */
::selection { background: rgba(0, 212, 255, 0.25); color: var(--text-primary); }

/* ============================================================
   3. TIPOGRAFÍA
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

code, .mono {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.875em;
}

.text-accent  { color: var(--accent-cyan) !important; }
.text-purple  { color: var(--accent-purple) !important; }
.text-green   { color: var(--accent-green) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-secondary-portal { color: var(--text-secondary) !important; }

/* ============================================================
   4. PÁGINA DE LOGIN
   ============================================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
}

/* Fondo animado */
.login-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

/* Grid tecnológico */
.login-bg .grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 212, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 212, 255, 0.04) 1px, transparent 1px);
    background-size: 60px 60px;
    animation: gridPulse 4s ease-in-out infinite;
}

[data-theme="light"] .login-bg .grid-overlay {
    background-image:
        linear-gradient(rgba(0, 102, 204, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 102, 204, 0.06) 1px, transparent 1px);
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Orbes flotantes */
.login-bg .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
}

.login-bg .orb-1 {
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.2) 0%, transparent 70%);
    top: -150px; left: -150px;
    animation: floatOrb1 10s ease-in-out infinite;
}

.login-bg .orb-2 {
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.2) 0%, transparent 70%);
    bottom: -100px; right: -100px;
    animation: floatOrb2 12s ease-in-out infinite;
}

.login-bg .orb-3 {
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(0, 255, 136, 0.1) 0%, transparent 70%);
    top: 50%; left: 60%;
    animation: floatOrb3 8s ease-in-out infinite;
}

[data-theme="light"] .login-bg .orb-1 {
    background: radial-gradient(circle, rgba(0, 102, 204, 0.15) 0%, transparent 70%);
}
[data-theme="light"] .login-bg .orb-2 {
    background: radial-gradient(circle, rgba(109, 40, 217, 0.12) 0%, transparent 70%);
}
[data-theme="light"] .login-bg .orb-3 {
    background: radial-gradient(circle, rgba(5, 150, 105, 0.08) 0%, transparent 70%);
}

@keyframes floatOrb1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%  { transform: translate(80px, 40px) scale(1.1); }
    66%  { transform: translate(40px, 80px) scale(0.95); }
}
@keyframes floatOrb2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%  { transform: translate(-60px, -40px) scale(1.05); }
    66%  { transform: translate(-30px, -70px) scale(1.1); }
}
@keyframes floatOrb3 {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%  { transform: translate(-50%, -50%) scale(1.2); }
}

/* Partículas (generadas por JS) */
.particle {
    position: absolute;
    width: 2px; height: 2px;
    background: var(--accent-cyan);
    border-radius: 50%;
    opacity: 0;
    animation: particleFade var(--duration, 4s) ease-in-out infinite;
    animation-delay: var(--delay, 0s);
}

@keyframes particleFade {
    0%   { opacity: 0; transform: translateY(0) scale(0); }
    20%  { opacity: 0.8; transform: translateY(-20px) scale(1); }
    80%  { opacity: 0.4; transform: translateY(-80px) scale(0.8); }
    100% { opacity: 0; transform: translateY(-120px) scale(0); }
}

/* Card de login */
.login-card {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 420px;
    padding: 48px 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: cardEntrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cardEntrance {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Logo del portal */
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px; height: 72px;
    background: var(--gradient-primary);
    border-radius: 20px;
    font-size: 32px;
    color: white;
    margin-bottom: 16px;
    box-shadow: var(--shadow-glow-lg);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 212, 255, 0.3); }
    50%       { box-shadow: 0 0 40px rgba(0, 212, 255, 0.6), 0 0 60px rgba(124, 58, 237, 0.3); }
}

[data-theme="light"] .login-logo .logo-icon {
    animation: logoPulseLight 3s ease-in-out infinite;
}
@keyframes logoPulseLight {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 102, 204, 0.3); }
    50%       { box-shadow: 0 0 40px rgba(0, 102, 204, 0.5); }
}

.login-logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Formulario de login */
.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.login-form .input-wrapper {
    position: relative;
}

.login-form .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
    transition: color 0.2s;
    pointer-events: none;
}

.login-form .form-control {
    width: 100%;
    padding: 12px 14px 12px 42px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
}

.login-form .form-control:focus {
    border-color: var(--accent-cyan);
    background: var(--bg-input);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.login-form .form-control:focus + .input-icon,
.login-form .input-wrapper:focus-within .input-icon {
    color: var(--accent-cyan);
}

.login-form .form-control::placeholder {
    color: var(--text-muted);
}

/* Botón de login */
.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    margin-top: 8px;
}

.btn-login::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 212, 255, 0.35);
}

.btn-login:hover::before { opacity: 1; }
.btn-login:active { transform: translateY(0); }

.btn-login .btn-spinner {
    display: none;
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 8px;
}

.btn-login.loading .btn-spinner { display: inline-block; }
.btn-login.loading .btn-text { opacity: 0.7; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error de login */
.login-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    padding: 12px 16px;
    color: #fc8181;
    font-size: 0.875rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: shakeError 0.4s ease;
}

@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    20%  { transform: translateX(-8px); }
    40%  { transform: translateX(8px); }
    60%  { transform: translateX(-4px); }
    80%  { transform: translateX(4px); }
}

/* Toggle de tema en login */
.login-theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
}

/* ============================================================
   5. NAVBAR
   ============================================================ */

.portal-navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 64px;
    background: var(--bg-navbar);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 1000;
    transition: all 0.3s ease;
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 20px;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Brand */
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: var(--gradient-primary);
    border-radius: 10px;
    color: white;
    font-size: 1rem;
}

.brand-name {
    font-size: 1.125rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-version {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Botones de icono en navbar */
.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

/* Toggle sidebar */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

/* Avatar de usuario */
.user-avatar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 4px 10px 4px 4px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.user-avatar-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-cyan);
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border-radius: 8px;
    border: 1px solid;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-avatar.lg {
    width: 44px; height: 44px;
    border-radius: 12px;
    font-size: 1rem;
}

/* Dropdown de usuario */
.user-dropdown {
    position: relative;
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.97);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1100;
}

.user-dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    margin-bottom: 4px;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 6px 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.dropdown-item.text-danger { color: #fc8181; }
.dropdown-item.text-danger:hover { background: rgba(239, 68, 68, 0.1); color: #fc8181; }

/* Badge de rol */
.role-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

.role-badge.admin {
    background: rgba(124, 58, 237, 0.15);
    color: var(--accent-purple);
    border: 1px solid rgba(124, 58, 237, 0.3);
}

.role-badge.user {
    background: rgba(0, 212, 255, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 212, 255, 0.2);
}

/* ============================================================
   6. LAYOUT PRINCIPAL (Sidebar + Main)
   ============================================================ */

.portal-layout {
    display: flex;
    min-height: 100vh;
    padding-top: 64px; /* altura del navbar */
}

/* SIDEBAR */
.portal-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 900;
    overflow: hidden;
}

.portal-sidebar.collapsed {
    transform: translateX(-260px);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

/* Navegación del sidebar */
.nav-section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 12px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(0, 212, 255, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 212, 255, 0.15);
}

[data-theme="light"] .nav-item.active {
    background: rgba(0, 102, 204, 0.08);
    color: var(--accent-cyan);
    border-color: rgba(0, 102, 204, 0.15);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    background: var(--accent-cyan);
    border-radius: 0 3px 3px 0;
}

/* Proyectos en sidebar */
.project-nav-item {
    border-left: 2px solid transparent;
    transition: all 0.2s ease;
}

.project-nav-item:hover {
    border-left-color: var(--project-color, var(--accent-cyan));
    color: var(--project-color, var(--accent-cyan));
    padding-left: 16px;
}

.text-danger-soft { color: #fc8181 !important; }
.text-danger-soft:hover { background: rgba(239, 68, 68, 0.08) !important; }

/* MAIN CONTENT */
.portal-main {
    flex: 1;
    margin-left: 260px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
}

.portal-main.expanded {
    margin-left: 0;
}

.main-content {
    padding: 28px;
    max-width: 1400px;
}

/* ============================================================
   7. PAGE HEADER Y BREADCRUMBS
   ============================================================ */

.page-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.page-header-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-title .title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    background: var(--gradient-primary);
    border-radius: 12px;
    color: white;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-left: 56px;
}

.breadcrumb-portal {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.breadcrumb-portal a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-portal a:hover { color: var(--accent-cyan); }
.breadcrumb-portal .separator { color: var(--text-muted); }
.breadcrumb-portal .current { color: var(--text-primary); }

/* ============================================================
   8. CARDS
   ============================================================ */

/* Card base */
.card-portal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.card-portal:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

/* Línea de color superior en cards */
.card-portal.accent-top::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 16px 16px 0 0;
}

/* Cards de estadísticas */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -30px; right: -30px;
    width: 100px; height: 100px;
    border-radius: 50%;
    background: var(--stat-color, var(--accent-cyan));
    opacity: 0.05;
    transition: all 0.3s ease;
}

.stat-card:hover::after { opacity: 0.1; transform: scale(1.2); }

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px; height: 52px;
    border-radius: 14px;
    font-size: 1.375rem;
    flex-shrink: 0;
    background: rgba(var(--stat-color-rgb, 0, 212, 255), 0.1);
    color: var(--stat-color, var(--accent-cyan));
    border: 1px solid rgba(var(--stat-color-rgb, 0, 212, 255), 0.2);
}

.stat-info .stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-info .stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Cards de proyectos en dashboard */
.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--project-color, var(--accent-cyan));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.35s ease;
    border-radius: 20px 20px 0 0;
}

.project-card::after {
    content: '';
    position: absolute;
    bottom: -60px; right: -60px;
    width: 160px; height: 160px;
    border-radius: 50%;
    background: var(--project-color, var(--accent-cyan));
    opacity: 0.04;
    transition: all 0.35s ease;
}

.project-card:hover {
    transform: translateY(-6px);
    border-color: var(--project-color, var(--accent-cyan));
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3),
                0 0 0 1px var(--project-color, var(--accent-cyan)),
                0 0 30px rgba(0, 212, 255, 0.1);
    color: var(--text-primary);
    text-decoration: none;
}

.project-card:hover::before { transform: scaleX(1); }
.project-card:hover::after { opacity: 0.08; transform: scale(1.3); }

.project-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px; height: 56px;
    border-radius: 16px;
    font-size: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--project-color, var(--accent-cyan));
    transition: all 0.3s ease;
    flex-shrink: 0;
}

[data-theme="light"] .project-card-icon {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
}

.project-card:hover .project-card-icon {
    background: var(--project-color, var(--accent-cyan));
    color: white;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.4);
}

.project-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.project-card-title {
    font-size: 1.0625rem;
    font-weight: 600;
    margin-bottom: 4px;
    transition: color 0.2s;
}

.project-card:hover .project-card-title {
    color: var(--project-color, var(--accent-cyan));
}

.project-card-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.project-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.project-card-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.project-card:hover .project-card-arrow {
    background: var(--project-color, var(--accent-cyan));
    color: white;
    transform: translateX(4px);
}

/* Badge de versión en project card */
.version-badge {
    font-size: 0.6875rem;
    font-family: 'JetBrains Mono', monospace;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

/* ============================================================
   9. TABLAS
   ============================================================ */

.table-portal-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.table-portal {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table-portal thead th {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table-portal tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

.table-portal tbody tr:last-child { border-bottom: none; }

.table-portal tbody tr:hover {
    background: var(--bg-tertiary);
}

.table-portal tbody td {
    padding: 14px 16px;
    color: var(--text-primary);
    vertical-align: middle;
}

/* ============================================================
   10. FORMULARIOS
   ============================================================ */

.form-portal .form-group {
    margin-bottom: 20px;
}

.form-portal label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-portal label .required {
    color: #fc8181;
    margin-left: 3px;
}

.form-portal .form-control,
.form-portal .form-select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
    appearance: none;
}

.form-portal .form-control:focus,
.form-portal .form-select:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
    background: var(--bg-input);
}

/* Fix: en tema oscuro los <option> del dropdown nativo necesitan fondo sólido */
[data-theme="dark"] select,
[data-theme="dark"] .form-select {
    background-color: #1e2a3a !important;
    color: #e8edf4 !important;
    color-scheme: dark;
}
[data-theme="dark"] select option {
    background-color: #1e2a3a !important;
    color: #e8edf4 !important;
}
[data-theme="dark"] select option:checked,
[data-theme="dark"] select option:hover {
    background-color: #2d3f57 !important;
    color: #ffffff !important;
}

/* Fix: en tema claro los <option> con el nuevo fondo azulado */
[data-theme="light"] select,
[data-theme="light"] .form-select {
    background-color: rgba(255, 255, 255, 0.80) !important;
    color: #0f1e32 !important;
    color-scheme: light;
}
[data-theme="light"] select option {
    background-color: #e8f0f9 !important;
    color: #0f1e32 !important;
}
[data-theme="light"] select option:checked,
[data-theme="light"] select option:hover {
    background-color: #cfdded !important;
    color: #0f1e32 !important;
}

.form-portal .form-control::placeholder { color: var(--text-muted); }

.form-portal textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-portal .form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-portal .form-error {
    font-size: 0.75rem;
    color: #fc8181;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Input con icono */
.input-group-portal {
    position: relative;
}

.input-group-portal .input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.2s;
}

.input-group-portal .form-control {
    padding-left: 38px;
}

.input-group-portal:focus-within .input-icon {
    color: var(--accent-cyan);
}

/* Color picker */
.color-picker-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-picker-group input[type="color"] {
    width: 44px; height: 44px;
    border: 1px solid var(--border-input);
    border-radius: 10px;
    background: var(--bg-input);
    cursor: pointer;
    padding: 2px;
}

/* ============================================================
   11. BOTONES
   ============================================================ */

.btn-portal {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
}

.btn-portal:hover { text-decoration: none; }

.btn-primary-portal {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
}

.btn-primary-portal:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.3);
    color: white;
}

.btn-secondary-portal {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-secondary-portal:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-danger-portal {
    background: rgba(239, 68, 68, 0.1);
    color: #fc8181;
    border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger-portal:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.4);
}

.btn-success-portal {
    background: rgba(0, 255, 136, 0.1);
    color: var(--accent-green);
    border-color: rgba(0, 255, 136, 0.2);
}

.btn-success-portal:hover {
    background: rgba(0, 255, 136, 0.2);
    border-color: rgba(0, 255, 136, 0.4);
}

.btn-sm-portal {
    padding: 6px 12px;
    font-size: 0.8125rem;
    border-radius: 8px;
}

.btn-portal i { font-size: 0.9375rem; }

/* ============================================================
   12. BADGES Y TAGS
   ============================================================ */

.badge-portal {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-active   { background: rgba(52,211,153,0.12);  color: var(--accent-green);  border: 1px solid rgba(52,211,153,0.25); }
.badge-inactive { background: rgba(248,113,113,0.12); color: #f87171;              border: 1px solid rgba(248,113,113,0.25); }
.badge-admin    { background: rgba(167,139,250,0.12); color: var(--accent-purple); border: 1px solid rgba(167,139,250,0.25); }
.badge-user     { background: rgba(96,165,250,0.12);  color: var(--accent-cyan);   border: 1px solid rgba(96,165,250,0.22); }
.badge-view     { background: rgba(96,165,250,0.08);  color: var(--accent-cyan);   border: 1px solid rgba(96,165,250,0.18); }
.badge-edit     { background: rgba(251,191,36,0.12);  color: #fbbf24;              border: 1px solid rgba(251,191,36,0.25); }

/* ============================================================
   13. ALERTS / FLASH MESSAGES
   ============================================================ */

.flash-container {
    margin-bottom: 20px;
}

.alert-portal {
    border-radius: 12px;
    border: 1px solid;
    padding: 12px 16px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: alertSlideIn 0.3s ease;
}

@keyframes alertSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.alert-portal.alert-success {
    background: rgba(0, 255, 136, 0.08);
    border-color: rgba(0, 255, 136, 0.2);
    color: var(--accent-green);
}

.alert-portal.alert-danger {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
    color: #fc8181;
}

.alert-portal.alert-warning {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.alert-portal.alert-info {
    background: rgba(0, 212, 255, 0.08);
    border-color: rgba(0, 212, 255, 0.2);
    color: var(--accent-cyan);
}

.alert-portal .btn-close {
    filter: invert(1);
    opacity: 0.5;
    margin-left: auto;
}

/* ============================================================
   14. EMPTY STATE
   ============================================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
    opacity: 0.4;
    display: block;
}

.empty-state h3 {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.875rem;
    max-width: 320px;
    margin: 0 auto 20px;
}

/* ============================================================
   15. MODAL
   ============================================================ */

.modal-portal .modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
}

.modal-portal .modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
}

.modal-portal .modal-title {
    font-weight: 600;
    color: var(--text-primary);
}

.modal-portal .modal-body { padding: 24px; }
.modal-portal .modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 16px 24px;
}

.modal-portal .btn-close {
    filter: invert(1);
    opacity: 0.5;
}

/* ============================================================
   16. DEMO PROJECT — TASK MANAGER
   ============================================================ */

.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.2s ease;
    margin-bottom: 10px;
}

.task-card:hover {
    border-color: var(--border-hover);
    transform: translateX(4px);
}

.task-card.completed {
    opacity: 0.6;
}

.task-card.completed .task-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-checkbox {
    width: 22px; height: 22px;
    border-radius: 6px;
    border: 2px solid var(--border-input);
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: transparent;
}

.task-checkbox.checked {
    background: var(--accent-green);
    border-color: var(--accent-green);
    color: white;
}

.task-priority {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.priority-high   { background: #fc8181; box-shadow: 0 0 6px rgba(252,129,129,0.5); }
.priority-medium { background: #fbbf24; box-shadow: 0 0 6px rgba(251,191,36,0.5); }
.priority-low    { background: var(--accent-green); box-shadow: 0 0 6px rgba(0,255,136,0.5); }

.task-title {
    flex: 1;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
}

.task-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================================
   17. RESPONSIVE
   ============================================================ */

@media (max-width: 992px) {
    .portal-sidebar {
        transform: translateX(-260px);
        box-shadow: var(--shadow-lg);
    }

    .portal-sidebar.mobile-open {
        transform: translateX(0);
    }

    .portal-main {
        margin-left: 0 !important;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 850;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.active { display: block; }

    .main-content { padding: 20px 16px; }
}

@media (max-width: 576px) {
    .login-card { padding: 32px 24px; margin: 16px; }
    .page-title { font-size: 1.375rem; }
    .brand-version { display: none; }
}

/* ============================================================
   18. UTILIDADES Y ANIMACIONES
   ============================================================ */

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg,
        var(--bg-tertiary) 25%,
        var(--bg-card-hover) 50%,
        var(--bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeletonShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Fade in */
.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Stagger para listas de cards */
.stagger-item { opacity: 0; animation: fadeIn 0.4s ease forwards; }
.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.10s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.20s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }
.stagger-item:nth-child(6) { animation-delay: 0.30s; }
.stagger-item:nth-child(7) { animation-delay: 0.35s; }
.stagger-item:nth-child(8) { animation-delay: 0.40s; }

/* Glow text */
.glow-text {
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
}

/* Divider con gradiente */
.divider-gradient {
    height: 1px;
    background: var(--gradient-primary);
    opacity: 0.3;
    border: none;
    margin: 24px 0;
}

/* Tooltip personalizado */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.75rem;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 9999;
}

[data-tooltip]:hover::after { opacity: 1; }

/* Pulse dot (indicador activo) */
.pulse-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    position: relative;
}

.pulse-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: var(--accent-green);
    opacity: 0.3;
    animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50%       { transform: scale(1.8); opacity: 0; }
}

/* Grid de proyectos */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* Grid de stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

/* Acciones de tabla */
.table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Separador de sección */
.section-gap { margin-bottom: 32px; }

/* Overflow hidden para animaciones */
.overflow-clip { overflow: hidden; }

/* Cursor pointer */
.clickable { cursor: pointer; }

/* Transición suave global */
.smooth { transition: all 0.3s ease; }
