/* Чат Агента как выезжающая панель (drawer) поверх дашборда Совета. Порт chat.html ВБ,
   перекрашен под токены темы Совета (styles.css). Классы/id неймспейснуты (nc-/nav-),
   чтобы не коллизить с дашбордом. Светлая/тёмная тема — через переменные. */

/* ── Чат Агента на ВСЮ СТРАНИЦУ (как ВБ/iKomek), не частичная панель ── */
.agent-chat-overlay{
  position:fixed; inset:0; z-index:1000;
  display:none; opacity:0;
  transition:opacity .15s ease;
  /* Шрифт чата — системный, как в iKomek (тоньше, чем Manrope дашборда). */
  font-family:-apple-system, system-ui, "Segoe UI", Inter, "Helvetica Neue", sans-serif;
  /* Базовый вес 400 (regular) — тема Совета наследует body{font-weight:500}, отсюда «толстило».
     Внутренние элементы наследуют 400; у акцентов (заголовки/жирный/шапки таблиц) явный 600. */
  font-weight:400;
}
.agent-chat-overlay.is-open{ display:block; opacity:1; }
.agent-chat-backdrop{ display:none; }   /* нет дашборда позади — чат занимает весь экран */
.agent-chat-drawer{
  position:absolute; inset:0;
  width:100%;
  display:flex; flex-direction:column;
  background:var(--bg);
}
.agent-chat-bar{
  flex:0 0 auto; display:flex; align-items:center; justify-content:space-between;
  padding:12px 16px; border-bottom:1px solid var(--border-2);
}
.agent-chat-bar-title{ font-size:15px; font-weight:600; color:var(--text); }
.agent-chat-close{
  width:34px; height:34px; border:0; background:transparent; border-radius:8px;
  cursor:pointer; color:var(--text-2); font-size:18px; line-height:1;
  display:inline-flex; align-items:center; justify-content:center;
  transition:background .12s ease, color .12s ease;
}
.agent-chat-close:hover{ background:var(--surface-3); color:var(--text); }
.agent-chat-body{ flex:1; min-height:0; display:flex; }
body.agent-chat-lock{ overflow:hidden; }

.nc-chat{
  --nc-col-w: 740px;
  display:flex;
  flex:1; min-height:0;          /* заполняет тело панели */
  background:var(--bg);
  overflow:hidden;
}

/* ── Панель сессий ── */
.nc-sessions-pane{
  width:264px; flex:0 0 264px;
  background:var(--surface);
  border-right:1px solid var(--border);
  display:flex; flex-direction:column;
  transition:margin-left .2s ease;
}
.nc-sessions-pane.nc-collapsed{ margin-left:-264px; }
.nc-pane-head{ padding:14px 12px 6px; }
.nc-newchat{
  width:100%; padding:10px 14px;
  background:var(--surface-2); color:var(--text);
  border:1px solid var(--border); border-radius:10px;
  cursor:pointer; font:inherit; font-size:14px; font-weight:600;
  display:flex; align-items:center; gap:8px; justify-content:center;
  transition:background .12s ease, border-color .12s ease;
}
.nc-newchat:hover{ background:var(--surface-3); border-color:var(--accent); }
.nc-sessions-scroll{ flex:1; overflow-y:auto; padding:6px 0 16px; }
/* Футер панели бесед — «Выйти» (из аккаунта), как в сайдбаре дашборда: полноэкранный
   чат закрывает сайдбар Совета, поэтому выход дублируем здесь. */
.nc-pane-foot{ flex:0 0 auto; padding:8px; border-top:1px solid var(--border-2); }
.nc-logout{
  width:100%; display:flex; align-items:center; gap:8px; justify-content:flex-start;
  padding:9px 12px; background:transparent; border:0; border-radius:8px;
  cursor:pointer; color:var(--muted); font:inherit; font-size:14px;
  transition:background .12s ease, color .12s ease;
}
.nc-logout:hover{ background:var(--surface-3); color:var(--text); }
.nc-logout svg{ flex-shrink:0; }
.nc-group h3{
  margin:0; padding:14px 18px 4px;
  font-size:11px; text-transform:uppercase; letter-spacing:.06em;
  color:var(--muted); font-weight:600;
}
.nc-item{
  position:relative; margin:1px 8px; padding:7px 12px;
  border-radius:8px; cursor:pointer; display:flex; align-items:center; gap:6px;
  font-size:14px; color:var(--text); transition:background .12s ease;
}
.nc-item:hover{ background:var(--surface-3); }
.nc-item.nc-active{ background:var(--accent-soft); }
.nc-item .nc-ic{ font-size:11px; opacity:.55; flex-shrink:0; }
.nc-item .nc-item-title{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.nc-item:hover .nc-item-title, .nc-item.nc-menu-open .nc-item-title{ padding-right:28px; }
.nc-item-actions{
  position:absolute; right:6px; top:50%; transform:translateY(-50%);
  opacity:0; transition:opacity .12s ease; pointer-events:none;
}
.nc-item:hover .nc-item-actions, .nc-item.nc-menu-open .nc-item-actions{ opacity:1; pointer-events:auto; }
.nc-item-actions button{
  width:26px; height:26px; border:0; background:var(--surface-3);
  border-radius:6px; cursor:pointer; color:var(--text-2);
  font-size:16px; line-height:1; display:inline-flex; align-items:center; justify-content:center;
}
.nc-item-actions button:hover{ background:var(--accent-soft-2); color:var(--text); }
.nc-empty-list{ padding:16px; color:var(--muted); font-size:13px; }

/* ── Колонка диалога ── */
.nc-main{ flex:1; display:flex; flex-direction:column; min-width:0; background:var(--bg); }
.nc-header{
  height:52px; flex:0 0 52px; display:flex; align-items:center;
  padding:0 14px; gap:6px; border-bottom:1px solid var(--border-2);
}
.nc-iconbtn{
  width:34px; height:34px; border:0; background:transparent; border-radius:8px;
  cursor:pointer; display:inline-flex; align-items:center; justify-content:center;
  color:var(--text-2); font-size:17px; transition:background .12s ease, color .12s ease;
}
.nc-iconbtn:hover{ background:var(--surface-3); color:var(--text); }
.nc-title{
  flex:1; font-size:15px; font-weight:600; color:var(--text);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; padding:0 6px;
}
.nc-title.nc-title-empty{ color:var(--muted); font-weight:400; }

.nc-menu-wrap{ position:relative; }
.nc-menu{
  position:absolute; background:var(--surface); border:1px solid var(--border);
  border-radius:10px; box-shadow:0 8px 28px rgba(0,0,0,.10);
  min-width:180px; padding:4px; z-index:60;
}
.nc-menu.nc-header-menu{ right:0; top:40px; }
.nc-menu.nc-item-menu{ right:8px; top:32px; }
.nc-menu button{
  width:100%; text-align:left; padding:8px 12px; background:transparent; border:0;
  border-radius:6px; cursor:pointer; font:inherit; font-size:14px; color:var(--text);
}
.nc-menu button:hover{ background:var(--surface-3); }
.nc-menu button.nc-danger{ color:var(--danger); }
.nc-menu[hidden]{ display:none; }

.nc-scroll{ flex:1; overflow-y:auto; padding:16px; }
.nc-col{ max-width:var(--nc-col-w); margin:0 auto; display:flex; flex-direction:column; gap:24px; padding:20px 0 40px; }
.nc-empty{ max-width:var(--nc-col-w); margin:0 auto; padding:12vh 16px 40px; text-align:center; color:var(--text-2); }
.nc-empty h1{ margin:0 0 10px; color:var(--text); font-weight:600; font-size:30px; letter-spacing:-.01em; }
.nc-empty p{ margin:0 0 26px; font-size:14px; color:var(--text-2); }
.nc-empty-cta{
  display:inline-flex; align-items:center; gap:8px; padding:12px 20px;
  background:var(--accent); color:#fff; border:0; border-radius:999px;
  font:inherit; font-weight:600; font-size:14px; cursor:pointer; transition:filter .12s ease;
}
.nc-empty-cta:hover{ filter:brightness(.96); }

.nc-msg{ display:flex; flex-direction:column; }
.nc-msg.nc-user{ align-items:flex-end; }
.nc-msg.nc-assistant{ align-items:flex-start; }
.nc-author{ font-size:11px; color:var(--muted); margin-bottom:4px; padding:0 6px; }
.nc-bubble{ max-width:80%; word-wrap:break-word; overflow-wrap:anywhere; line-height:1.65; font-size:15.5px; }
.nc-msg.nc-user .nc-bubble{ background:var(--surface-3); color:var(--text); padding:12px 18px; border-radius:18px; border-bottom-right-radius:6px; }
.nc-msg.nc-assistant .nc-bubble{ background:transparent; color:var(--text); padding:2px 0; max-width:100%; }
.nc-bubble.nc-error{ background:var(--danger-soft); color:var(--danger); padding:12px 18px; border-radius:14px; max-width:80%; }
.nc-bubble p{ margin:0 0 10px; }
.nc-bubble p:last-child{ margin:0; }
.nc-bubble pre{ background:var(--surface-3); color:var(--text); padding:14px 16px; border-radius:10px; overflow-x:auto; font-size:13.5px; line-height:1.55; margin:10px 0; }
.nc-bubble code{ font-family:"SF Mono",Menlo,Consolas,monospace; font-size:.92em; }
.nc-bubble :not(pre) > code{ background:var(--accent-soft); color:var(--accent-ink); padding:1px 6px; border-radius:4px; }
.nc-bubble ul, .nc-bubble ol{ margin:4px 0 10px; padding-left:24px; }
.nc-bubble li{ margin-bottom:4px; }
.nc-bubble table{ border-collapse:collapse; margin:10px 0; font-size:14px; }
.nc-bubble th, .nc-bubble td{ border:1px solid var(--border); padding:6px 10px; }
.nc-bubble th{ font-weight:600; }
.nc-bubble strong, .nc-bubble b{ font-weight:600; }   /* жирный тоньше, как в iKomek (не 700) */
.nc-bubble h1, .nc-bubble h2, .nc-bubble h3{ margin:14px 0 6px; line-height:1.3; font-weight:600; }
.nc-bubble h1{ font-size:21px; } .nc-bubble h2{ font-size:18px; } .nc-bubble h3{ font-size:16px; }
.nc-bubble a{ color:var(--accent-ink); text-decoration:underline; text-underline-offset:2px; }
.nc-tool-hint{ font-size:13px; color:var(--muted); font-style:italic; padding:2px 4px; }

.nc-dots{ display:inline-flex; gap:5px; padding:8px 0; align-items:center; }
.nc-dots span{ width:7px; height:7px; background:var(--muted); border-radius:50%; animation:nc-dots 1.3s infinite ease-in-out; }
.nc-dots span:nth-child(2){ animation-delay:.18s; }
.nc-dots span:nth-child(3){ animation-delay:.36s; }
@keyframes nc-dots{ 0%,80%,100%{ transform:scale(.5); opacity:.35; } 40%{ transform:scale(1); opacity:1; } }

/* ── Поле ввода ── */
.nc-input-area{ flex:0 0 auto; padding:6px 16px 18px; background:var(--bg); }
.nc-input-wrap{
  max-width:var(--nc-col-w); margin:0 auto; background:var(--surface);
  border:1px solid var(--border); border-radius:24px; padding:6px 8px;
  transition:border-color .15s ease, box-shadow .15s ease;
}
.nc-input-wrap:focus-within{ border-color:var(--accent); box-shadow:0 2px 14px rgba(0,0,0,.05); }
.nc-chips{ display:flex; flex-wrap:wrap; gap:6px; padding:8px 12px 4px; }
.nc-chips:empty{ display:none; }
.nc-chip{ display:inline-flex; align-items:center; gap:6px; background:var(--surface-3); border-radius:14px; padding:4px 8px 4px 10px; font-size:12px; max-width:220px; }
.nc-chip-name{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.nc-chip button{ background:transparent; border:0; cursor:pointer; color:var(--text-2); padding:0; width:16px; height:16px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-size:14px; line-height:1; }
.nc-chip button:hover{ background:var(--accent-soft-2); color:var(--text); }

.nc-input-row{ display:flex; align-items:flex-end; gap:4px; padding:4px; }
.nc-input-row textarea{
  flex:1; min-height:28px; max-height:200px; resize:none; border:0; outline:none;
  padding:10px 8px; font:inherit; font-size:15.5px; background:transparent; color:var(--text); line-height:1.5;
}
.nc-input-row textarea::placeholder{ color:var(--muted); }

.nc-send{
  width:36px; height:36px; border-radius:50%; border:0; padding:0;
  background:var(--accent); color:#fff; cursor:pointer; display:inline-flex;
  align-items:center; justify-content:center; flex-shrink:0; transition:filter .12s ease, opacity .12s ease;
}
.nc-send svg{ display:block; }
.nc-send:hover:not(:disabled){ filter:brightness(.96); }
.nc-send:disabled{ background:var(--surface-3); color:var(--muted); cursor:not-allowed; }

.nc-actions{ display:flex; gap:4px; align-items:center; padding-bottom:2px; }
.nc-actions .nc-iconbtn{ width:36px; height:36px; border-radius:50%; padding:0; color:var(--text-2); background:transparent; flex-shrink:0; }
.nc-actions .nc-iconbtn svg{ display:block; }
.nc-actions .nc-iconbtn:hover{ background:var(--surface-3); color:var(--text); }
.nc-iconbtn.nc-recording{ color:#fff !important; background:var(--danger) !important; animation:nc-pulse 1.4s infinite; }
.nc-voice-hidden{ display:none !important; }   /* голос выключен (нет Groq-ключа) */
@keyframes nc-pulse{ 0%,100%{ opacity:1; } 50%{ opacity:.7; } }
.nc-input-hint{ max-width:var(--nc-col-w); margin:8px auto 0; text-align:center; font-size:12px; color:var(--muted); }
.nc-rec-hint{ font-size:13px; color:var(--danger); max-width:var(--nc-col-w); margin:6px auto 0; text-align:center; display:flex; align-items:center; justify-content:center; gap:8px; }
.nc-rec-hint[hidden]{ display:none; }   /* author display:flex перебивал [hidden] — показывалось всегда */
.nc-rec-dot{ width:8px; height:8px; border-radius:50%; background:var(--danger); animation:nc-pulse 1.2s infinite; }

.nc-backdrop{ display:none; }

/* ── Мобилка ── */
@media (max-width:900px){
  .agent-chat-drawer{ width:100vw; border-left:0; }
  .nc-chat{ --nc-col-w:100%; }
  .nc-sessions-pane{ position:absolute; top:0; bottom:0; left:0; z-index:50; box-shadow:0 0 24px rgba(0,0,0,.18); margin-left:-264px; }
  .nc-sessions-pane.nc-open{ margin-left:0; }
  .nc-backdrop{ position:absolute; inset:0; background:rgba(0,0,0,.3); z-index:40; }
  .nc-backdrop.nc-show{ display:block; }
  .nc-scroll{ padding:8px 12px; }
  .nc-input-area{ padding:6px 12px 12px; }
  .nc-empty{ padding:8vh 16px 40px; }
  .nc-empty h1{ font-size:25px; }
}
@media (max-width:480px){
  .nc-sessions-pane{ width:84vw; flex-basis:84vw; margin-left:-84vw; }
}
