/* layout.css — App shell: sidebar + content + login */

/* ─── App Shell ────────────────────────────────────────────── */
#app {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    width: 240px;
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid var(--sidebar-border);
    position: sticky;
    top: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Webkit thin scrollbar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Subtle top glow accent */
.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--sidebar-brand);
    opacity: 0.6;
}

/* ─── Sidebar Header ──────────────────────────────────────── */
.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-logo {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--sidebar-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

.sidebar-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    letter-spacing: -0.01em;
}

.sidebar-header .sidebar-version {
    font-size: 0.6rem;
    color: var(--sidebar-text);
    opacity: 0.5;
    font-weight: 400;
    margin-left: auto;
    font-family: var(--font-mono);
}

/* ─── Sidebar Navigation ──────────────────────────────────── */
.sidebar-nav {
    padding: 8px 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.nav-section {
    padding: 16px 16px 6px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255, 255, 255, 0.25);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    margin: 1px 8px;
    color: var(--sidebar-text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    width: calc(100% - 16px);
    text-align: left;
    font-family: inherit;
    border-radius: var(--radius);
    position: relative;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-active-text);
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.3);
}

/* Nav icon placeholder */
.nav-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav-item.active .nav-icon { opacity: 1; }

/* Nav item badge (notification count) */
.nav-badge {
    margin-left: auto;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: rgba(239, 68, 68, 0.9);
    color: #fff;
    min-width: 18px;
    text-align: center;
}

/* ─── Sidebar Footer ──────────────────────────────────────── */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.sidebar-user {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.sidebar-user strong {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 0.95rem;
    padding: 6px;
    border-radius: var(--radius);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.theme-toggle:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

/* ─── Main Content ─────────────────────────────────────────── */
.content {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
    background: var(--bg-primary);
    min-width: 0;
}

/* ─── Login Layout ─────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════
   LOGIN — Premium split layout (brand + form)
   ═══════════════════════════════════════════════════════════════ */

/* Legacy wrapper (backward compat for pages still using it) */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--login-bg);
    position: relative;
}

/* Split layout: brand left, form right */
.login-split {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ─── Brand Panel — dark with animated orbs ────────────── */
.login-brand-panel {
    position: relative;
    width: 42%;
    min-height: 100vh;
    background: linear-gradient(135deg, #020617 0%, #0f172a 50%, #1e1b4b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Grid overlay on brand panel */
.login-brand-panel::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(59, 130, 246, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    animation: gridPulse 8s ease-in-out infinite;
    mask-image: radial-gradient(ellipse 60% 60% at center, black 30%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse 60% 60% at center, black 30%, transparent 70%);
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* Floating gradient orbs */
.login-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    opacity: 0.4;
}

.login-orb-1 {
    width: 300px; height: 300px;
    background: radial-gradient(circle, #3b82f6 0%, transparent 70%);
    top: -80px; right: -60px;
    animation: orbFloat1 12s ease-in-out infinite;
}

.login-orb-2 {
    width: 250px; height: 250px;
    background: radial-gradient(circle, #6366f1 0%, transparent 70%);
    bottom: -60px; left: -40px;
    animation: orbFloat2 15s ease-in-out infinite;
}

.login-orb-3 {
    width: 180px; height: 180px;
    background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
    top: 40%; left: 50%;
    animation: orbFloat3 10s ease-in-out infinite;
}

@keyframes orbFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-30px, 40px) scale(1.1); }
    66% { transform: translate(20px, -20px) scale(0.9); }
}

@keyframes orbFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(40px, -30px) scale(1.15); }
}

@keyframes orbFloat3 {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.3; }
    50% { transform: translate(-50%, -50%) scale(1.3); opacity: 0.5; }
}

/* Brand content centered in panel */
.login-brand-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px;
}

/* Shield logo */
.login-shield {
    width: 80px;
    height: 96px;
    margin: 0 auto 28px;
    filter: drop-shadow(0 4px 20px rgba(59, 130, 246, 0.4));
    animation: shieldGlow 4s ease-in-out infinite;
}

.login-shield-svg {
    width: 100%;
    height: 100%;
}

/* Text fallback for setup page (no SVG logo) */
.login-shield-text {
    width: 64px;
    height: 64px;
    margin: 0 auto 28px;
    border-radius: 16px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.4);
    animation: shieldGlow 4s ease-in-out infinite;
}

@keyframes shieldGlow {
    0%, 100% { filter: drop-shadow(0 4px 20px rgba(59, 130, 246, 0.3)); }
    50% { filter: drop-shadow(0 4px 30px rgba(59, 130, 246, 0.6)); }
}

.login-brand-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #f1f5f9;
    margin-bottom: 6px;
    background: linear-gradient(135deg, #e2e8f0 0%, #93c5fd 50%, #c4b5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-brand-subtitle {
    font-size: 0.9rem;
    color: #94a3b8;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 500;
    margin-bottom: 32px;
}

/* Feature badges */
.login-brand-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.login-feature-badge {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    border-radius: 13px;
    background: rgba(59, 130, 246, 0.12);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.2);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    white-space: nowrap;
}

/* ─── Form Panel — light/glass side ────────────────────── */
.login-form-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px 56px;
    background: var(--bg-primary);
    min-height: 100vh;
    overflow-y: auto;
}

.login-form-header {
    margin-bottom: 32px;
}

.login-form-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.login-form-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-form {
    max-width: 380px;
}

.login-form .form-field {
    margin-bottom: 20px;
}

.login-form .form-field input {
    height: 42px;
    padding: 0 14px;
    font-size: 14px;
    border-radius: var(--radius);
}

.login-form .btn-lg {
    height: 44px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
    margin-top: 8px;
}

/* MFA section */
.login-mfa {
    padding: 16px;
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light, var(--border));
    margin-bottom: 16px;
}

.login-mfa-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.login-mfa .form-field {
    margin-bottom: 0;
}

.login-mfa .form-field label {
    display: none;
}

/* Checkbox label */
.login-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}

/* Form footer */
.login-form-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light, var(--border));
}

.login-form-footer p {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
    .content { padding: 24px; }
}

@media (max-width: 768px) {
    .sidebar {
        width: 64px;
    }

    .sidebar-header h2,
    .sidebar-header .sidebar-version { display: none; }
    .nav-item span:not(.nav-icon) { display: none; }
    .nav-section { display: none; }
    .sidebar-user { display: none; }
    .nav-badge { display: none; }

    .nav-item {
        justify-content: center;
        margin: 1px 4px;
        padding: 10px;
        width: calc(100% - 8px);
    }

    .nav-icon { opacity: 1; font-size: 1.1rem; }

    .content { padding: 16px; }

    /* Login split → stacked on tablet */
    .login-split { flex-direction: column; }
    .login-brand-panel { width: 100%; min-height: auto; padding: 40px 24px; }
    .login-brand-content { padding: 20px; }
    .login-shield { width: 56px; height: 67px; margin-bottom: 16px; }
    .login-shield-text { width: 48px; height: 48px; font-size: 22px; margin-bottom: 16px; }
    .login-brand-title { font-size: 1.3rem; }
    .login-brand-subtitle { font-size: 0.8rem; margin-bottom: 20px; }
    .login-form-panel { padding: 32px 24px; min-height: auto; }
    .login-form { max-width: 100%; }

    /* Legacy login-card compat */
    .login-card { margin: 16px; padding: 28px; }
}

/* ─── Extra small screens ─────────────────────────────────── */
@media (max-width: 480px) {
    .content { padding: 12px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .page-header h1 { font-size: 1.2rem; }
    .login-brand-panel { padding: 24px 16px; }
    .login-brand-features { gap: 6px; }
    .login-feature-badge { font-size: 10px; height: 22px; padding: 0 8px; }
    .login-form-panel { padding: 24px 16px; }
    .login-form .form-field input { height: 38px; }
    .login-card { margin: 8px; padding: 20px; }
}

/* ─── Large screens ───────────────────────────────────────── */
@media (min-width: 1400px) {
    .content { max-width: 1320px; padding: 32px 40px; }
}

/* ─── Sidebar Mode Selector ──────────────────────────────── */
.sidebar-mode-selector {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.sidebar-mode-selector label {
    display: block;
    font-size: 0.6rem;
    color: rgba(255,255,255,0.45);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.mode-select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(255,255,255,0.08);
    color: #cbd5e1;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: border-color 180ms;
    -webkit-appearance: none;
}
.mode-select:hover { border-color: rgba(255,255,255,0.4); }
.mode-select:focus { border-color: #3b82f6; }
.mode-select option { background: #1e293b; color: #e2e8f0; }

/* ─── TCVN Tooltip ───────────────────────────────────────── */
.tcvn-tooltip {
    position: fixed;
    z-index: 10010;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    padding: 10px 14px;
    max-width: 460px;
    min-width: 280px;
    font-size: 0.75rem;
    color: #e2e8f0;
    pointer-events: none;
    line-height: 1.5;
    white-space: pre-line;
}
.tcvn-tooltip-content {
    font-family: var(--font-mono, 'SF Mono', 'Cascadia Code', monospace);
    font-size: 0.7rem;
}
[data-theme="light"] .tcvn-tooltip {
    background: #fff;
    border-color: #e2e8f0;
    color: #1e293b;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

/* NTP Alert styles */
.ntp-alert {
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid;
}
.ntp-alert-danger {
    background: var(--danger-bg);
    border-left-color: var(--danger);
}
.ntp-alert-success {
    background: var(--success-bg);
    border-left-color: var(--success);
}

/* Tooltip toggle active state */
.theme-toggle.active {
    background: rgba(59,130,246,0.3);
    color: #60a5fa;
}
