/* ============================================================
   main.css — Dark Core Control Center
   Design tokens, reset, typography, layout
   ============================================================ */

/* ── Custom Properties ── */
:root {
  /* Background */
  --bg:            #080808;
  --surface:       #111111;
  --surface-alt:   #181818;
  --surface-hover: #1e1e1e;

  /* Borders */
  --border:        #2a2a2a;
  --border-hover:  #3d3d3d;

  /* Text */
  --text:          #e2e8f0; /* Soft off-white (comfortable, no glare) */
  --text-muted:    #71717a; /* Distinct secondary text (Zinc-500) */
  --text-dim:      #404047;

  /* Radius — one value for the entire project */
  --radius:        6px;

  /* Role colours */
  --role-106: #f59e0b; /* Старший администратор */
  --role-105: #fb923c; /* Администратор         */
  --role-104: #60a5fa; /* Младший администратор */
  --role-103: #c084fc; /* Старший модератор     */
  --role-102: #a78bfa; /* Модератор             */
  --role-101: #818cf8; /* Младший модератор     */
  --role-100: #34d399; /* Хелпер                */
  --role-099: #94a3b8; /* Строитель             */

  /* Status colours */
  --red:          #ef4444;
  --red-soft:     #f87171;
  --green:        #10b981;
  --yellow:       #f59e0b;

  /* Admin accent tokens */
  --admin-accent:        #fca5a5; /* Muted pastel rose */
  --admin-bg-active:     linear-gradient(90deg, rgba(239, 68, 68, 0.05) 0%, rgba(239, 68, 68, 0.01) 100%);
  --admin-border-active: rgba(239, 68, 68, 0.12);
  --admin-glow:          rgba(239, 68, 68, 0.15);

  /* Nav active item tokens */
  --nav-active-text:     #ffffff;
  --nav-active-bg:       linear-gradient(90deg, rgba(96, 165, 250, 0.12) 0%, rgba(96, 165, 250, 0.03) 100%);
  --nav-active-border:   rgba(96, 165, 250, 0.25);
  --nav-active-accent:   #60a5fa;

  /* Layout */
  --sidebar-w:    240px;
  --topbar-h:     52px;

  /* Transition */
  --t: 150ms ease;
}

/* ── Light Theme Overrides ── */
[data-theme="light"] {
  --bg:            #f4f4f6;
  --surface:       #ffffff;
  --surface-alt:   #f0f0f3;
  --surface-hover: #e5e5eb;

  --border:        #e2e2e8;
  --border-hover:  #c8c8d2;

  --text:          #111827;
  --text-muted:    #6b7280;
  --text-dim:      #9ca3af;

  --nav-active-text:     #1d4ed8; /* Dark readable blue for light theme */
  --nav-active-bg:       linear-gradient(90deg, rgba(37, 99, 235, 0.1) 0%, rgba(37, 99, 235, 0.02) 100%);
  --nav-active-border:   rgba(37, 99, 235, 0.3);
  --nav-active-accent:   #2563eb;

  --admin-accent:        #dc2626; /* Darker legible red for light theme */
  --admin-bg-active:     linear-gradient(90deg, rgba(220, 38, 38, 0.08) 0%, rgba(220, 38, 38, 0.01) 100%);
  --admin-border-active: rgba(220, 38, 38, 0.25);
  --admin-glow:          rgba(220, 38, 38, 0.2);

  --role-106: #d97706;
  --role-105: #ea580c;
  --role-104: #2563eb;
  --role-103: #9333ea;
  --role-102: #7c3aed;
  --role-101: #4f46e5;
  --role-100: #059669;
  --role-099: #475569;
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

/* ── Universal Sleek Scrollbars (Standard & WebKit) ── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  line-height: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

img { display: block; max-width: 100%; }

ul, ol { list-style: none; }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: width 350ms cubic-bezier(0.16, 1, 0.3, 1), transform 350ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  will-change: width;
}

/* Smooth internal element transitions */
.sidebar .logo-text,
.sidebar .nav-label {
  opacity: 1;
  transform: translateX(0);
  transition: opacity 220ms cubic-bezier(0.16, 1, 0.3, 1), transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.sidebar .nav-icon {
  transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1), color var(--t);
}

/* ── Collapsed Sidebar Desktop Mode ── */
body.sidebar-collapsed .sidebar {
  width: 64px;
  overflow: visible !important;
}

body.sidebar-collapsed .sidebar .sidebar-nav {
  overflow: visible !important;
}

body.sidebar-collapsed .sidebar .logo-text,
body.sidebar-collapsed .sidebar .nav-label {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateX(-10px) scale(0.95) !important;
  position: absolute !important;
  visibility: hidden !important;
  transition: opacity 140ms ease, transform 140ms ease !important;
}

body.sidebar-collapsed .sidebar-header {
  padding: 16px 12px;
  justify-content: center !important;
  transition: padding 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

body.sidebar-collapsed .sidebar .logo {
  justify-content: center;
}

body.sidebar-collapsed .sidebar .nav-item {
  justify-content: center;
  padding: 10px;
  transition: padding 350ms cubic-bezier(0.16, 1, 0.3, 1), background var(--t);
}

body.sidebar-collapsed .sidebar .nav-item:hover .nav-icon {
  transform: scale(1.2);
}

body.sidebar-collapsed .sidebar-footer {
  padding: 12px 6px;
  transition: padding 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

body.sidebar-collapsed .layout-main {
  margin-left: 64px;
  transition: margin-left 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Contextual Tooltips when sidebar is collapsed */
body.sidebar-collapsed .sidebar .nav-item {
  position: relative;
}

body.sidebar-collapsed .sidebar .nav-item::after {
  content: attr(aria-label);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface);
  border: 1px solid var(--border-hover);
  color: var(--text);
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 150ms ease, transform 150ms ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  z-index: 300;
}

body.sidebar-collapsed .sidebar .nav-item:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(2px);
}

.sidebar-header {
  padding: 18px 16px;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  flex-shrink: 0;
  border-radius: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1;
}

.logo-sub {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1;
}

/* ── Nav ── */
.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color var(--t), background var(--t), border-color var(--t), box-shadow var(--t);
  white-space: nowrap;
  position: relative;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-alt);
  border-color: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: var(--nav-active-text);
  background: var(--nav-active-bg);
  border-color: var(--nav-active-border);
  font-weight: 600;
}

.nav-item.active .nav-icon {
  color: var(--nav-active-accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--nav-active-accent);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--nav-active-accent);
}

.nav-item-admin.active {
  color: var(--admin-accent) !important;
  background: var(--admin-bg-active);
  border-color: var(--admin-border-active);
}

.nav-item-admin.active::before {
  background: var(--red);
  box-shadow: 0 0 6px var(--admin-glow);
}

.nav-icon {
  width: 16px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--t);
}

.nav-item:hover .nav-icon {
  color: var(--text);
}

.nav-item.active .nav-icon {
  color: #60a5fa;
}

/* ── Sidebar footer ── */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 2px solid var(--border);
  flex-shrink: 0;
}

.sidebar-footer-text {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* ── Mobile overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 190;
}

.sidebar-overlay.open {
  display: block;
}

/* ── Main layout ── */
.layout-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.hamburger {
  display: none;
  padding: 6px 8px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 15px;
  transition: color var(--t), background var(--t);
}

.hamburger:hover {
  color: var(--text);
  background: var(--surface-alt);
}

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

.topbar-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  transition: color var(--t);
}

.topbar-link:hover {
  color: var(--text);
}

/* ── Content ── */
.content {
  flex: 1;
  padding: 28px 28px 40px;
  min-width: 0;
}

.content:has(.dashboard-cockpit),
.content:has(.banlist-cockpit),
.content:has(.compare-cockpit),
.content:has(.lab-cockpit) {
  padding: 14px 24px 14px;
  height: calc(100vh - var(--topbar-h));
  max-height: calc(100vh - var(--topbar-h));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

@media (min-width: 1025px) {
  .content:has(.dashboard-cockpit),
  .content:has(.banlist-cockpit),
  .content:has(.compare-cockpit),
  .content:has(.lab-cockpit) {
    overflow: hidden;
  }
}

@media (max-width: 1024px) {
  .content:has(.dashboard-cockpit),
  .content:has(.banlist-cockpit),
  .content:has(.compare-cockpit),
  .content:has(.lab-cockpit) {
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 16px 20px 24px;
  }
}

/* ── Page structure ── */
.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
  font-weight: 400;
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  min-width: 220px;
  max-width: 340px;
  pointer-events: all;
  animation: toastIn 150ms ease forwards;
}

.toast-error   { border-color: var(--red); }
.toast-success { border-color: var(--green); }

.toast-icon { font-size: 13px; flex-shrink: 0; }
.toast-error   .toast-icon { color: var(--red);   }
.toast-success .toast-icon { color: var(--green); }

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .layout-main {
    margin-left: 0;
  }
  .hamburger {
    display: flex;
    align-items: center;
  }
  .topbar {
    padding: 0 12px;
  }
  .topbar-right {
    gap: 6px;
  }
  .topbar-link span,
  .topbar-link {
    font-size: 11px;
  }
  .content {
    padding: 16px 16px 32px;
  }
}

@media (max-width: 580px) {
  #btnGlobalSearch span,
  #btnGlobalSearch kbd,
  #cubix-site-link {
    display: none !important;
  }
  #btnGlobalSearch {
    padding: 6px 8px !important;
  }
}

@media (max-width: 480px) {
  .topbar-right {
    gap: 5px;
  }
  #liveIndicator span:last-child {
    display: none;
  }
  #liveIndicator {
    padding: 4px 6px !important;
  }
  .content {
    padding: 12px 12px 28px;
  }
  .page-title {
    font-size: 17px;
  }
}
