/* Поддержка: кабинет клиента (/tickets) и панель саппорта (/support) */

.sup{min-height:100svh;display:flex;flex-direction:column}
.sup main{flex:1}
.sup-page{padding-block:clamp(28px,5vw,52px) clamp(48px,7vw,84px)}

.sup-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:18px;
  margin-bottom:clamp(20px,3vw,30px);
}
.sup-head h1{
  margin-top:12px;
  font-size:clamp(26px,4vw,40px);
  letter-spacing:-.035em;
}
.sup-sub{margin-top:6px;font-size:14.5px;color:var(--muted)}
.sup-actions{display:flex;gap:10px;flex-wrap:wrap}

/* Очередь */
.qbar{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:10px 26px;
  padding:16px 20px;
  margin-bottom:20px;
  border:1px solid var(--line);
  border-radius:var(--r-md);
  background:var(--bg-soft);
}
.qbar-main{display:flex;align-items:center;gap:12px;min-width:0}
.qbar-ic{
  display:grid;place-items:center;
  width:38px;height:38px;flex:none;
  border-radius:11px;
  background:var(--lime);
  color:var(--on-lime);
  font-size:17px;
}
.qbar-text{min-width:0}
.qbar-text b{display:block;font-size:15px;letter-spacing:-.01em}
.qbar-text span{font-size:13.5px;color:var(--muted)}
.qbar-stats{display:flex;gap:22px;margin-left:auto;flex-wrap:wrap}
.qbar-stat{display:grid;gap:1px}
.qbar-stat b{font-size:18px;font-weight:700;letter-spacing:-.02em;line-height:1.2}
.qbar-stat span{font-size:12px;color:var(--muted)}
.qbar.is-off .qbar-ic{background:var(--st-gray-bg);color:var(--st-gray-fg)}

/* Список тикетов */
.tlist{display:grid;gap:12px}
.tcard{
  display:grid;
  grid-template-columns:1fr auto;
  gap:6px 16px;
  width:100%;
  padding:18px 20px;
  text-align:left;
  border:1px solid var(--line);
  border-radius:var(--r-md);
  background:var(--bg);
  transition:border-color .22s var(--ease),transform .22s var(--ease);
}
button.tcard{cursor:pointer}
.tcard:hover{border-color:var(--line-strong)}
.tcard-top{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}
.tcard-id{font-family:"JetBrains Mono",ui-monospace,monospace;font-size:12.5px;color:var(--muted)}
.tcard-subj{font-size:16px;font-weight:700;letter-spacing:-.015em;overflow-wrap:anywhere}
.tcard-meta{
  grid-column:1;
  display:flex;
  gap:6px 14px;
  flex-wrap:wrap;
  font-size:13px;
  color:var(--muted);
}
.tcard-side{grid-column:2;grid-row:1 / span 2;display:flex;align-items:center;gap:8px}

.tst{
  padding:4px 11px;
  border-radius:999px;
  font-size:12px;
  font-weight:600;
  white-space:nowrap;
}
.tst-open{background:var(--st-blue-bg);color:var(--st-blue-fg)}
.tst-in_progress{background:var(--lime);color:var(--on-lime)}
.tst-closed{background:var(--st-gray-bg);color:var(--st-gray-fg)}

.tdot{
  display:grid;place-items:center;
  min-width:20px;height:20px;padding:0 6px;
  border-radius:999px;
  background:#d9432a;color:#fff;
  font-size:11px;font-weight:700;
}

/* Форма нового тикета */
.sup-card{
  padding:clamp(22px,3.5vw,32px);
  border:1px solid var(--line);
  border-radius:var(--r-lg);
  background:var(--bg);
}
.sup-card h2{font-size:22px;letter-spacing:-.025em;margin-bottom:6px}
.sup-card .muted{font-size:14px;margin-bottom:20px}

.topics{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:18px}
.topic{
  padding:9px 15px;
  border:1px solid var(--line-strong);
  border-radius:999px;
  font-size:14px;
  font-weight:600;
  color:var(--ink-soft);
  transition:background-color .2s var(--ease),color .2s var(--ease),border-color .2s var(--ease);
}
.topic:hover{border-color:var(--ink);color:var(--ink)}
.topic.is-on{background:var(--lime);border-color:var(--lime);color:var(--on-lime)}

.sup-form .field textarea{min-height:130px;resize:vertical}
.sup-form-actions{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  flex-wrap:wrap;
  margin-top:18px;
}

/* Переписка */
.thread{
  display:flex;
  flex-direction:column;
  min-height:0;
  border:1px solid var(--line);
  border-radius:var(--r-lg);
  background:var(--bg);
  overflow:hidden;
}
.thread-head{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  padding:16px 20px;
  border-bottom:1px solid var(--line);
  background:var(--bg-soft);
}
.thread-back{
  display:grid;place-items:center;
  width:34px;height:34px;flex:none;
  border-radius:10px;
  color:var(--ink-soft);
  transition:background-color .2s var(--ease),color .2s var(--ease);
}
.thread-back:hover{background:var(--bg);color:var(--ink)}
.thread-title{min-width:0;flex:1}
.thread-title b{display:block;font-size:16px;letter-spacing:-.015em;overflow-wrap:anywhere}
.thread-title span{font-size:12.5px;color:var(--muted)}
.thread-tools{display:flex;gap:8px;flex-wrap:wrap}

.thread-note{
  padding:11px 20px;
  border-bottom:1px solid var(--line);
  background:var(--lime-tint);
  font-size:13.5px;
  color:var(--ink-soft);
}

.msgs{
  flex:1;
  min-height:220px;
  max-height:min(56vh,560px);
  overflow-y:auto;
  padding:20px;
  display:flex;
  flex-direction:column;
  gap:14px;
  scroll-behavior:smooth;
}
.msg{
  max-width:min(78%,620px);
  padding:12px 15px;
  border:1px solid var(--line);
  border-radius:var(--r-md);
  background:var(--bg-soft);
}
.msg.is-mine{align-self:flex-end;background:var(--lime-tint);border-color:transparent}
.msg-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:14px;
  margin-bottom:5px;
}
.msg-head b{font-size:13px;font-weight:700;letter-spacing:-.01em}
.msg-head time{font-size:11.5px;color:var(--muted);white-space:nowrap}
.msg-text{font-size:14.5px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}
.msg-system{
  align-self:center;
  max-width:90%;
  text-align:center;
}
.msg-system span{
  display:inline-block;
  padding:5px 13px;
  border-radius:999px;
  background:var(--bg-sunk);
  font-size:12.5px;
  color:var(--muted);
}

.msg-files{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.msg-shot{
  display:block;
  width:118px;height:88px;
  border-radius:10px;
  border:1px solid var(--line);
  overflow:hidden;
  background:var(--bg);
}
.msg-shot img{width:100%;height:100%;object-fit:cover}
.msg-file{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border:1px solid var(--line);
  border-radius:10px;
  background:var(--bg);
  font-size:13px;
  max-width:100%;
}
.msg-file:hover{border-color:var(--line-strong)}
.msg-file-ic{color:var(--muted);font-size:15px}
.msg-file-name{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.msg-file-size{color:var(--muted);white-space:nowrap}

/* Поле ответа */
.composer{
  border-top:1px solid var(--line);
  padding:14px 20px 16px;
  background:var(--bg);
}
.composer.is-drop{background:var(--lime-tint)}
.composer-row{display:flex;align-items:flex-end;gap:10px}
.composer textarea{
  flex:1;
  min-height:46px;
  max-height:200px;
  padding:12px 14px;
  border:1px solid var(--line-strong);
  border-radius:var(--r-sm);
  background:var(--bg-soft);
  font-size:14.5px;
  line-height:1.5;
  resize:none;
  outline:none;
  transition:border-color .2s var(--ease),background-color .2s var(--ease);
}
.composer textarea:focus{border-color:var(--ink);background:var(--bg)}
.composer-btn{
  display:grid;place-items:center;
  width:46px;height:46px;flex:none;
  border:1px solid var(--line-strong);
  border-radius:var(--r-sm);
  color:var(--ink-soft);
  font-size:17px;
  transition:border-color .2s var(--ease),color .2s var(--ease),background-color .2s var(--ease);
}
.composer-btn:hover{border-color:var(--ink);color:var(--ink)}
.composer-send{
  background:var(--solid-bg);
  border-color:var(--solid-bg);
  color:var(--solid-fg);
}
.composer-send:hover{opacity:.88;border-color:var(--solid-bg);color:var(--solid-fg)}
.composer-send[disabled]{opacity:.4;pointer-events:none}
.composer-hint{margin-top:8px;font-size:12px;color:var(--muted)}

.atts{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:10px}
.att{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 8px 6px 11px;
  border:1px solid var(--line);
  border-radius:999px;
  background:var(--bg-soft);
  font-size:12.5px;
  max-width:100%;
}
.att.is-loading{opacity:.7}
.att.is-error{border-color:var(--st-red-fg);color:var(--st-red-fg)}
.att-ic{font-size:14px;color:var(--muted)}
.att.is-error .att-ic{color:var(--st-red-fg)}
.att-name{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:190px}
.att-size{color:var(--muted)}
.att.is-error .att-size{color:var(--st-red-fg)}
.att-del{
  display:grid;place-items:center;
  width:22px;height:22px;flex:none;
  border-radius:50%;
  color:var(--muted);
  font-size:12px;
}
.att-del:hover{background:var(--bg-sunk);color:var(--ink)}

.sup-empty{
  display:grid;
  justify-items:center;
  gap:14px;
  padding:clamp(32px,6vw,54px) 24px;
  text-align:center;
  border:1px dashed var(--line-strong);
  border-radius:var(--r-lg);
  background:var(--bg-soft);
}
.sup-empty p{color:var(--ink-soft);max-width:42ch}

/* Панель саппорта */
.agent-grid{
  display:grid;
  grid-template-columns:minmax(300px,380px) minmax(0,1fr);
  gap:18px;
  align-items:start;
}
.agent-side{display:grid;gap:16px}
.agent-group h3{
  display:flex;
  align-items:center;
  gap:8px;
  margin-bottom:10px;
  font-size:14px;
  letter-spacing:-.01em;
}
.agent-count{
  padding:2px 8px;
  border-radius:999px;
  background:var(--bg-sunk);
  font-size:12px;
  font-weight:700;
  color:var(--ink-soft);
}
.agent-group .tcard{padding:14px 16px}
.agent-group .tcard-subj{font-size:15px}
.tcard.is-on{border-color:var(--ink)}
.tcard.is-mute{opacity:.72}

/* В шапке панели логотип ведёт на сайт, а слово «поддержка» — обратно в панель */
.sup .brand{gap:8px}
.brand-home{display:inline-flex;align-items:center;gap:10px;transition:opacity .22s var(--ease)}
.brand-home:hover{opacity:.72}
.brand-sep{color:var(--muted);font-weight:500}
.brand-sub{
  font-weight:700;
  color:var(--muted);
  transition:color .22s var(--ease);
}
.brand-sub:hover{color:var(--ink)}

/* Переключатель присутствия: пока саппорт не на линии, клиенту видно, что никого нет */
.line-toggle{
  display:inline-flex;
  align-items:center;
  gap:8px;
  height:38px;
  padding:0 14px;
  border:1px solid var(--line-strong);
  border-radius:999px;
  background:var(--bg);
  font-size:13.5px;
  font-weight:600;
  color:var(--ink-soft);
  transition:border-color .22s var(--ease),color .22s var(--ease),background-color .22s var(--ease);
}
.line-toggle:hover{border-color:var(--ink);color:var(--ink)}
.line-dot{
  width:8px;height:8px;
  border-radius:50%;
  background:var(--muted);
  transition:background-color .22s var(--ease),box-shadow .22s var(--ease);
}
.line-toggle.is-on{
  border-color:var(--lime);
  background:var(--lime);
  color:var(--on-lime);
}
.line-toggle.is-on .line-dot{background:var(--on-lime);box-shadow:0 0 0 3px rgba(16,16,16,.12)}

.agent-who{
  display:flex;
  align-items:center;
  gap:10px;
  padding:5px 13px 5px 6px;
  border:1px solid var(--line);
  border-radius:999px;
  background:var(--bg);
  font-size:13.5px;
}
.agent-ava{
  display:grid;place-items:center;
  width:30px;height:30px;
  border-radius:50%;
  background:var(--lime);
  color:var(--on-lime);
  font-weight:700;
  font-size:13px;
}
.agent-who b{font-weight:700}
.agent-who small{display:block;color:var(--muted);font-size:11.5px;line-height:1.2}

.gate{
  display:grid;
  place-items:center;
  padding:clamp(40px,8vw,90px) var(--gutter);
}
.gate-card{
  width:min(440px,100%);
  padding:clamp(26px,4vw,38px);
  border:1px solid var(--line);
  border-radius:var(--r-lg);
  background:var(--bg);
  box-shadow:var(--shadow-md);
}
.gate-card h1{margin:14px 0 8px;font-size:clamp(24px,4vw,30px);letter-spacing:-.03em}
.gate-card .muted{margin-bottom:22px;font-size:15px}

/* На узком экране длинная надпись на кнопке не должна распирать карточку */
@media (max-width:440px){
  .gate-card .btn-block{
    white-space:normal;
    height:auto;
    min-height:54px;
    padding-block:12px;
    line-height:1.3;
    text-align:center;
  }
}

@media (max-width:1040px){
  .agent-grid{grid-template-columns:1fr}
  .agent-side.is-hidden,
  .agent-main.is-hidden{display:none}
}

/* Телефон: в шапке панели оставляем только переключатель линии и выход */
@media (max-width:760px){
  .sup .agent-who{display:none}
  .sup .header-inner{gap:12px}
  .line-toggle{height:36px;padding:0 12px;font-size:13px;white-space:nowrap}
  .sup-page{padding-block:20px 40px}
  .sup-head{gap:12px;margin-bottom:16px}
  .agent-grid{gap:12px}
  .agent-side{gap:12px}
  .thread-tools{width:100%}
  .thread-tools .btn{flex:1 1 auto;justify-content:center}
  .qbar{padding:14px;gap:10px 18px}
  .qbar-stats{gap:14px}
  .qbar-stat b{font-size:16px}
}

/* Совсем узкий экран: в шапке остаются логотип, «поддержка», линия и иконки */
@media (max-width:560px){
  .sup .brand-name{display:none}
  .sup .brand{gap:6px}
  .sup #logout{gap:0;padding-inline:10px;font-size:0}
  .sup #logout [data-icon]{font-size:15px}
  .sup-head h1{font-size:26px}
}

@media (max-width:640px){
  .qbar-stats{gap:16px;width:100%;margin-left:0}
  .tcard{grid-template-columns:1fr}
  .tcard-side{grid-column:1;grid-row:auto;justify-content:flex-start}
  .msg{max-width:92%}
  .msgs{padding:16px;max-height:none}
  .composer{padding:12px 14px 14px}
  .thread-head{padding:14px}
  .sup-head .btn{width:100%}
  .sup-form-actions .btn{width:100%}
  .msg-shot{width:104px;height:78px}
}
