/* ── Оболочка админок завода — общая дизайн-система «Завод 2.0» ──
   Токены, логин, сайдбар, топбар, модалки, чат-кружок, мобильный режим.
   Живёт в platform/shared-ui/, копируется в сборку каждой админки:
   все три админки завода должны выглядеть одной системой.
   Вьюхи направления — в его собственном admin.css. */

:root {
  --bg: #f1efea; --surface: #fff; --hover: #ece9e3;
  --text: #1a1a1a; --muted: #6b6a65; --dim: #9a9892; --border: #e0ddd6;
  --lime: #d6f24e; --danger: #c0392b; --success: #22c55e;
  --tone-blue: #bfd4e8; --tone-yellow: #f5d92a; --tone-sage: #c8e6b0;
  --tone-lavender: #d9c8ea; --tone-peach: #f0d4bd;
  --sidebar-w: 230px; --sidebar-w-collapsed: 60px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: 'Inter Tight', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
em.serif { font-family: 'Instrument Serif', serif; font-style: italic; font-weight: 400; }
a { color: inherit; }
svg { display: inline-block; vertical-align: middle; }

/* login */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 40px; width: 340px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.login-card .avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--lime); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; font-size: 26px; }
.login-card h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.login-card input { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 999px; font: inherit; margin: 16px 0 10px; text-align: center; }
.login-card button { width: 100%; padding: 11px; border: none; border-radius: 999px; background: #1a1a1a; color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.login-card .err { color: var(--danger); font-size: 12px; min-height: 16px; margin-top: 8px; }

/* shell */
#app { display: none; min-height: 100vh; }
#app.on { display: grid; grid-template-columns: var(--sidebar-w) 1fr; transition: grid-template-columns .22s ease; }
#app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
/* min-width:0 обязателен: у grid-элемента по умолчанию min-width:auto, то есть
   колонка не может стать уже min-content своего содержимого. Из-за этого свёрнутые
   60px игнорировались, как только внутри появлялся широкий блок (тумблер мозгов). */
.sidebar {
  min-width: 0;
  border-right: 1px solid var(--border); padding: 16px 12px;
  display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden;
}
/* Верх сайдбара — один ряд: переключатель направлений слева, «свернуть» справа.
   Левый край переключателя выставлен по иконкам пунктов меню (padding сайдбара 12px
   + padding пункта 10px), иначе шапка визуально уезжает вправо от всего остального. */
.sidebar-top { display: flex; flex-direction: row; align-items: center; gap: 8px; margin-bottom: 10px; padding: 0; }
.sidebar-top .ws-switch { order: 1; flex: 1 1 auto; margin-bottom: 0; justify-content: flex-start; padding-left: 10px; }
.sidebar-top .collapse-btn { order: 2; margin-left: auto; align-self: center; flex: 0 0 auto; }
/* Свёрнутый сайдбар (60px): ряд не влезает — возвращаем столбик по центру. */
#app.collapsed .sidebar-top { flex-direction: column; }
#app.collapsed .sidebar-top .ws-switch { order: 0; padding-left: 0; justify-content: center; }
#app.collapsed .sidebar-top .collapse-btn { order: 1; margin-left: 0; align-self: center; }
.wordmark { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
#app.collapsed .wordmark-txt { display: none; }

/* Workspace-switch v3: активный (сверху) + неактивные (снизу сайдбара)
   Sidebar = flex-column, wsInactive получает margin-top:auto → всегда у низа.
   Каждая кнопка = 2 PNG (expanded для active, circular для inactive).
   На expanded/desktop-collapsed/mobile всё выглядит одинаково — центрировано по X. */

/* Переключатель направлений — общий файл platform/shared-ui/switcher.css */

.collapse-btn { background: none; border: none; padding: 6px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.collapse-btn:hover { background: var(--hover); color: var(--text); }
.nav-group { margin: 12px 6px 4px; font-family: 'JetBrains Mono', monospace; font-size: 9px; text-transform: uppercase; color: var(--dim); letter-spacing: .08em; }
#app.collapsed .nav-group { visibility: hidden; height: 6px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  cursor: pointer; color: var(--text); text-decoration: none; font-weight: 500;
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--lime); font-weight: 600; }
.nav-item svg { flex-shrink: 0; }
#app.collapsed .nav-label { display: none; }
#app.collapsed .nav-item { justify-content: center; padding: 8px 6px; }
.folder-toggle { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; cursor: pointer; user-select: none; font-weight: 600; }
.folder-toggle:hover { background: var(--hover); border-radius: 10px; }
.folder-body { padding-left: 12px; display: none; }
.folder-body.on { display: block; }

.main { padding: 26px 34px 100px; max-width: 1400px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.crumbs { color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.brains { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; }
.brains .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone-sage); }
h2.hero { font-size: 40px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; margin: 6px 0 26px; }


/* generic-контролы */
.pill-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 8px 18px; font: inherit; font-weight: 600; cursor: pointer; font-size: 13px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.pill-btn.primary { background: var(--lime); border-color: var(--lime); }
.pill-btn.danger { color: var(--danger); border-color: var(--danger); }
.pill-btn:disabled { opacity: .5; cursor: not-allowed; }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 12px; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.filter-label { font-family: 'JetBrains Mono', monospace; font-size: 10px; text-transform: uppercase; color: var(--dim); margin-right: 4px; }

/* chat dock */
/* Чат-ассистент: круглая кнопка (справа-внизу) + слайд-панель */
.chat-bubble {
  position: fixed; right: 20px; bottom: 20px; z-index: 120;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--text); color: var(--lime); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.22); transition: transform .18s, box-shadow .18s;
}
.chat-bubble:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,.28); }
.chat-bubble.on { background: var(--lime); color: var(--text); }
.chat-panel {
  position: fixed; right: 20px; bottom: 90px; z-index: 119;
  width: 380px; max-width: calc(100vw - 40px); height: min(520px, 70vh);
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.15);
  display: none; flex-direction: column; overflow: hidden;
}
.chat-panel.on { display: flex; }
.chat-panel-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.chat-panel-close { background: none; border: none; font-size: 22px; line-height: 1; padding: 2px 8px; cursor: pointer; color: var(--muted); border-radius: 8px; }
.chat-panel-close:hover { background: var(--hover); color: var(--text); }
.chat-panel .messages { flex: 1; overflow-y: auto; padding: 14px 18px; font-size: 13px; line-height: 1.5; }
.chat-panel .input-row { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.chat-panel input { flex: 1; border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font: inherit; }
@media (max-width: 640px) {
  .chat-panel { right: 10px; left: 10px; width: auto; bottom: 82px; }
  .chat-bubble { right: 14px; bottom: 14px; width: 50px; height: 50px; }
}

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center; justify-content: center; z-index: 200; }
.modal-bg.on { display: flex; }
.modal { background: var(--surface); border-radius: 20px; padding: 28px; max-width: 640px; width: 92%; max-height: 90vh; overflow-y: auto; position: relative; }
/* macOS traffic-light close button — маленький красный круг в правом верхнем углу */
.mac-close {
  position: absolute; top: 14px; right: 14px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #ff5f57; border: 0.5px solid rgba(0,0,0,.15);
  cursor: pointer; padding: 0;
  box-shadow: inset 0 0.5px 0 rgba(255,255,255,.35);
  transition: background .12s;
}
.mac-close:hover { background: #ff3b30; }
.mac-close:hover::after {
  content: '×';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: rgba(0,0,0,.55); font-size: 12px; font-weight: 700; line-height: 1;
}
.modal h3 { margin: 0 0 12px; }
.modal input, .modal select, .modal textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; margin: 6px 0 12px; }
.modal textarea { min-height: 80px; resize: vertical; }
.modal .row-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.modal .warn { background: color-mix(in srgb, var(--danger) 8%, transparent); border: 1px solid var(--danger); border-radius: 12px; padding: 12px 14px; color: var(--danger); font-size: 13px; margin: 8px 0; }
.modal label { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }


/* nav-разделитель + кнопка-item (для «Репорт бага» в сайдбаре) */
.nav-divider { height: 1px; background: var(--border); margin: 10px 6px; }
.nav-btn { background: none; border: none; width: 100%; text-align: left; font: inherit; }

/* Мобильный гамбургер + затемнение при открытом сайдбаре */
.mobile-menu-btn {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 130;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; color: var(--text); align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 105;
}

@media (max-width: 900px) {
  /* На мобиле сайдбар off-canvas overlay, не толкает контент */
  #app.on { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh;
    width: var(--sidebar-w); z-index: 110;
    background: var(--surface); box-shadow: 2px 0 20px rgba(0,0,0,.08);
    transform: translateX(-100%); transition: transform .22s ease;
    padding-top: 60px;
  }
  #app.mobile-open .sidebar { transform: translateX(0); }
  #app.mobile-open .sidebar-backdrop { display: block; }
  .mobile-menu-btn { display: inline-flex; }
  .main { padding: 60px 16px 100px; }
  .topbar { margin-bottom: 16px; }
  .board { grid-template-columns: 1fr; }
  .md-shell, .pj-shell { grid-template-columns: 1fr; }
}


