/* ============================================================
   COCKPIT TOKENS — точная палитра owner.axioma-ai.ru
   Генеративная AI-платформа управления бизнесом: переход с бумажного PT Serif на тёмный navy-платформа.
   Inter (UI) + JetBrains Mono (числа).
   ============================================================ */

:root {
  /* layout */
  --sidebar-width: 260px;
  --sidebar-width-collapsed: 72px;

  /* surfaces (тёмная палитра) */
  --bg-primary: #0a0e1a;
  --bg-surface: #111827;
  --bg-card: #1a2035;
  --bg-card-hover: #222a45;
  --bg-overlay: rgba(10, 14, 26, 0.7);
  --border: #1e2a45;
  --border-strong: #2a3a5a;

  /* алиасы для совместимости со страницами, использующими короткие имена */
  --bg: var(--bg-primary);

  /* accents */
  --accent-blue: #3b82f6;
  --accent-blue-soft: rgba(59, 130, 246, 0.1);
  --accent-blue-deep: #1d4ed8;
  --accent-purple: #8b5cf6;
  --accent-purple-soft: rgba(139, 92, 246, 0.1);
  --accent-green: #10b981;
  --accent-green-soft: rgba(16, 185, 129, 0.1);
  --accent-gold: #f59e0b;
  --accent-gold-soft: rgba(245, 158, 11, 0.1);
  --accent-red: #ef4444;
  --accent-red-soft: rgba(239, 68, 68, 0.1);
  --accent-cyan: #06b6d4;
  --accent-cyan-soft: rgba(6, 182, 212, 0.12);
  --accent-orange: #f97316;

  /* gradient brand */
  --gradient-brand: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-blue-deep) 100%);
  --gradient-mic: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-blue-deep) 100%);

  /* text */
  --text-primary: #e2e8f0;
  --text-body: #cbd5e1;
  --text-muted: #64748b;
  --text-dim: #475569;

  /* алиасы текста для страниц, использующих ступенчатые имена */
  --text: var(--text-primary);
  --text-1: var(--text-primary);
  --text-2: var(--text-body);
  --text-3: var(--text-muted);

  /* shadows / glow */
  --shadow-card: 0 6px 18px rgba(0, 0, 0, 0.30);
  --shadow-hover: 0 12px 28px rgba(0, 0, 0, 0.40);
  --glow-blue: 0 0 24px rgba(59, 130, 246, 0.18);
  --glow-purple: 0 0 24px rgba(139, 92, 246, 0.18);
  --glow-gold: 0 0 24px rgba(245, 158, 11, 0.18);

  /* radii */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-2xl: 24px;
  --r-full: 9999px;

  /* fonts */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Menlo', Consolas, monospace;

  /* TYPE SCALE — единая шкала, заменяет hardcoded font-size:Xpx */
  --text-h1:   22px;   /* page hero */
  --text-h2:   18px;   /* section hero */
  --text-h3:   15px;   /* card title */
  --text-h4:   13px;   /* sub-title */
  --text-body: 14px;   /* default body */
  --text-sm:   12px;   /* secondary / labels */
  --text-xs:   11px;   /* micro / captions */
  --text-kpi:  22px;   /* numeric KPI big */
  --text-kpi-lg: 32px; /* numeric KPI hero */
  --lh-tight: 1.2;
  --lh-base:  1.55;
  --lh-loose: 1.65;
  --tracking-tight: -0.01em;
  --tracking-base:   0;
  --tracking-wide:   0.05em;
  --tracking-wider:  0.08em;

  /* SPACING SCALE — 4px base, заменяет hardcoded margin/padding:Xpx */
  --sp-0:  0;
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-7:  28px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-20: 80px;

  /* AI-Insight: общий компонент использует префикс --ax-*. Подвязываем его
     к radar-токенам, чтобы цвет/фон/бордер автоматически следовали за темой. */
  --ax-surface:      var(--bg-card);
  --ax-surface-2:    var(--bg-surface);
  --ax-text:         var(--text-primary);
  --ax-text-muted:   var(--text-2);
  --ax-border:       var(--border);
  --ax-gold:         var(--accent-gold);
  --ax-blue:         var(--accent-blue);
  --ax-good:         var(--accent-green);
}

/* LIGHT THEME — переключается через [data-theme="light"] на <html>
   Профессиональная палитра дашборда холдинга: off-white фон, slate-текст,
   те же бренд-акценты (на светлом фоне они читаются так же). */
html[data-theme="light"] {
  /* surfaces */
  --bg-primary:    #f7f8fb;
  --bg-surface:    #ffffff;
  --bg-card:       #ffffff;
  --bg-card-hover: #f0f3f8;
  --bg-overlay:    rgba(247, 248, 251, 0.85);
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;

  /* алиас короткого имени */
  --bg: var(--bg-primary);

  /* T0.2: акценты для light-темы — dark hex чтобы текст имел контраст ≥ 4.5:1.
     Старые #10B981/#F59E0B/#EF4444 на white давали 2.5/2.2/3.8 — нечитаемо. */
  --accent-blue:        #1D4ED8;  /* 8.6:1 vs white */
  --accent-blue-soft:   rgba(29, 78, 216, 0.12);
  --accent-purple:      #6D28D9;
  --accent-purple-soft: rgba(109, 40, 217, 0.12);
  --accent-green:       #15803D;  /* 5.21:1 vs white */
  --accent-green-soft:  rgba(21, 128, 61, 0.14);
  --accent-gold:        #B45309;  /* 4.74:1 vs white */
  --accent-gold-soft:   rgba(180, 83, 9, 0.18);
  --accent-red:         #B91C1C;  /* 5.93:1 vs white */
  --accent-red-soft:    rgba(185, 28, 28, 0.14);
  --accent-cyan:        #06b6d4;
  --accent-cyan-soft:   rgba(6, 182, 212, 0.14);
  --accent-orange:      #f97316;

  /* gradient brand — повторяем явно (на случай отдельных правил, не наследующих переменные) */
  --gradient-brand: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);

  /* text */
  --text-primary: #0f172a; /* slate-900 */
  --text-body:    #475569; /* slate-600 */
  --text-muted:   #64748b; /* slate-500 */
  --text-dim:     #94a3b8; /* slate-400 */

  /* алиасы ступенчатого текста */
  --text:   #0f172a;
  --text-1: #1e293b;
  --text-2: #475569;
  --text-3: #64748b;

  /* shadows / glow */
  --shadow-card:  0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 8px 24px rgba(15, 23, 42, 0.10);
  --glow-blue:    0 4px 14px rgba(59, 130, 246, 0.18);
  --glow-purple:  0 4px 14px rgba(139, 92, 246, 0.18);
  --glow-gold:    0 4px 14px rgba(245, 158, 11, 0.20);
}

html[data-theme="light"] body {
  background: var(--bg-primary);
  color: var(--text-primary);
}

html[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--border-strong); }

/* ============================================================
   BASE RESET
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  overflow-x: hidden;
}

/* ============================================================
   SCROLLBARS
   ============================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============================================================
   GRADIENT TEXT (brand)
   ============================================================ */
.gradient-text {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================
   UTILITY: монохромные числа (KPI / таблицы / тикеры)
   ============================================================ */
.font-mono { font-family: var(--font-mono); font-feature-settings: 'tnum' 1, 'lnum' 1; }
.tabular { font-variant-numeric: tabular-nums; }

/* ============================================================
   STATUS COLORS
   ============================================================ */
.text-blue   { color: var(--accent-blue); }
.text-purple { color: var(--accent-purple); }
.text-green  { color: var(--accent-green); }
.text-gold   { color: var(--accent-gold); }
.text-red    { color: var(--accent-red); }
.text-muted  { color: var(--text-muted); }
.text-dim    { color: var(--text-dim); }

/* ============================================================
   SKELETON LOADER (универсальная плашка для загрузок)
   ============================================================ */
@keyframes skeletonShimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  display: inline-block;
  background: linear-gradient(
    90deg,
    rgba(148, 163, 184, 0.10) 0%,
    rgba(148, 163, 184, 0.22) 50%,
    rgba(148, 163, 184, 0.10) 100%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.6s ease-in-out infinite;
  border-radius: var(--r-sm, 6px);
  color: transparent !important;
  user-select: none;
  pointer-events: none;
  min-height: 1em;
  vertical-align: middle;
}
html[data-theme="light"] .skeleton {
  background: linear-gradient(
    90deg,
    rgba(15, 23, 42, 0.04) 0%,
    rgba(15, 23, 42, 0.10) 50%,
    rgba(15, 23, 42, 0.04) 100%
  );
  background-size: 200% 100%;
}
.skeleton-line { display: block; height: 1em; margin: 6px 0; border-radius: 4px; }
.skeleton-line.w-25 { width: 25%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-full { width: 100%; }
.skeleton-card {
  display: block; width: 100%;
  border-radius: var(--r-md, 8px);
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* ============================================================
   EMPTY STATE — единый паттерн "нет данных / создайте первое"
   Использование:
     <div class="empty-state">
       <div class="empty-state-icon">📋</div>     (или <svg>)
       <h3 class="empty-state-title">Триггеров пока нет</h3>
       <p class="empty-state-desc">Создайте первое правило за 30 секунд.</p>
       <a class="empty-state-cta" href="...">+ Новый триггер</a>
     </div>
   ============================================================ */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-surface);
}
.empty-state-icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-full);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 22px;
}
.empty-state-icon svg { width: 22px; height: 22px; }
.empty-state-title {
  margin: 0;
  font-size: var(--text-h3);
  font-weight: 600;
  color: var(--text-primary);
}
.empty-state-desc {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 42ch;
  line-height: var(--lh-base);
}
.empty-state-cta {
  margin-top: var(--sp-2);
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-4);
  background: var(--accent-blue);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--r-md);
  text-decoration: none;
  transition: background-color .15s, transform .15s;
}
.empty-state-cta:hover { background: var(--accent-blue); filter: brightness(1.08); transform: translateY(-1px); }
.empty-state-presets {
  display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: center;
  margin-top: var(--sp-2);
}
.empty-state-presets a {
  font-size: var(--text-xs);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text-muted);
  text-decoration: none;
}
.empty-state-presets a:hover { color: var(--accent-blue); border-color: var(--accent-blue); }

/* ============================================================
   PAGE HEADER — единая шапка страницы (title + опционально KPI inline)
   Использование:
     <div class="page-header">
       <div class="page-header-titles">
         <h1 class="page-header-title">Сегодня · <span>16 мая</span></h1>
         <p class="page-header-sub">Утренняя сводка · фокус дня</p>
       </div>
       <div class="page-header-kpis">
         <span class="page-header-kpi"><b>5</b> сигналов</span>
         <span class="page-header-kpi"><b>12</b> задач</span>
       </div>
     </div>
   ============================================================ */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: var(--sp-4); flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.page-header-title {
  margin: 0 0 var(--sp-1);
  font-size: var(--text-h1);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}
.page-header-title span { color: var(--text-muted); font-weight: 500; }
.page-header-sub {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}
.page-header-kpis {
  display: flex; gap: var(--sp-5); flex-wrap: wrap;
}
.page-header-kpi {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.page-header-kpi b {
  display: inline-block; min-width: 1.5ch;
  margin-right: var(--sp-1);
  font-family: var(--font-mono);
  font-size: var(--text-h2);
  font-weight: 700;
  color: var(--text-primary);
  text-transform: none;
}

/* ============================================================
   GLOBAL A11Y — focus-visible + skip-link
   ============================================================ */
*:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.skip-link {
  position: absolute;
  left: 8px; top: -100px;
  z-index: 9999;
  padding: var(--sp-2) var(--sp-4);
  background: var(--accent-blue);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--r-md);
}
.skip-link:focus { top: 8px; }

/* ============================================================
   PULSE DOT (для алертов и live-индикаторов)
   ============================================================ */
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(1.6); }
}
.pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulseDot 2s ease-in-out infinite;
}
.pulse-dot.blue { background: var(--accent-blue); }
.pulse-dot.red  { background: var(--accent-red); }
.pulse-dot.gold { background: var(--accent-gold); }

/* ============================================================
   TICKER (бегущая лента алертов)
   ============================================================ */
@keyframes ticker {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.ticker-anim { animation: ticker 40s linear infinite; }
.ticker-anim:hover { animation-play-state: paused; }

/* ============================================================
   TV / PRESENTATION MODE (font scaling для совещаний и больших экранов)
   Применяется через data-font-scale="1.25|1.5|1.75|2" на <html>.
   TV-режим (data-tv="1") дополнительно: скрывает sidebar/FAB, расширяет container.
   ============================================================ */
html[data-font-scale="1.25"] body { zoom: 1.25; }
html[data-font-scale="1.5"]  body { zoom: 1.5; }
html[data-font-scale="1.75"] body { zoom: 1.75; }
html[data-font-scale="2"]    body { zoom: 2; }

/* TV-режим: чистый экран для проектора/большого монитора */
html[data-tv="1"] .cockpit-sidebar,
html[data-tv="1"] #cockpit-sidebar,
html[data-tv="1"] #ask-fab,
html[data-tv="1"] .ask-fab,
html[data-tv="1"] .cmdk-trigger,
html[data-tv="1"] .floating-help,
html[data-tv="1"] .pin-btn { display: none !important; }

html[data-tv="1"] main,
html[data-tv="1"] .container,
html[data-tv="1"] .cockpit-main {
  margin-left: 0 !important;
  max-width: 100% !important;
  padding-left: 20px !important;
  padding-right: 20px !important;
}

html[data-tv="1"] .hero-banner,
html[data-tv="1"] .ai-narrative { padding: 28px 32px; }
html[data-tv="1"] body { font-size: 16px; }

/* Маленькая плашка-индикатор в углу когда TV-режим активен */
html[data-tv="1"]::after {
  content: "TV";
  position: fixed; top: 8px; right: 8px;
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--accent-red);
  padding: 3px 8px; border-radius: 4px;
  letter-spacing: 0.08em;
  pointer-events: none;
  z-index: 9998;
}
