/* IT Quick · Админ-консоль — дизайн-система «Community Hub · Haze».
   Тёмная тема основная, светлая идёт парой и включается через
   <html data-bs-theme="light">. Поверх Bootstrap 5.3: переопределяем его
   CSS-переменные, поэтому таблицы, формы, модалки и пагинация следуют за
   токенами без правки разметки. */

/* ── Токены: Haze Dark v3 ─────────────────────────────────────────── */
:root,
[data-bs-theme="dark"] {
  --haze-bg: #1a1b1e;
  --haze-surface: #26272a;
  --haze-surface-low: #212225;
  --haze-surface-high: #2f3033;
  --haze-lowest: #151619;

  --haze-text: #ffffff;
  --haze-text-2: #a9abb0;
  --haze-text-3: #7e8085;

  --brand: #2e7d32;            /* заливки: кнопки, выбранный чип */
  --brand-rgb: 46, 125, 50;
  --brand-text: #5cc264;       /* текст и иконки: #2E7D32 на графите не проходит по контрасту */
  --brand-hover: #3a9440;

  --haze-secondary: #38bdf8;
  --haze-danger: #f87171;
  --haze-success: #10b981;
  --haze-warning: #fbbf24;

  /* Обводки по умолчанию нет; когда нужна — на грани различимости. */
  --haze-outline: rgba(255, 255, 255, .06);
  --haze-shadow: none;

  /* Пятна атмосферной подложки. */
  --haze-warm: rgba(255, 255, 255, .035);
  --haze-tint: rgba(46, 125, 50, .07);
  --haze-deep: rgba(0, 0, 0, .35);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --sidebar-w: 248px;
  --topbar-h: 56px;
}

/* ── Токены: Haze Light v2 ────────────────────────────────────────── */
[data-bs-theme="light"] {
  --haze-bg: #f2f3f5;
  --haze-surface: #ffffff;
  --haze-surface-low: #f7f8fa;
  --haze-surface-high: #edeef2;
  --haze-lowest: #e9eaee;

  --haze-text: #17181b;
  --haze-text-2: #6b6f7b;
  --haze-text-3: #9598a3;

  --brand: #2e7d32;
  --brand-rgb: 46, 125, 50;
  --brand-text: #2e7d32;
  --brand-hover: #25692a;

  --haze-secondary: #0284c7;
  --haze-danger: #d92244;
  --haze-success: #15803d;
  --haze-warning: #b45309;

  --haze-outline: #edeef2;
  --haze-shadow: 0 1px 2px rgba(23, 24, 27, .06);

  --haze-warm: rgba(255, 255, 255, .7);
  --haze-tint: rgba(46, 125, 50, .05);
  --haze-deep: rgba(23, 24, 27, .04);
}

/* ── Мост к переменным Bootstrap 5.3 ──────────────────────────────── */
:root,
[data-bs-theme="dark"],
[data-bs-theme="light"] {
  --bs-body-bg: var(--haze-bg);
  --bs-body-color: var(--haze-text);
  --bs-emphasis-color: var(--haze-text);
  --bs-secondary-color: var(--haze-text-2);
  --bs-tertiary-color: var(--haze-text-3);
  --bs-secondary-bg: var(--haze-surface-high);
  --bs-tertiary-bg: var(--haze-surface-low);
  --bs-border-color: var(--haze-outline);
  --bs-border-color-translucent: var(--haze-outline);

  --bs-primary: var(--brand);
  --bs-primary-rgb: var(--brand-rgb);
  --bs-link-color: var(--brand-text);
  --bs-link-hover-color: var(--brand-hover);
  --bs-link-color-rgb: var(--brand-rgb);

  --bs-danger: var(--haze-danger);
  --bs-success: var(--haze-success);
  --bs-warning: var(--haze-warning);
  --bs-info: var(--haze-secondary);

  --bs-border-radius: var(--radius-md);
  --bs-border-radius-sm: var(--radius-sm);
  --bs-border-radius-lg: var(--radius-lg);
  --bs-border-radius-xl: var(--radius-lg);

  --bs-card-bg: var(--haze-surface);
  --bs-card-border-color: transparent;
  --bs-card-cap-bg: var(--haze-surface);

  --bs-table-bg: transparent;
  --bs-table-color: var(--haze-text);
  --bs-table-border-color: var(--haze-outline);
  --bs-table-striped-bg: var(--haze-surface-low);
  --bs-table-hover-bg: var(--haze-surface-high);

  --bs-modal-bg: var(--haze-surface);
  --bs-modal-border-color: transparent;
  --bs-dropdown-bg: var(--haze-surface);
  --bs-dropdown-border-color: transparent;
  --bs-dropdown-link-hover-bg: var(--haze-surface-high);
}

html, body { height: 100%; }

/* Главное правило темы: фон никогда не плоский. Три очень широких пятна
   без резких границ — тёплое сверху слева, брендовое сверху справа,
   затемнение снизу. Атмосфера живёт на всём экране, а не только под шапкой. */
body {
  background-color: var(--haze-bg);
  background-image:
    radial-gradient(120% 90% at 8% -10%, var(--haze-warm) 0%, transparent 60%),
    radial-gradient(110% 80% at 100% -5%, var(--haze-tint) 0%, transparent 62%),
    radial-gradient(130% 70% at 50% 115%, var(--haze-deep) 0%, transparent 65%);
  background-attachment: fixed;
  color: var(--haze-text);
  font-size: 14px;
  margin: 0;
}

/* ---- Сетка ---- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

/* ---- Сайдбар: отделяется тоном, а не линией ---- */
.sidebar {
  grid-row: 1 / 3;
  background: var(--haze-surface-low);
  color: var(--haze-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: none;
}
.sidebar .brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  color: var(--haze-text);
  font-weight: 700;
  letter-spacing: .2px;
  border-bottom: none;
  flex: 0 0 auto;
}
.sidebar .brand .logo {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .5px;
}
.nav-scroll { overflow-y: auto; padding: 8px 10px 24px; flex: 1 1 auto; }
.nav-group {
  padding: 14px 8px 6px;
  font-size: 11px;
  letter-spacing: .4px;
  color: var(--haze-text-3);
}
/* Каждый пункт — своя скруглённая плашка, без линии-рельса слева. */
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  margin-bottom: 2px;
  color: var(--haze-text-2);
  text-decoration: none; cursor: pointer;
  border-left: none;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.nav-item:hover { background: var(--haze-surface-high); color: var(--haze-text); }
.nav-item.active { background: var(--haze-surface-high); color: var(--brand-text); font-weight: 600; }
.nav-item .ni { width: 18px; text-align: center; font-size: 15px; flex: 0 0 auto; }
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; }

/* ---- Топбар: лежит на атмосферном фоне, без заливки и без линии ---- */
.topbar {
  grid-column: 2;
  background: transparent;
  border-bottom: none;
  display: flex; align-items: center;
  padding: 0 22px; gap: 16px;
}
.topbar .crumbs { color: var(--haze-text-2); }
.topbar .crumbs b { color: var(--haze-text); font-weight: 600; }
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 9px; }
.userchip .av {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 12px;
}
.userchip .uinfo { line-height: 1.15; }
.userchip .uname { font-weight: 600; font-size: 13px; }
.userchip .urole { font-size: 11px; color: var(--haze-text-3); }
.logout-btn {
  border: none; background: transparent; color: var(--haze-text-2);
  font-size: 18px; cursor: pointer; padding: 4px 6px; border-radius: var(--radius-sm);
}
.logout-btn:hover { background: var(--haze-surface-high); color: var(--brand-text); }

/* ---- Контент ---- */
.app-content { grid-column: 2; padding: 22px 24px; overflow: auto; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-head .sub { color: var(--haze-text-2); font-size: 13px; }

.muted { color: var(--haze-text-2); }
.route-loading { padding: 40px; color: var(--haze-text-2); }
.placeholder-page { padding: 48px 8px; }
.placeholder-page h1 { font-size: 20px; font-weight: 700; margin: 0 0 8px; }

/* Карточки: тон вместо обводки, без тени. */
.card {
  border: none;
  background: var(--haze-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--haze-shadow);
}

/* ---- Акцентные элементы ---- */
.btn-brand {
  background: var(--brand); border-color: var(--brand); color: #fff;
  border-radius: var(--radius-md); min-height: 40px; font-weight: 600;
}
.btn-brand:hover, .btn-brand:focus { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.pagination .page-item.active .page-link { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-link { color: var(--brand-text); background: transparent; border-color: var(--haze-outline); }
a { color: var(--brand-text); text-decoration: none; }
a:hover { color: var(--brand-hover); text-decoration: underline; }

/* Поле ввода: заливка без обводки, тонкая обводка акцентом в фокусе. */
.form-control, .form-select {
  background: var(--haze-surface-high);
  border: 1px solid transparent;
  color: var(--haze-text);
  border-radius: var(--radius-md);
  min-height: 40px;
}
.form-control::placeholder { color: var(--haze-text-3); }
.form-control:focus, .form-select:focus {
  background: var(--haze-surface-high);
  color: var(--haze-text);
  border-color: var(--brand-text);
  box-shadow: none;
}

/* Таблицы: разделяет тон, hairline-разделителей нет. */
.table { --bs-table-bg: transparent; color: var(--haze-text); }
.table > :not(caption) > * > * { border-bottom-width: 0; background: transparent; }
.table thead th {
  color: var(--haze-text-2);
  font-weight: 600; font-size: 12px; letter-spacing: .2px;
  background: transparent;
}
.table tbody tr { background: var(--haze-surface); }
.table tbody tr:hover > * { background: var(--haze-surface-high); }
.table > :not(caption) > * > * { padding: .7rem .75rem; }

/* Чип статуса: заливка 12% от статусного цвета, текст статусным цветом, без обводки. */
.badge { border-radius: 999px; font-weight: 600; padding: .35em .7em; }
.badge.bg-success { background: rgba(16, 185, 129, .12) !important; color: var(--haze-success); }
.badge.bg-danger  { background: rgba(248, 113, 113, .12) !important; color: var(--haze-danger); }
.badge.bg-warning { background: rgba(251, 191, 36, .12) !important; color: var(--haze-warning); }
.badge.bg-secondary { background: var(--haze-surface-high) !important; color: var(--haze-text-2); }

/* ---- Логин ---- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: transparent; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--haze-surface);
  border: none;
  border-radius: var(--radius-lg);
  padding: 28px 26px;
  box-shadow: var(--haze-shadow);
}
.login-card .brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; }
.login-card .brand-row .logo {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: .5px;
}

/* ---- Аватары: монограмма на нейтральной подложке ---- */
.res-name { display: flex; align-items: center; gap: 10px; }
.res-av { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.res-av-ph {
  display: inline-grid; place-items: center;
  background: var(--haze-surface-high); color: var(--haze-text-2);
  font-weight: 600; font-size: 12px;
}
.res-av-lg { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.res-av-lg.res-av-ph { font-size: 22px; }

/* ---- Дашборд ---- */
.dash-card { border: none; background: var(--haze-surface); border-radius: var(--radius-md); }
.dash-card:hover { background: var(--haze-surface-high); box-shadow: none; }
.dash-ic {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  display: grid; place-items: center; font-size: 20px;
  flex: 0 0 auto;
  background: rgba(var(--brand-rgb), .14); color: var(--brand-text);
}
.dash-ic.ac-indigo { background: rgba(var(--brand-rgb), .14); color: var(--brand-text); }
.dash-ic.ac-blue { background: rgba(56, 189, 248, .14); color: var(--haze-secondary); }
.dash-ic.ac-amber { background: rgba(251, 191, 36, .14); color: var(--haze-warning); }
.dash-ic.ac-red { background: rgba(248, 113, 113, .14); color: var(--haze-danger); }
.dash-val { font-size: 24px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dash-title { font-size: 13px; color: var(--haze-text-2); }
.dash-activity li { padding: 6px 0; border-bottom: none; }
.dash-activity li:last-child { border-bottom: 0; }

/* Все числа — табличными цифрами. */
.table td, .dash-val, .pagination { font-variant-numeric: tabular-nums; }

/* ---- Утилиты (вместо inline style=, CSP style-src 'self') ---- */
.progress-tall { height: 1.4rem; }
.truncate-420 { max-width: 420px; }
.fxw-grow { flex: 1 1 200px; }
.fxw-200 { flex: 0 0 200px; }
.fxw-140 { flex: 0 0 140px; }

/* ============================================================
   Мобильная адаптация (≤768px). Десктоп (≥769px) остаётся без изменений —
   всё скоуплено в media-query либо за аддитивные классы (.sidebar-open, .menu-toggle,
   .sidebar-backdrop, .filter-row).
   ============================================================ */

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--haze-text-2);
  font-size: 22px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.menu-toggle:hover, .menu-toggle:focus { background: var(--haze-surface-high); color: var(--brand-text); }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 1044;                 /* под drawer (1045) и под Bootstrap-модалкой (1050+) */
}

@media (max-width: 768px) {
  /* — Сетка в одну колонку: контент во всю ширину, сайдбар выходит из потока — */
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
  }
  .topbar { grid-column: 1; padding: 0 12px; gap: 10px; }
  .app-content { grid-column: 1; padding: 16px 14px; }

  /* — Сайдбар → off-canvas drawer поверх контента — */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    grid-row: auto;
    width: min(84vw, var(--sidebar-w));
    z-index: 1045;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  }
  .layout.sidebar-open .sidebar { transform: translateX(0); }
  .layout.sidebar-open .sidebar-backdrop { display: block; }

  /* — Топбар компактный: гамбургер виден, крошки усечены многоточием — */
  .menu-toggle { display: inline-flex; }
  .topbar .spacer { display: none; }
  .topbar .crumbs {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
  }

  /* — Userchip ужимается: роль скрыта, имя усечено, аватар остаётся — */
  .userchip { gap: 0; }
  .userchip .urole { display: none; }
  .userchip .uname { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* — Тач-таргеты навигации ≈44px — */
  .nav-item { padding-top: 11px; padding-bottom: 11px; }
  .nav-group { padding-top: 16px; }

  /* — Таблицы: горизонтальный скролл с инерцией, плотнее ячейки, читаемые заголовки — */
  .table-responsive { -webkit-overflow-scrolling: touch; }
  .table > :not(caption) > * > * { padding: .5rem .5rem; }
  .table thead th { white-space: nowrap; }

  /* — Панель фильтров: поля в столбик, во всю ширину (перебивает inline flex-basis) — */
  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-row > * { width: 100%; flex: 1 1 auto !important; }

  /* — Кнопки и пагинация: комфортный тач-таргет — */
  .btn { min-height: 40px; }
  .pagination .page-link {
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* — Модалки почти во всю ширину, без горизонтального переполнения — */
  .modal-dialog { margin: .5rem; }

  /* — Защита от переполнения фиксированных утилит на узком экране — */
  .page-head { flex-wrap: wrap; }
  .truncate-420 { max-width: 100%; }
  .fxw-200, .fxw-140 { flex: 1 1 auto; }
}
