

:root {
  --red:          #c0392b;
  --red-deep:     #96281b;
  --red-pale:     #fdf0ee;
  --gold:         #b8963e;
  --gold-light:   #d4af6a;
  --gold-pale:    rgba(184, 150, 62, .10);
  --green:        #2d7a47;
  --green-pale:   #edf7f0;
  --blue:         #1a5276;
  --blue-pale:    #eaf2f8;
  --orange:       #c47a1a;
  --orange-pale:  #fef9ec;
  --purple:       #6d3b8e;
  --purple-pale:  #f3ecf9;

  --bg-page:      #f5f0eb;
  --bg-surface:   #ffffff;
  --bg-surface2:  #faf7f4;
  --bg-input:     #f0ebe5;

  --text:         #1a1210;
  --text-2:       #4a3830;
  --text-3:       #9b8c86;

  --border:       #e8ddd8;
  --border-2:     #d5c9c3;

  --topbar-bg:    #ffffff;
  --topbar-h:     56px;

  --sidebar-w:           250px;
  --sidebar-w-collapsed: 64px;
  --sidebar-bg:          #ffffff;
  --sidebar-border:      #e8ddd8;
  --sidebar-text:        #4a3830;
  --sidebar-text-muted:  #9b8c86;
  --sidebar-hover-bg:    rgba(192, 57, 43, .05);
  --sidebar-active-bg:   rgba(192, 57, 43, .09);
  --sidebar-active-txt:  #c0392b;
  --sidebar-section-clr: rgba(74, 56, 48, .35);
  --sidebar-divider:     rgba(74, 56, 48, .10);
  --sidebar-logo-sub:    rgba(184, 150, 62, .75);
  --sidebar-logo-brand:  #1a1210;

  --footer-bg:    #ffffff;
  --footer-h:     44px;

  --shadow-sm:    0 1px  8px rgba(0, 0, 0, .05);
  --shadow-md:    0 6px 20px rgba(0, 0, 0, .08);
  --shadow-lg:    0 12px 32px rgba(0, 0, 0, .10);

  --radius:       12px;
  --transition:   .25s ease;
}

[data-theme="dark"] {
  --bg-page:      #0f1117;
  --bg-surface:   #1a1d27;
  --bg-surface2:  #20232f;
  --bg-input:     #14161f;
  --text:         #eee8e3;
  --text-2:       #a89f96;
  --text-3:       #5a5250;
  --border:       #282b38;
  --border-2:     #32364a;
  --green-pale:   rgba(45,  122,  71, .15);
  --blue-pale:    rgba(26,   82, 118, .15);
  --orange-pale:  rgba(196, 122,  26, .15);
  --red-pale:     rgba(192,  57,  43, .12);
  --gold-pale:    rgba(184, 150,  62, .12);
  --purple-pale:  rgba(109,  59, 142, .15);
  --topbar-bg:    #1a1d27;
  --footer-bg:    #1a1d27;
  --sidebar-bg:          #1a1210;
  --sidebar-border:      rgba(255, 255, 255, .06);
  --sidebar-text:        rgba(255, 255, 255, .85);
  --sidebar-text-muted:  rgba(255, 255, 255, .38);
  --sidebar-hover-bg:    rgba(255, 255, 255, .05);
  --sidebar-active-bg:   rgba(192,  57,  43, .22);
  --sidebar-active-txt:  #ffffff;
  --sidebar-section-clr: rgba(255, 255, 255, .22);
  --sidebar-divider:     rgba(255, 255, 255, .07);
  --sidebar-logo-sub:    rgba(184, 150,  62, .62);
  --sidebar-logo-brand:  #ffffff;
  --shadow-sm:    0 1px  8px rgba(0, 0, 0, .40);
  --shadow-md:    0 6px 20px rgba(0, 0, 0, .50);
  --shadow-lg:    0 12px 32px rgba(0, 0, 0, .60);
}


/* ============================================================
   2. MAIN CONTENT
   ============================================================ */

#mainContent {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

#pageArea {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  padding-bottom: 48px;
  transition: opacity .15s;
}
#pageArea.loading { opacity: 0; }


/* ============================================================
   3. SIDEBAR
   ============================================================ */

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100dvh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 100;
  overflow: hidden;
  flex-shrink: 0;
  transition:
    width         .3s ease,
    min-width     .3s ease,
    background    var(--transition),
    border-color  var(--transition);
}

/* Collapsed */
#sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
  min-width: var(--sidebar-w-collapsed);
}
#sidebar.collapsed .nav-lbl,
#sidebar.collapsed .nav-section-title,
#sidebar.collapsed .sidebar-footer-text,
#sidebar.collapsed .badge-dot,
#sidebar.collapsed .logo-text { display: none; }
#sidebar.collapsed .nav-item  { justify-content: center; padding: 10px 0; }
#sidebar.collapsed .nav-item i { margin: 0; }
#sidebar.collapsed .sidebar-footer { justify-content: center; padding: 14px 0; }
#sidebar.collapsed .sidebar-avatar { margin: 0; }

/* Logo */
.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--sidebar-divider);
  flex-shrink: 0;
}
.logo-wrapper { display: flex; align-items: center; justify-content: space-between; }
.logo-text { white-space: nowrap; overflow: hidden; }

.sidebar-logo-brand {
  font-family: 'Playfair Display', serif;
  font-size: 21px; font-weight: 900;
  color: var(--sidebar-logo-brand);
  transition: color var(--transition);
  line-height: 1.1;
}
.sidebar-logo-brand em { color: var(--red); font-style: italic; font-weight: 300; }

.sidebar-logo-sub {
  display: block;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic; font-size: 9px;
  color: var(--sidebar-logo-sub);
  letter-spacing: .3em; text-transform: uppercase;
  margin-top: -2px;
  transition: color var(--transition);
}

/* Role badge */
.sidebar-role-badge {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 6px; padding: 2px 8px;
  background: var(--gold-pale);
  border: 1px solid rgba(184, 150, 62, .25);
  border-radius: 20px;
  font-size: 9px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--gold);
}
.sidebar-role-badge.role-staff { background: var(--blue-pale); border-color: rgba(26,82,118,.2); color: var(--blue); }
.sidebar-role-badge.role-admin { background: var(--gold-pale); border-color: rgba(184,150,62,.25); color: var(--gold); }

/* Toggle */
.sidebar-toggle-btn {
  background: transparent; border: none;
  color: var(--sidebar-text-muted);
  font-size: 15px; padding: 4px;
  cursor: pointer; transition: color .2s; flex-shrink: 0;
}
.sidebar-toggle-btn:hover { color: var(--sidebar-text); }

/* Gold line */
.gold-line {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold) 30%, var(--gold-light) 50%, var(--gold) 70%, transparent);
  opacity: .3; flex-shrink: 0;
}

/* Nav */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; min-height: 0; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-section-title {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3em;
  color: var(--sidebar-section-clr);
  padding: 16px 18px 6px; white-space: nowrap;
  transition: color var(--transition);
}

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 18px; width: 100%;
  background: transparent; border: none; text-align: left;
  font-family: inherit; font-size: 12px; font-weight: 500;
  letter-spacing: .03em; color: var(--sidebar-text-muted);
  white-space: nowrap; position: relative; cursor: pointer;
  transition: color .2s, background .2s;
}
.nav-item i { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-lbl { flex: 1; }
.nav-item:hover  { color: var(--sidebar-text); background: var(--sidebar-hover-bg); }
.nav-item.active { color: var(--sidebar-active-txt); background: var(--sidebar-active-bg); }
.nav-item.active::before {
  content: ''; position: absolute;
  left: 0; top: 4px; bottom: 4px; width: 3px;
  background: var(--red); border-radius: 0 2px 2px 0;
}

.nav-divider { height: 1px; background: var(--sidebar-divider); margin: 6px 18px; }

.badge-dot {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 9px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; flex-shrink: 0;
}
.badge-dot.orange { background: var(--orange); }
.badge-dot.green  { background: var(--green); }
.badge-dot.gold   { background: var(--gold); }

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--sidebar-divider);
  padding: 14px 18px;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--red); color: #fff;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-avatar.gold   { background: var(--gold); }
.sidebar-avatar.green  { background: var(--green); }
.sidebar-avatar.blue   { background: var(--blue); }
.sidebar-avatar.purple { background: var(--purple); }

.sidebar-footer-text { flex: 1; overflow: hidden; }
.sidebar-footer-name {
  font-size: 12px; font-weight: 600; color: var(--sidebar-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color var(--transition);
}
.sidebar-footer-role { font-size: 10px; color: var(--sidebar-text-muted); transition: color var(--transition); }

.sidebar-online-dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--green);
  margin-right: 5px; animation: pulse 2s infinite;
}

.sidebar-logout-btn {
  background: transparent; border: none;
  color: var(--sidebar-text-muted);
  font-size: 14px; padding: 4px; cursor: pointer; transition: color .2s;
}
.sidebar-logout-btn:hover { color: var(--red); }


/* ============================================================
   4. TOPBAR
   ============================================================ */

#topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; flex-shrink: 0;
  position: relative; z-index: 50;
  transition: background var(--transition);
  box-shadow: var(--shadow-sm);
}

/* Mobile menu button — hidden by default, shown in media query */
#mobileMenuBtn,
.topbar-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  color: var(--text-2); font-size: 14px;
  cursor: pointer; transition: all .2s; flex-shrink: 0;
}
#mobileMenuBtn:hover,
.topbar-menu-btn:hover { background: var(--bg-surface2); color: var(--text); }

.topbar-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-3);
  white-space: nowrap; overflow: hidden;
}
.topbar-breadcrumb .crumb-active { color: var(--text); font-weight: 600; }
.topbar-breadcrumb i { font-size: 9px; }

.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; padding: 0 12px;
  height: 34px; flex: 1; max-width: 320px;
  transition: border-color .2s;
}
.topbar-search:focus-within { border-color: var(--red); }
.topbar-search i { color: var(--text-3); font-size: 12px; flex-shrink: 0; }
.topbar-search input {
  border: none; background: transparent;
  font-size: 12px; color: var(--text);
  outline: none; width: 100%; font-family: inherit;
}
.topbar-search input::placeholder { color: var(--text-3); }

.topbar-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.live-badge {
  display: flex; align-items: center; gap: 5px;
  background: var(--green-pale);
  border: 1px solid rgba(45, 122, 71, .2);
  border-radius: 20px; padding: 4px 10px;
  font-size: 10px; font-weight: 600; color: var(--green); white-space: nowrap;
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); animation: pulse 1.5s infinite;
}

.topbar-icon-btn {
  background: transparent; border: 1px solid var(--border);
  border-radius: 8px; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); font-size: 14px;
  cursor: pointer; position: relative; transition: all .2s;
}
.topbar-icon-btn:hover { background: var(--bg-surface2); color: var(--text); }

.notif-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  background: var(--red); color: #fff;
  font-size: 9px; font-weight: 700; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; border: 2px solid var(--topbar-bg);
  line-height: 1; pointer-events: none;
}

.topbar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--red); color: #fff;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: opacity .2s;
}
.topbar-avatar:hover { opacity: .85; }

/* Notification dropdown */
.notif-wrap { position: relative; }

#notifDrop {
  position: absolute;
  top: calc(var(--topbar-h) - 10px); right: 0;
  width: 320px; background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: none; z-index: 300; overflow: hidden;
  animation: notifIn .18s ease;
}
#notifDrop.open { display: block; }

@keyframes notifIn {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.notif-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-surface2);
}
.notif-header-title { font-size: 12px; font-weight: 700; color: var(--text); }

.notif-action-btn {
  background: none; border: none;
  font-size: 10px; font-weight: 600; color: var(--text-3);
  cursor: pointer; padding: 0; font-family: inherit;
  letter-spacing: .02em; transition: color .2s;
}
.notif-action-btn:hover { color: var(--text); }

#notifList { max-height: 300px; overflow-y: auto; }

.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  transition: background .15s; cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover  { background: var(--bg-surface2); }
.notif-item.unread { background: var(--bg-surface); }
.notif-item.read   { background: var(--bg-surface2); }

.notif-icon-wrap {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; flex-shrink: 0; margin-top: 1px;
}
.notif-body { flex: 1; min-width: 0; }
.notif-message {
  font-size: 11px; color: var(--text-2); line-height: 1.45;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.notif-item.unread .notif-message { font-weight: 600; color: var(--text); }
.notif-time { font-size: 10px; color: var(--text-3); margin-top: 3px; }
.notif-unread-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--red); flex-shrink: 0; margin-top: 6px;
}
.notif-empty { padding: 36px 16px; text-align: center; color: var(--text-3); }
.notif-empty i { font-size: 28px; display: block; margin-bottom: 10px; opacity: .35; }
.notif-empty p { font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.notif-empty span { font-size: 11px; opacity: .7; }
.notif-footer {
  padding: 8px 16px; border-top: 1px solid var(--border);
  background: var(--bg-surface2); font-size: 10px; color: var(--text-3);
  display: flex; align-items: center; gap: 5px;
}


/* ============================================================
   5. PAGE FOOTER
   ============================================================ */

#pageFooter {
  height: var(--footer-h); background: var(--footer-bg);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; flex-shrink: 0; position: relative;
  transition: background var(--transition);
  box-shadow: 0 -1px 0 var(--border);
}
#pageFooter::before {
  content: ''; position: absolute;
  bottom: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 30%, var(--gold-light) 50%, var(--gold) 70%, transparent 100%);
  opacity: .25;
}

.footer-left  { display: flex; align-items: center; gap: 16px; }
.footer-right { display: flex; align-items: center; gap: 14px; }
.footer-brand { font-family: 'Playfair Display', serif; font-size: 13px; font-weight: 700; color: var(--text); }
.footer-brand em { color: var(--red); font-style: italic; font-weight: 300; }
.footer-version {
  font-size: 10px; color: var(--text-3);
  background: var(--bg-input); padding: 2px 7px;
  border-radius: 4px; border: 1px solid var(--border);
}
.footer-divider { width: 1px; height: 16px; background: var(--border); }
.footer-status  { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--green); font-weight: 600; }
.footer-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); animation: pulse 2s infinite;
}
.footer-link { font-size: 10px; color: var(--text-3); text-decoration: none; transition: color .2s; }
.footer-link:hover { color: var(--text); }
.footer-copy { font-size: 10px; color: var(--text-3); }


/* ============================================================
   6. SHARED ANIMATIONS
   ============================================================ */

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(.8); }
}
@keyframes bellShake {
  0%, 100% { transform: rotate(0); }
  20%       { transform: rotate(-14deg); }
  40%       { transform: rotate(14deg); }
  60%       { transform: rotate(-8deg); }
  80%       { transform: rotate(8deg); }
}
.bell-shake i { animation: bellShake .55s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.anim-1 { animation: fadeUp .4s ease .05s both; }
.anim-2 { animation: fadeUp .4s ease .10s both; }
.anim-3 { animation: fadeUp .4s ease .15s both; }
.anim-4 { animation: fadeUp .4s ease .20s both; }
.anim-5 { animation: fadeUp .4s ease .25s both; }


/* ============================================================
   7. SCROLLBAR (global)
   ============================================================ */

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }


/* ============================================================
   8. RESPONSIVE
   ============================================================ */

/* ── Mobile overlay (backdrop) ── */
#mobileOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 150;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeInBg .2s ease;
}
#mobileOverlay.show { display: block; }
@keyframes fadeInBg { from { opacity:0; } to { opacity:1; } }

/* ── Mobile (≤768px) ── */
@media (max-width: 768px) {

  /* Sidebar: off-canvas drawer */
  #sidebar {
    position: fixed;
    left: calc(-1 * var(--sidebar-w));
    top: 0;
    height: 100dvh;
    z-index: 200;
    transition: left .28s cubic-bezier(.4,0,.2,1), background var(--transition);
    box-shadow: none;
    overflow: hidden; /* flex column handles internal scroll via .sidebar-nav */
  }
  #sidebar.mobile-open {
    left: 0;
    box-shadow: 4px 0 32px rgba(0,0,0,.22);
  }

  /* Sidebar footer sticky at bottom so it never gets hidden */
  #sidebar .sidebar-footer {
    position: sticky;
    bottom: 0;
    background: var(--sidebar-bg);
    z-index: 1;
  }

  /* Page content bottom padding so content isn't hidden under any sticky bars */
  #pageArea { padding: 16px; padding-bottom: 80px; }

  /* Mobile menu button appears */
  #mobileMenuBtn,
  .topbar-menu-btn { display: flex; }

  /* Desktop-only topbar elements hide */
  .topbar-search     { display: none; }
  .topbar-breadcrumb { display: none; }
  .live-badge        { display: none; }
  #topClock          { display: none; }
  .mgr-badge         { display: none; }

  /* Topbar compact */
  #topbar { padding: 0 12px; gap: 6px; }
  .topbar-right { gap: 4px; }

  /* Notification dropdown full-width on mobile */
  #notifDrop {
    width: 100vw;
    right: -12px;
    border-radius: 0 0 var(--radius) var(--radius);
  }
}

/* ── Very small screens (≤420px) ── */
@media (max-width: 420px) {
  #topbar { padding: 0 8px; gap: 4px; }
  .topbar-avatar { width: 30px; height: 30px; font-size: 11px; }
}

/* ── Tablet (769px – 1024px): auto-collapse sidebar ── */
@media (min-width: 769px) and (max-width: 1024px) {
  #sidebar {
    width: var(--sidebar-w-collapsed);
    min-width: var(--sidebar-w-collapsed);
  }
  #sidebar .nav-lbl,
  #sidebar .nav-section-title,
  #sidebar .sidebar-footer-text,
  #sidebar .badge-dot,
  #sidebar .logo-text { display: none; }
  #sidebar .nav-item   { justify-content: center; padding: 10px 0; }
  #sidebar .nav-item i { margin: 0; }
  #sidebar .sidebar-footer { justify-content: center; padding: 14px 0; }
  #sidebar .sidebar-avatar { margin: 0; }
  .topbar-search { max-width: 200px; }
  #pageArea { padding: 16px; }
}