/* ============================================================
   VORTAX COUNSEL — GLOBAL DESIGN SYSTEM (THEME READY)
   ============================================================ */


/* ------------------------------------------------------------
   1) ROOT VARIABLES (fallbacks; theme overrides below)
   ------------------------------------------------------------ */
:root{
  /* Neutral text */
  --txt: #ffffff;
  --muted:#bfc2ce;

  /* Panels */
  --panel-bg: #1e202a;
  --panel-border: rgba(255,255,255,.08);

  /* Inputs */
  --input-bg:#202233;
  --input-border:rgba(255,255,255,.14);

  /* Buttons */
  --btn-bg:#343851;
  --btn-bg2:#24273a;

  /* Accents */
  --accent:#00c853;
  --accent2:#2eea7a;
  --accent3:#00a846;

  /* Danger red (dark theme accent) */
  --red-1:#ff3b3b;
  --red-2:#cc2e2e;

  /* Shadow */
  --shadow-heavy:0 20px 60px rgba(0,0,0,.45);

  /* Theme floating control */
  --theme-btn-bg:#20242e;
  --theme-btn-txt:#fff;
}


/* ============================================================
   2) GLOBAL RESET
   ============================================================ */
*{ box-sizing:border-box; }

body{
  margin:0;
  font:14px/1.45 system-ui,Inter,sans-serif;
  color:var(--txt);
  background: var(--body-bg);
  transition: background .3s, color .3s;
}

.wrap{
  max-width:1200px;
  margin:0 auto;
  padding:20px;
}


/* ============================================================
   3) FULLSCREEN SCREENS
   ============================================================ */
.screen{
  display:none;
  background:var(--panel-bg);
  border-radius:16px;
  border:1px solid var(--panel-border);
  min-height:calc(100vh - 40px);
  padding:clamp(20px, 3vw, 40px);
  box-shadow:var(--shadow-heavy);
}

.screen.screen--active{
  display:block;
}


/* ============================================================
   4) TYPOGRAPHY
   ============================================================ */
.screen h2{
  font-size: clamp(28px, 3vw, 40px);
  font-weight:800;
  margin:0 0 18px;
}

.screen h3{
  font-size: clamp(20px, 2.2vw, 28px);
  font-weight:700;
  margin:0 0 12px;
}

label, .intro, .note{
  color:var(--muted);
  font-size:clamp(14px, 1.1vw, 16px);
}


/* ============================================================
   5) BUTTONS
   ============================================================ */
.btn{
  width:100%;
  padding:12px 14px;
  margin:8px 0;
  border-radius:14px;
  background:linear-gradient(180deg,var(--btn-bg),var(--btn-bg2));
  border:1px solid rgba(255,255,255,.12);
  color:var(--txt);
  font-weight:650;
  cursor:pointer;
  transition:.2s;
}

.btn:hover{
  filter:brightness(1.08);
}

.btn--main{
  background:linear-gradient(180deg,#3d425e,#2a2e44);
}

.btn--accent{
  background:linear-gradient(180deg,var(--accent2),var(--accent),var(--accent3));
  border-color:rgba(46,234,122,.55);
}

.btn--ghost{
  width:auto;
  padding:8px 14px;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.12);
}

/* Red button for login/register */
.btn-red{
  background:linear-gradient(180deg,var(--red-1),var(--red-2));
  border:1px solid rgba(255,255,255,.2);
  color:white !important;
  font-weight:800;
  font-size:clamp(14px,1.1vw,16px);
}


/* ============================================================
   6) FORMS
   ============================================================ */
input, textarea, select{
  width:100%;
  padding:12px;
  border-radius:12px;
  background:var(--input-bg);
  border:1px solid var(--input-border);
  color:var(--txt);
  font-size:clamp(14px,1.1vw,16px);
  outline:none;
}

textarea{ min-height:70px; }

label{ display:block; margin:10px 0 6px; }


/* ============================================================
   7) LOGIN / REGISTER PANEL
   ============================================================ */
#pane-login,
#pane-register{
  background:var(--panel-dark);
  border:1px solid var(--panel-border);
  padding:28px;
  max-width:500px;
  margin:0 auto;
  border-radius:18px;
  box-shadow:0 0 25px rgba(0,0,0,.45);
}

.tabs{
  display:flex;
  justify-content:center;
  gap:8px;
  margin:14px 0 20px;
}

.tab{
  padding:10px 16px;
  border-radius:12px;
  background:#1b1c22;
  border:1px solid rgba(255,255,255,.14);
  color:#777;
  font-weight:600;
  cursor:pointer;
}

.tab--active{
  background:var(--tab-active-bg);
  color:var(--tab-active-txt);
}


/* ============================================================
   8) MAIN SCREEN BUTTONS
   ============================================================ */
.btn--section{
  width:100%;
  padding:clamp(14px,2vw,20px);
  margin:14px 0;
  border-radius:14px;
  background:var(--section-btn-bg);
  border:1px solid rgba(255,255,255,.12);
  color:var(--section-btn-txt);
  font-weight:750;
  font-size:clamp(14px,1.2vw,17px);
  letter-spacing:.3px;
  transition:.2s;
}

.btn--section:hover{
  transform:translateY(-1px);
  box-shadow:0 6px 18px rgba(0,0,0,.35);
}


/* ============================================================
   9) CHAT MODULE
   ============================================================ */
.section-chat{ margin-top:16px; }

.chat-window{
  min-height:clamp(260px,40vh,60vh);
  background:#12131a;
  border:1px solid rgba(255,255,255,.12);
  border-radius:12px;
  padding:12px;
  overflow:auto;
}

.chat-input-wrap{
  display:flex; gap:8px; align-items:stretch;
}

.chat-input-wrap .btn{
  width:auto; min-width:56px; height:48px; margin:0;
}

.chat-input{
  flex:1; min-height:48px; resize:none;
}

.chat-msg{
  margin:0 0 10px;
  padding:10px 12px;
  border-radius:12px;
  max-width:88%;
  white-space:pre-wrap;

  position: relative;     /* 👈 ДОБАВИТЬ */
  overflow: visible;      /* 👈 ДОБАВИТЬ */
  z-index: 1;
}

.chat-user{ background:#2f3345; margin-left:auto; }
.chat-bot{ background:#252839; border-left:4px solid var(--accent); }

/* ============================================================
   10) ADMIN MINI BUTTONS
   ============================================================ */
.admin-actions{
  display:flex; gap:8px; justify-content:flex-end; align-items:center;
}

button[data-action]{
  width:34px; height:34px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.15);
  font-size:18px; font-weight:800;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; color:white;
  background:#262a38;
}

button[data-action="approve"]{
  background:linear-gradient(180deg,#2eea7a,#00c853,#00a846);
}

button[data-action="reject"]{
  background:linear-gradient(180deg,#5a2a2a,#3a1b1b);
}


/* ============================================================
   11) FLOATING THEME SWITCH BUTTON
   ============================================================ */
#theme-toggle{
  position:fixed;
  bottom:26px;
  right:26px;
  width:54px;
  height:54px;
  border-radius:50%;
  background:var(--theme-btn-bg);
  color:var(--theme-btn-txt);
  border:1px solid rgba(255,255,255,.2);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  font-size:22px;
  font-weight:700;
  z-index:999;
  box-shadow:0 6px 20px rgba(0,0,0,.35);
  transition:.2s;
  user-select:none;
  -webkit-user-select:none;
  touch-action:none;
}

#theme-toggle:hover{
  transform:scale(1.07);
}


/* ============================================================
   12) THEMES
   ============================================================ */

/* DARK THEME (default) */
html.theme-dark{
  --body-bg:
    radial-gradient(1200px 600px at 85% -10%, rgba(255,59,59,.09), transparent 60%),
    radial-gradient(1000px 500px at -10% 100%, rgba(255,59,59,.07), transparent 60%),
    linear-gradient(160deg,#121318,#1c1e26);

  --panel-bg:rgba(30,32,42,.92);
  --panel-dark:#16171d;
  --panel-border:rgba(255,255,255,.1);

  --txt:#ffffff;
  --muted:#bfc2ce;

  --section-btn-bg:linear-gradient(180deg,#2b3045,#23273a);
  --section-btn-txt:#e9ecf7;

  --tab-active-bg:var(--red-1);
  --tab-active-txt:#fff;

  --theme-btn-bg:#16171d;
  --theme-btn-txt:#ffffff;
}


/* LIGHT THEME (improved readability for chat) */
html.theme-light{
  /* Базовые цвета */
  --body-bg: linear-gradient(180deg,#ffffff,#f6f7fa);
  --panel-bg: #ffffff;
  --panel-dark:#ffffff;
  --panel-border: rgba(0,0,0,.10);

  /* Текст */
  --txt: #121318;            /* основной */
  --muted:#60636c;           /* второстепенный */

  /* Инпуты */
  --input-bg: #f7f8fb;
  --input-border: rgba(0,0,0,.18);

  /* Кнопки/секции */
  --btn-bg:#e7ecf6;
  --btn-bg2:#d7dfef;
  --section-btn-bg: linear-gradient(180deg,#eef2f9,#e3e9f5);
  --section-btn-txt:#1a1d26;

  /* Табы */
  --tab-active-bg:#0067c0;
  --tab-active-txt:#fff;

  /* Плавающая кнопка темы */
  --theme-btn-bg:#ffffff;
  --theme-btn-txt:#1c1e21;
}

/* ---------------------------
   Светлая тема: чат-окна
   --------------------------- */

/* Фон окна чата — светлый */
html.theme-light .chat-window{
  background: #f7f8fb;
  border: 1px solid rgba(0,0,0,.10);
}

/* Текст по умолчанию в чате — тёмный */
html.theme-light .chat-msg{
  color: #121318;
}

/* Сообщение пользователя — серый пузырь */
html.theme-light .chat-user{
  background: #e9edf5;                       /* светло-серый */
  border: 1px solid rgba(0,0,0,.08);
}

/* Сообщение бота — белый пузырь с зелёным индикатором слева */
html.theme-light .chat-bot{
  background: #ffffff;
  border: 1px solid rgba(0,0,0,.08);
  border-left: 4px solid #00c853;            /* твой зелёный акцент */
}

/* Поле ввода внизу чата */
html.theme-light .chat-input{
  background: #ffffff;
  color: #121318;
  border: 1px solid rgba(0,0,0,.18);
}

/* Кнопки в чате — немного темнее для контраста */
html.theme-light .chat-input-wrap .btn{
  background: linear-gradient(180deg,#e3e9f5,#d6deee);
  border: 1px solid rgba(0,0,0,.12);
  color: #0f1116;
}

/* Кнопка "Очистить" — светлая, читабельная */
html.theme-light .btn--ghost{
  background: #f5f7fb;
  color: #1a1d26;
  border-color: rgba(0,0,0,.12);
}

/* Статус/подписи */
html.theme-light .note,
html.theme-light label,
html.theme-light .intro{
  color: #60636c;
}

/* Заголовки для лучшей читаемости */
html.theme-light .screen h2,
html.theme-light .screen h3{
  color: #0f1116;
}

/* ============================================================
   13) ОБНОВЛЕНИЯ
   ============================================================ */

/* === Главная двухколоночная сетка === */
.main-grid{
  display:flex;
  align-items:stretch;
  gap: 16px;
  margin-top: 8px;
}

/* Левая колонка */
.main-actions{
  flex: 1 1 auto;
  min-width: 0;
}

/* Правая колонка-рамка */
.side-panel{
  flex: 0 0 110px;
  display:flex;
}

.side-panel__inner{
  border:1px solid var(--panel-border);
  background: var(--panel-dark);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
  width:100%;
  padding: 12px;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* Кнопка со скрепкой */
.btn-clip{
  width:48px; height:48px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.15);
  background:#262a38;
  color:white;
  font-size:20px;
  font-weight:800;
  cursor:pointer;
}
.btn-clip--big{
  width:56px; height:56px;
  font-size:22px;
}

/* Восстановить ширину секционных кнопок */
.btn--section{
  width:100%;
}

/* Исправление для чатов — изначально скрыты */
#kb-chat,
#codes-chat,
#chat-chat {
  display: none;
}

/* ============================================================
 14) MODAL OVERLAY (Upload)
============================================================ */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0,0,0,.45);              /* затемнение фона */
  backdrop-filter: blur(2px);
  z-index: 2000;                             /* выше всего */
}
.modal[hidden] { display: none; }

.modal__dialog{
  width: min(720px, 96vw);
  max-height: 90vh;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: var(--shadow-heavy);
  display: flex;
  flex-direction: column;
}

.modal__header, .modal__footer{
  padding: 12px 16px;
  background: var(--panel-dark);
  border-bottom: 1px solid var(--panel-border);
}
.modal__footer{ border-top: 1px solid var(--panel-border); border-bottom: none; }

.modal__body{ padding: 16px; overflow: auto; }

.modal__close{
  width: 34px; height: 34px;
  margin-left: auto;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.15);
  font-weight: 800;
  background:#262a38; color:#fff; cursor:pointer;
}

/* Когда модалка открыта, запрещаем прокрутку подложки */
body.modal-open { overflow: hidden; }

/* Кнопки в шапке экрана: "Назад" + "Обновить" рядом */
.head-actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.head-actions .btn{ width: auto; }

/* ============================================================
 15) TOAST NOTIFICATIONS
============================================================ */
.toast-wrap{
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 3000;
}
.toast{
  min-width: 220px;
  max-width: min(92vw, 420px);
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--txt);
  box-shadow: var(--shadow-heavy);
  font: 14px/1.4 system-ui, Inter, sans-serif;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast--show{ opacity: 1; transform: translateY(0); }
.toast--ok{ border-color: rgba(46,234,122,.55); }
.toast--bad{ border-color: rgba(255,59,59,.6); }
.toast__title{ font-weight: 750; margin-bottom: 4px; }
.toast__msg{ opacity: .85; white-space: pre-wrap; }

/* --- кнопки в одну строку в формах --- */
.btn-row{
  display:flex;
  gap:8px;
  align-items:stretch;
}
.btn--short{
  width:auto; /* переопределяет .btn { width:100% } */
}

.doc-dd{
  position:relative;
}

.doc-dd__toggle{
  width:100%;
  padding:12px;
  border-radius:12px;
  background:var(--input-bg);
  border:1px solid var(--input-border);
  color:var(--txt);
  font-size:clamp(14px,1.1vw,16px);
  text-align:left;
  cursor:pointer;
}

.doc-dd__toggle::after{
  content:"▾";
  float:right;
  opacity:.8;
}

.doc-dd__panel{
  position:absolute;
  top:calc(100% + 6px);
  left:0;
  right:0;
  z-index:1200;
  background:var(--panel-bg);
  border:1px solid var(--panel-border);
  border-radius:12px;
  box-shadow:var(--shadow-heavy);
  padding:10px;
}

.doc-dd__list{
  max-height:160px;
  overflow-y:auto;
  display:flex;
  flex-direction:column;
  gap:8px;
  padding-right:4px;
}

.doc-dd--compact .doc-dd__list{
  max-height:130px;
}

.doc-dd__item{
  display:flex;
  align-items:flex-start;
  gap:8px;
  color:var(--txt);
  font-size:14px;
  line-height:1.35;
}

.doc-dd__item input[type="checkbox"]{
  width:16px;
  height:16px;
  margin:2px 0 0;
  flex:0 0 auto;
}

.doc-dd__item--all{
  padding-bottom:6px;
  margin-bottom:4px;
  border-bottom:1px solid rgba(255,255,255,.08);
  font-weight:700;
}

.doc-dd__actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:10px;
}

/* ============================= */
/* TOOLTIP (STABLE VERSION) */
/* ============================= */

.tooltip {
  position: relative;
  cursor: pointer;
  color: #4da3ff;
  border-bottom: 1px dashed #4da3ff;
  z-index: 2;
}

/* Само всплывающее окно */
.tooltip-box {
  display: none;
  position: absolute;

  bottom: 120%;
  left: 0;

  width: 320px;
  max-height: 220px;
  overflow: auto;

  background: #1e202a;
  color: #ffffff;

  padding: 10px 12px;
  border-radius: 10px;

  white-space: pre-wrap;
  line-height: 1.4;
  font-size: 13px;

  z-index: 9999;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);

  opacity: 0;
  transform: translateY(6px);
  transition: all 0.15s ease;
}

/* Появление */
.tooltip:hover .tooltip-box {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* ============================= */
/* GLOBAL CHUNK TOOLTIP          */
/* ============================= */

.chunk-link{
  color:#4da3ff;
  cursor:pointer;
  border-bottom:1px dashed #4da3ff;
  text-decoration:none;
}

.global-tooltip{
  position:fixed;
  z-index:20000;
  display:none;

  width:min(560px, calc(100vw - 24px));   /* шире */
  max-height:min(70vh, 520px);            /* большой лимит по высоте */
  overflow:auto;

  background:#1e202a;
  color:#ffffff;
  padding:14px 16px;
  border-radius:12px;
  box-shadow:0 14px 40px rgba(0,0,0,.45);
  line-height:1.45;
  font-size:14px;

  pointer-events:auto;                    /* можно навести и скролить */
  white-space:normal;
  word-break:break-word;
}

.global-tooltip--show{
  display:block;
}

html.theme-light .chunk-link{
  color:#0067c0;
  border-bottom:1px dashed #0067c0;
}

html.theme-light .global-tooltip{
  background:#ffffff;
  color:#121318;
  border:1px solid rgba(0,0,0,.12);
}

/* ============================= */
/* Rich text / Markdown in chat  */
/* ============================= */

.chat-bot h1,
.chat-bot h2,
.chat-bot h3,
.chat-bot h4 {
  margin: 0 0 10px;
  line-height: 1.3;
  font-weight: 800;
}

.chat-bot h1 { font-size: 22px; }
.chat-bot h2 { font-size: 19px; }
.chat-bot h3 { font-size: 17px; }
.chat-bot h4 { font-size: 15px; }

.chat-bot p {
  margin: 0 0 10px;
}

.chat-bot ul,
.chat-bot ol {
  margin: 0 0 10px 20px;
  padding: 0;
}

.chat-bot li {
  margin: 0 0 6px;
}

.chat-bot strong,
.chat-bot b {
  font-weight: 700;
}

.chat-bot em,
.chat-bot i {
  font-style: italic;
}

.chat-bot blockquote {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-left: 4px solid var(--accent);
  background: rgba(255,255,255,.04);
  border-radius: 8px;
}

.chat-bot pre {
  margin: 0 0 10px;
  padding: 12px;
  overflow: auto;
  border-radius: 10px;
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.08);
}

.chat-bot code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
}

.chat-bot p code,
.chat-bot li code {
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255,255,255,.08);
}

.chat-bot a:not(.chunk-link) {
  color: #7ab8ff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-bot > :last-child {
  margin-bottom: 0;
}

/* Светлая тема */
html.theme-light .chat-bot blockquote {
  background: rgba(0,0,0,.03);
  border-left-color: #00c853;
}

html.theme-light .chat-bot pre {
  background: #f4f6fa;
  border: 1px solid rgba(0,0,0,.08);
}

html.theme-light .chat-bot p code,
html.theme-light .chat-bot li code {
  background: rgba(0,0,0,.06);
}

html.theme-light .chat-bot a:not(.chunk-link) {
  color: #0067c0;
}

/* ============================= */
/* Fix large gaps in rich text   */
/* ============================= */

/* Для HTML-рендера Markdown не нужно сохранять все переводы строк как в plain text */
.chat-bot {
  white-space: normal;
  line-height: 1.45;
}

/* Внутри списков убираем лишние отступы у параграфов */
.chat-bot li > p {
  margin: 0;
}

/* Чуть компактнее заголовки и абзацы */
.chat-bot h1,
.chat-bot h2,
.chat-bot h3,
.chat-bot h4 {
  margin: 0 0 8px;
}

.chat-bot p {
  margin: 0 0 8px;
}

/* Компактнее списки */
.chat-bot ul,
.chat-bot ol {
  margin: 0 0 8px 20px;
  padding: 0;
}

.chat-bot li {
  margin: 0 0 4px;
}

/* А вот для кода/преформатированного текста переносы сохранить */
.chat-bot pre,
.chat-bot code {
  white-space: pre-wrap;
}
