/* ==========================================================================
   Nexus — hoja de estilos única
   Sustituye a: nexus-core/layout/components/auth/dni/luxury.css y a los
   <style> embebidos de cada página. Se apoya en Bootstrap 5.3 (data-bs-theme).
   Secciones: 1 Tokens · 2 Base · 3 Layout · 4 Componentes · 5 Auth · 6 Utilidades
   ========================================================================== */

/* 1. TOKENS ---------------------------------------------------------------- */
:root {
    --nx-primary: #0ea5e9;
    --nx-primary-dark: #0284c7;
    --nx-accent: #6366f1;

    --nx-bg: #f8fafc;
    --nx-surface: rgba(255, 255, 255, .88);
    --nx-surface-solid: #fff;
    --nx-border: rgba(15, 23, 42, .07);
    --nx-text: #1e293b;
    --nx-muted: #64748b;

    --nx-radius: 1rem;
    --nx-radius-lg: 1.5rem;
    --nx-shadow: 0 10px 30px -8px rgba(15, 23, 42, .08);
    --nx-shadow-hover: 0 20px 40px -10px rgba(15, 23, 42, .14);

    --nx-sidebar-w: 280px;
    --nx-sidebar-w-collapsed: 76px;
    --nx-topbar-h: 68px;
    --nx-dock-h: 64px;

    --bs-primary: var(--nx-primary);
    --bs-primary-rgb: 14, 165, 233;
    --bs-link-color: var(--nx-primary-dark);
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

[data-bs-theme="dark"] {
    --nx-bg: #0b1220;
    --nx-surface: rgba(30, 41, 59, .85);
    --nx-surface-solid: #1e293b;
    --nx-border: rgba(255, 255, 255, .08);
    --nx-text: #e2e8f0;
    --nx-muted: #94a3b8;
    --nx-shadow: 0 10px 30px -8px rgba(0, 0, 0, .5);
    --nx-shadow-hover: 0 20px 40px -10px rgba(0, 0, 0, .6);
    --bs-link-color: #7dd3fc;
}

/* 2. BASE ------------------------------------------------------------------ */
body {
    background: var(--nx-bg);
    color: var(--nx-text);
    min-height: 100vh;
}

h1, h2, h3, h4, h5 { letter-spacing: -.02em; }

.btn-primary {
    --bs-btn-bg: var(--nx-primary);
    --bs-btn-border-color: var(--nx-primary);
    --bs-btn-hover-bg: var(--nx-primary-dark);
    --bs-btn-hover-border-color: var(--nx-primary-dark);
    --bs-btn-active-bg: var(--nx-primary-dark);
    --bs-btn-active-border-color: var(--nx-primary-dark);
    font-weight: 600;
}
.btn { border-radius: .75rem; }

.form-control, .form-select {
    border-radius: .75rem;
    border-color: var(--nx-border);
}
.form-control:focus, .form-select:focus {
    border-color: var(--nx-primary);
    box-shadow: 0 0 0 .25rem rgba(14, 165, 233, .18);
}

/* 3. LAYOUT (app autenticada) ---------------------------------------------- */
.nx-topbar {
    position: fixed; inset: 0 0 auto 0;
    height: var(--nx-topbar-h);
    z-index: 1030;
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1rem;
    background: var(--nx-surface);
    backdrop-filter: blur(18px) saturate(180%);
    border-bottom: 1px solid var(--nx-border);
}
.nx-brand {
    display: flex; align-items: center; gap: .6rem;
    font-weight: 800; font-size: 1.3rem; text-decoration: none;
    background: linear-gradient(135deg, var(--nx-primary), #3b82f6);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.nx-brand img { width: 36px; height: auto; -webkit-text-fill-color: initial; }

.nx-icon-btn {
    width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: .85rem; border: 1px solid var(--nx-border);
    background: var(--nx-surface-solid); color: var(--nx-muted);
    transition: .2s;
}
.nx-icon-btn:hover { color: var(--nx-primary); transform: translateY(-2px); }

.nx-chip {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .4rem .9rem; border-radius: 999px;
    background: var(--nx-surface-solid); border: 1px solid var(--nx-border);
    color: var(--nx-muted); font-weight: 600; font-size: .9rem; text-decoration: none;
}
a.nx-chip:hover { color: var(--nx-primary); }

.nx-sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: var(--nx-sidebar-w);
    padding: calc(var(--nx-topbar-h) + 1rem) .75rem 1.5rem;
    background: var(--nx-surface);
    backdrop-filter: blur(14px);
    border-right: 1px solid var(--nx-border);
    overflow-y: auto; overflow-x: hidden;
    z-index: 1020;
    transition: width .3s cubic-bezier(.4, 0, .2, 1);
}
.nx-sidebar .nav-link {
    display: flex; align-items: center; gap: .85rem;
    padding: .7rem .9rem; margin-bottom: .2rem;
    color: var(--nx-muted); font-weight: 500; white-space: nowrap;
    border-radius: .85rem; transition: .2s;
}
.nx-sidebar .nav-link i.fa-fw { font-size: 1.1rem; width: 1.5rem; }
.nx-sidebar .nav-link:hover { background: rgba(14, 165, 233, .08); color: var(--nx-text); }
.nx-sidebar .nav-link.active,
.nx-sidebar .nav-link[aria-expanded="true"] { background: rgba(14, 165, 233, .1); color: var(--nx-primary); font-weight: 600; }
.nx-sidebar .nav-arrow { margin-left: auto; font-size: .7rem; transition: transform .2s; }
.nx-sidebar .nav-link[aria-expanded="true"] .nav-arrow { transform: rotate(180deg); }
.nx-sidebar .nx-submenu { margin: .1rem 0 .5rem 1.6rem; padding-left: .5rem; border-left: 2px solid var(--nx-border); }
.nx-sidebar .nx-submenu .nav-link { font-size: .9rem; padding: .45rem .8rem; }

.nx-main {
    padding: calc(var(--nx-topbar-h) + 1.5rem) 1.25rem calc(var(--nx-dock-h) + 2rem);
    margin-left: var(--nx-sidebar-w);
    transition: margin-left .3s cubic-bezier(.4, 0, .2, 1);
}
body.sidebar-collapsed .nx-sidebar { width: var(--nx-sidebar-w-collapsed); }
body.sidebar-collapsed .nx-sidebar .nav-text,
body.sidebar-collapsed .nx-sidebar .nav-arrow,
body.sidebar-collapsed .nx-sidebar .nx-submenu { display: none; }
body.sidebar-collapsed .nx-main { margin-left: var(--nx-sidebar-w-collapsed); }

@media (max-width: 991.98px) {
    .nx-sidebar { transform: translateX(-100%); width: var(--nx-sidebar-w); box-shadow: var(--nx-shadow-hover); }
    body.sidebar-open .nx-sidebar { transform: none; }
    .nx-main, body.sidebar-collapsed .nx-main { margin-left: 0; }
    body.sidebar-collapsed .nx-sidebar .nav-text,
    body.sidebar-collapsed .nx-sidebar .nav-arrow { display: initial; }
}
@media (min-width: 992px) {
    .nx-dock { display: none !important; }
    .nx-main { padding-bottom: 2rem; }
}

.nx-guest .nx-main { margin-left: 0; max-width: 1100px; margin-inline: auto; }

/* Dock inferior (solo móvil) */
.nx-dock {
    position: fixed; inset: auto 0 0 0; height: calc(var(--nx-dock-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: flex; justify-content: space-around; align-items: center;
    background: linear-gradient(90deg, #0d6efd, #ffc107 50%, #dc3545);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, .2); z-index: 1025;
}
.nx-dock a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: rgba(255, 255, 255, .88); font-size: .72rem; font-weight: 600; text-decoration: none;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: .2s;
}
.nx-dock a i { font-size: 1.35rem; }
.nx-dock a img { width: 38px; }
.nx-dock a.active, .nx-dock a:hover { color: #fff; transform: translateY(-3px); }

/* 4. COMPONENTES ----------------------------------------------------------- */
.nx-page-header { margin-bottom: 1.75rem; }
.nx-page-header h1 { font-weight: 800; font-size: clamp(1.6rem, 3vw, 2.3rem); margin: 0; }
.nx-page-header p { color: var(--nx-muted); margin: .25rem 0 0; }

.nx-card {
    background: var(--nx-surface);
    backdrop-filter: blur(14px);
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius-lg);
    box-shadow: var(--nx-shadow);
    padding: 1.5rem;
}
.nx-card-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 1rem; display: flex; align-items: center; gap: .6rem; }

.nx-stat { transition: .3s cubic-bezier(.4, 0, .2, 1); }
.nx-stat:hover { transform: translateY(-4px); box-shadow: var(--nx-shadow-hover); }
.nx-stat .nx-stat-icon {
    width: 46px; height: 46px; border-radius: .9rem; margin-bottom: .9rem;
    display: flex; align-items: center; justify-content: center; font-size: 1.15rem; color: #fff;
}
.nx-stat .nx-stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.nx-stat .nx-stat-label { color: var(--nx-muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }

.nx-table { --bs-table-bg: transparent; margin: 0; }
.nx-table thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--nx-muted); font-weight: 700; padding: 1rem; border-bottom: 2px solid var(--nx-border);
}
.nx-table tbody td { padding: 1rem; vertical-align: middle; border-color: var(--nx-border); }

.nx-badge {
    display: inline-block; padding: .3rem .65rem; border-radius: .6rem; margin: 0 .25rem .25rem 0;
    background: rgba(99, 102, 241, .1); color: var(--nx-accent); font-size: .78rem; font-weight: 600;
}
.nx-badge.is-off { opacity: .5; }
.nx-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 700; font-size: .85rem;
    background: rgba(100, 116, 139, .12); padding: .2rem .5rem; border-radius: .4rem; }

.nx-amount-in { color: #10b981; font-weight: 700; }
.nx-amount-out { color: #ef4444; font-weight: 700; }

.nx-avatar {
    width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
    background: linear-gradient(135deg, var(--nx-primary), var(--nx-accent));
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: 2.2rem; font-weight: 800;
}

.nx-empty { text-align: center; padding: 2.5rem 1rem; color: var(--nx-muted); }
.nx-empty i { font-size: 2.4rem; margin-bottom: .75rem; opacity: .5; }

.nx-flash-stack { position: fixed; top: calc(var(--nx-topbar-h) + .75rem); right: 1rem; z-index: 1080; width: min(420px, calc(100vw - 2rem)); }

/* Animación de entrada */
.nx-fade { animation: nxFade .5s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes nxFade { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .nx-fade { animation: none; } * { transition: none !important; } }

/* 5. AUTH ------------------------------------------------------------------ */
.nx-auth {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem;
    position: relative; overflow: hidden;
    background:
        radial-gradient(60rem 30rem at 0% 0%, rgba(99, 102, 241, .18), transparent 60%),
        radial-gradient(50rem 30rem at 100% 100%, rgba(14, 165, 233, .2), transparent 60%),
        var(--nx-bg);
}
.nx-auth-card { width: 100%; max-width: 440px; z-index: 1; padding: 2rem; }
.nx-auth-card.wide { max-width: 640px; }
.nx-auth-logo { width: 72px; display: block; margin: 0 auto 1rem; }
[data-bs-theme="dark"] .nx-auth-logo { filter: invert(1) hue-rotate(180deg); }
.nx-input-icon { position: relative; }
.nx-input-icon > i { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: var(--nx-muted); pointer-events: none; }
.nx-input-icon > .form-control { padding-left: 2.5rem; }
.nx-theme-toggle { position: fixed; top: 1rem; right: 1rem; z-index: 5; }

/* 6. UTILIDADES ------------------------------------------------------------ */
.text-muted-nx { color: var(--nx-muted) !important; }
.bg-grad-primary { background: linear-gradient(135deg, #0ea5e9, #3b82f6); }
.bg-grad-success { background: linear-gradient(135deg, #10b981, #059669); }
.bg-grad-warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.bg-grad-accent  { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
