/**
 * ═══════════════════════════════════════════════════════════════════════════════
 *  SECUBOX SIDEBAR — DARK THEME v2.0
 *  Based on Charte Graphique Six-Module Color System
 * ═══════════════════════════════════════════════════════════════════════════════
 *
 *  SecuBox-Deb :: Sidebar Component (Glass Morphism)
 *  CyberMind — https://cybermind.fr
 *  Author: Gérald Kerma <gandalf@gk2.net>
 *  License: Proprietary / ANSSI CSPN candidate
 *
 *  Location: Notre-Dame-du-Cruet · Savoie · France
 *  Project: SecuBox-Deb — Debian-based security appliance
 *
 * ───────────────────────────────────────────────────────────────────────────────
 *  FEATURES:
 * ───────────────────────────────────────────────────────────────────────────────
 *  - Glass Morphism: backdrop-filter blur effect
 *  - Six-Module Color System: AUTH/WALL/BOOT/MIND/ROOT/MESH
 *  - Collapsible nav sections with animation
 *  - Responsive mobile toggle (hamburger menu)
 *  - Status indicators with pulse animations
 *  - Dev badges (alpha/beta)
 *  - Theme toggle button
 *
 * ───────────────────────────────────────────────────────────────────────────────
 *  USAGE:
 * ───────────────────────────────────────────────────────────────────────────────
 *  Requires: design-tokens.css (CSS Custom Properties)
 *  Load sidebar content via: /shared/sidebar.js
 *
 * ───────────────────────────────────────────────────────────────────────────────
 *  COPYRIGHT (C) 2024-2025 CyberMind / Gérald Kerma
 *  All Rights Reserved — Unauthorized use prohibited
 * ═══════════════════════════════════════════════════════════════════════════════
 */

/* ── IMPORT DESIGN TOKENS ── */
@import url('./design-tokens.css');

/* ── EMOJI FONT FALLBACK ── */
/* Force browser to use system emoji fonts with explicit fallback */
@font-face {
  font-family: 'Emoji';
  src: local('Noto Color Emoji'),
       local('Apple Color Emoji'),
       local('Segoe UI Emoji'),
       local('Segoe UI Symbol'),
       local('Symbola'),
       local('EmojiOne Color'),
       local('Twemoji Mozilla');
  unicode-range: U+1F000-1F9FF, U+2600-26FF, U+2700-27BF, U+FE00-FE0F, U+1F100-1F1FF;
}

/* ── SIDEBAR CONTAINER — Glass Morphism ── */
/* !important used to override inline module styles */
.sidebar,
body .sidebar,
.hybrid-skin .sidebar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 220px !important;
  height: 100vh !important;
  background: var(--glass-bg, rgba(17, 23, 32, 0.7)) !important;
  backdrop-filter: blur(var(--glass-blur, 20px)) !important;
  -webkit-backdrop-filter: blur(var(--glass-blur, 20px)) !important;
  border-right: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08)) !important;
  display: flex !important;
  flex-direction: column !important;
  z-index: 1000 !important;
  font-family: var(--font-body) !important;
  overflow: hidden !important;
  box-shadow: 2px 0 20px rgba(0,0,0,0.3) !important;
}

/* Left accent stripe */
.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--root-main), var(--mesh-main), var(--mind-main));
}

/* ── HEADER ── */
.sidebar-header {
  padding: 1.25rem 1rem 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: transparent !important;
}

.sidebar-header a {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Logo styling */
.logo {
  font-size: 1rem;
  font-weight: var(--weight-bold);
  letter-spacing: 0.1em;
  color: var(--root-light);
  text-shadow: 0 0 6px rgba(20,140,102,0.5);
  text-transform: uppercase;
}

.logo-icon {
  font-size: 1.3rem;
  filter: drop-shadow(0 0 6px rgba(20,140,102,0.5));
  font-family: 'Emoji', 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Symbola', sans-serif;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
}

.logo-version {
  display: block;
  font-size: 0.55rem;
  color: var(--muted-dark);
  letter-spacing: 0.15em;
  margin-top: 0.15rem;
  font-family: var(--font-mono);
}

/* ── SCROLLABLE NAV ── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border2-dark) var(--bg-dark);
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border2-dark);
  border-radius: 2px;
}

/* ── NAVIGATION SECTIONS ── */
.nav-section {
  margin-bottom: 0.25rem;
}

.nav-section-title {
  padding: 0.6rem 1rem 0.6rem 1.5rem;
  font-size: var(--size-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--wall-light);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all var(--transition-fast);
  border-left: 2px solid transparent;
  font-family: var(--font-mono);
}

.nav-section-title:hover {
  color: var(--wall-main);
  background: rgba(204,136,32,0.08);
  border-left-color: var(--wall-dark);
}

.nav-section-title .cat-icon {
  font-family: 'Emoji', 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Symbola', sans-serif;
  font-size: 0.9rem;
  line-height: 1;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
}

.nav-section-title .toggle-icon {
  font-size: 0.55rem;
  color: var(--muted-dark);
  transition: transform 0.2s;
}

.nav-section.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.nav-section.collapsed .nav-items {
  display: none;
}

/* ── NAV ITEMS ── */
.nav-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem 0.55rem 2rem;
  text-decoration: none;
  color: var(--text-dark);
  font-size: var(--size-sm);
  letter-spacing: 0.03em;
  transition: all 0.15s ease;
  border-left: 2px solid transparent;
  position: relative;
}

.nav-item:hover {
  background: rgba(20,140,102,0.08);
  color: var(--root-light);
  border-left-color: var(--root-dark);
}

.nav-item.active {
  background: rgba(20,140,102,0.15);
  color: var(--root-light);
  text-shadow: 0 0 6px rgba(20,140,102,0.5);
  border-left-color: var(--root-light);
  font-weight: var(--weight-semibold);
}

.nav-item.active::before {
  content: '>';
  position: absolute;
  left: 1rem;
  color: var(--root-light);
  animation: blink-cursor 1.2s step-start infinite;
}

@keyframes blink-cursor {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.nav-item .icon {
  font-size: 0.95rem;
  width: 1.3rem;
  text-align: center;
  font-family: 'Emoji', 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Symbola', sans-serif;
  line-height: 1;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
}

.nav-item span:not(.icon):not(.status-dot):not(.status-led) {
  flex: 1;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.2;
  word-break: break-word;
}

/* ── STATUS INDICATORS — 6-MODULE COLORS ── */
.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border2-dark);
  margin-left: auto;
}

.status-dot.active {
  background: var(--root-light);
  box-shadow: 0 0 6px var(--root-light), 0 0 12px rgba(20,140,102,0.4);
  animation: pulse-glow 2s ease-in-out infinite;
}

.status-dot.warning {
  background: var(--wall-light);
  box-shadow: 0 0 6px var(--wall-light);
}

.status-dot.error {
  background: var(--boot-light);
  box-shadow: 0 0 6px var(--boot-light);
  animation: pulse-error 1s ease-in-out infinite;
}

.status-dot.info {
  background: var(--mesh-light);
  box-shadow: 0 0 6px var(--mesh-light);
}

.status-dot.mind {
  background: var(--mind-light);
  box-shadow: 0 0 6px var(--mind-light);
}

/* ── DEV STAGE BADGES ── */
.dev-badge {
  font-size: 0.65em;
  font-weight: bold;
  padding: 0.1em 0.35em;
  border-radius: 3px;
  margin-left: 0.3em;
  margin-right: 0.2em;
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dev-badge.alpha {
  background: rgba(230, 57, 70, 0.25);
  color: var(--boot-light);
  border: 1px solid rgba(230, 57, 70, 0.5);
}

.dev-badge.beta {
  background: rgba(201, 168, 76, 0.25);
  color: var(--gold-hermetic, #c9a84c);
  border: 1px solid rgba(201, 168, 76, 0.5);
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes pulse-error {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── THEME TOGGLE ── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem;
  margin: 0.5rem 1rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-dark);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  transition: all var(--transition-fast);
  width: calc(100% - 2rem);
}
.theme-toggle:hover {
  border-color: var(--root-dark);
  color: var(--root-light);
  background: rgba(20,140,102,0.1);
}
.theme-icon {
  font-size: 1.1rem;
}

/* ── FOOTER ── */
.sidebar-footer {
  padding: 0.75rem 1rem 0.75rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: transparent !important;
}

.sidebar-clock {
  font-size: var(--size-xs);
  color: var(--muted-dark);
  letter-spacing: 0.1em;
  text-align: center;
  font-family: var(--font-mono);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  margin-top: 0.5rem;
  border: 1px solid var(--border-dark);
  background: rgba(20,140,102,0.05);
  border-radius: var(--radius-md);
}

.sidebar-user-avatar {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--root-light);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.75rem;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.6rem;
  color: var(--muted-dark);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.sidebar-logout {
  background: none;
  border: 1px solid var(--border-dark);
  color: var(--muted-dark);
  padding: 0.25rem 0.5rem;
  font-size: 0.65rem;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.08em;
  transition: all var(--transition-fast);
  text-transform: uppercase;
  border-radius: var(--radius-sm);
}

.sidebar-logout:hover {
  border-color: var(--boot-main);
  color: var(--boot-light);
  text-shadow: 0 0 6px rgba(192,96,64,0.4);
}

/* ── MOBILE ── */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1001;
  background: var(--surface-dark);
  border: 1px solid var(--border-dark);
  color: var(--root-light);
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .main, .main-content {
    margin-left: 0 !important;
  }
}

/* ── MAIN CONTENT OFFSET ── */
.main, .main-content {
  margin-left: 220px;
}
