/**
 * Поддержка: список обращений, форма тикета и чат.
 * Опирается на переменные темы из styles.css (--bg, --panel, --lime, --text, --muted).
 */

.support-body {
  min-height: 100vh;
  background: #080808;
}

.support-shell {
  position: relative;
  z-index: 2;
  width: min(calc(100% - 28px), var(--container));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 116px 0 24px;
}

.support-header-inner { grid-template-columns: 1fr auto; align-items: center; }
.support-view:not(.chat) { width: min(100%, 880px); margin-inline: auto; }

.support-back {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.support-head { margin-bottom: 20px; }

.support-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: clamp(28px, 6vw, 40px);
  letter-spacing: -.02em;
}

.support-subtitle {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.support-card {
  padding: 24px;
  margin-bottom: 16px;
  border: 0;
  border-radius: 32px;
  background: #111111;
}

.support-card-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.support-card-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
}

.support-icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #202020;
  color: #aaa9a4;
  font-size: 18px;
  cursor: pointer;
  transition: transform .14s ease;
}
.support-icon-btn:active { transform: scale(.94); }
/* iconify-icon по умолчанию строчный и садится на базовую линию — из-за этого
   глиф смещался вверх относительно центра круглой кнопки */
.support-icon-btn iconify-icon { display: block; line-height: 1; }

.support-new-btn {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13px;
}

/* --- Список обращений --- */

.ticket-list { display: flex; flex-direction: column; gap: 8px; }

.ticket-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  min-height: 72px;
  border: 0;
  border-radius: 20px;
  background: #1a1a1a;
  color: inherit;
  text-decoration: none;
}

.ticket-row-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ticket-subject {
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ticket-meta { color: var(--muted); font-size: 12px; }

.ticket-row-side { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.ticket-unread {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--lime);
  color: #111;
  font-size: 11px;
  font-weight: 800;
}

.ticket-status {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.ticket-status--waiting { background: rgba(255, 176, 32, .16); color: #ffcb6b; }
.ticket-status--operator { background: rgba(214, 228, 74, .16); color: var(--lime); }
.ticket-status--closed { background: rgba(255, 255, 255, .06); color: #7d7d78; }

/* --- Форма обращения --- */

.support-form { display: flex; flex-direction: column; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { padding-left: 12px; color: #b2b2ac; font-size: 12px; font-weight: 650; }
.field-optional { color: #6f6f6a; font-weight: 500; }

.field-input {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 16px;
  background: var(--panel-light);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.field-input::placeholder { color: #666; }
.field-input:focus { background: var(--panel-light); box-shadow: none; }

.field-textarea { min-height: 130px; line-height: 1.55; resize: vertical; }

.field-select { position: relative; }
.field-select select { width: 100%; appearance: none; cursor: pointer; }

/* Тот же паттерн кастомного select, что используется в админке. */
.field-select.is-enhanced { z-index: 12; }
.field-select.is-enhanced:not(.is-open) { z-index: auto; }
.field-select-native {
  position: absolute;
  width: 1px !important;
  height: 1px;
  margin: -1px;
  padding: 0 !important;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.field-select-trigger {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 15px 0 16px;
  border: 0;
  border-radius: 16px;
  background: var(--panel-light);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.field-select-trigger span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.field-select-trigger iconify-icon {
  flex: 0 0 auto;
  color: var(--lime);
  font-size: 17px;
  transition: transform .2s ease;
}
.field-select.is-open .field-select-trigger iconify-icon { transform: rotate(180deg); }

.field-select-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  left: 0;
  display: grid;
  width: 100%;
  max-height: min(280px, 45dvh);
  gap: 3px;
  padding: 6px;
  overflow-y: auto;
  border: 0;
  border-radius: 19px;
  background: #202020;
  box-shadow: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-7px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}
.field-select.is-open .field-select-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.field-select.is-up .field-select-menu {
  top: auto;
  bottom: calc(100% + 8px);
  transform: translateY(7px);
}
.field-select.is-up.is-open .field-select-menu { transform: none; }
.field-select-menu button {
  min-height: 42px;
  padding: 10px 13px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: #a1a19b;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.field-select-menu button.is-selected {
  background: var(--lime);
  color: #111;
}
.field-select-menu button:focus-visible {
  outline: none;
  background: #2a2a2a;
  color: var(--text);
}
.field-select-menu button.is-selected:focus-visible {
  background: var(--lime);
  color: #111;
}
.field-select-menu button:disabled { cursor: not-allowed; opacity: .45; }

.field-hint { padding-left: 12px; color: var(--muted); font-size: 11px; }

.support-form-foot {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 4px;
}

.support-attach-btn {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: #1b1b1b;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.support-submit { min-height: 46px; padding: 0 22px; border-radius: 999px; font-size: 14px; cursor: pointer; }
.support-form.is-sending { opacity: .6; pointer-events: none; }

.support-form-note { margin: 12px 0 0; color: #6f6f6a; font-size: 11px; line-height: 1.6; }

/* --- Прикреплённые файлы --- */

.composer-files { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

.file-chip {
  position: relative;
  display: grid;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: #202020;
  color: var(--lime);
}
.file-chip.is-uploading { opacity: .55; }
.file-chip img { width: 100%; height: 100%; border-radius: 14px; object-fit: cover; }
.file-chip iconify-icon { color: var(--lime); font-size: 26px; }
.file-chip-name { display: none; }

.file-chip-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #111111;
  color: #b8b8b1;
  font-size: 16px;
  cursor: pointer;
}

/* --- Чат --- */

.support-view.chat {
  display: flex;
  width: min(100%, 1040px);
  flex-direction: column;
  height: calc(100dvh - 140px);
  min-height: 560px;
  margin-inline: auto;
  overflow: hidden;
  border: 0;
  border-radius: 28px;
  background: #141414;
}

.chat-head {
  display: flex;
  min-height: 78px;
  gap: 12px;
  align-items: center;
  padding: 13px 16px;
  border: 0;
  background: #171717;
}
.chat-head-main { flex: 1; min-width: 0; }
.chat-head-main strong {
  display: block;
  overflow: hidden;
  font-size: 15px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chat-head-meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }

.chat-status { padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, .07); font-size: 11px; font-weight: 700; }
.chat-status[data-status="waiting"] { background: rgba(255, 176, 32, .16); color: #ffcb6b; }
.chat-status[data-status="operator"] { background: rgba(214, 228, 74, .16); color: var(--lime); }
.chat-status[data-status="closed"] { color: #7d7d78; }

.chat-thread {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  gap: 10px;
  padding: 18px 22px;
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chat-thread::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Пузырь сжимается по содержимому: фиксированная ширина растягивала
   даже короткие реплики вроде «дай ссылки» на три четверти экрана */
.msg { display: flex; max-width: min(78%, 720px); }
.msg--client { align-self: flex-end; }
.msg--ai, .msg--operator { align-self: flex-start; }
.msg--pending { opacity: .55; }

.msg--system {
  align-self: center;
  width: auto;
  max-width: 88%;
  padding: 7px 14px;
  border-radius: 999px;
  background: #1b1b1b;
  color: #777771;
  font-size: 10px;
  text-align: center;
}

.msg-bubble {
  position: relative;
  min-width: 112px;   /* чтобы время в правом нижнем углу не наезжало на текст */
  padding: 13px 15px 22px;
  border-radius: 19px;
  background: #202020;
  color: #dfdfd8;
  font-size: 14px;
  line-height: 1.5;
}
.msg--client .msg-bubble { border-bottom-right-radius: 7px; background: var(--lime); color: #111; }
.msg--ai .msg-bubble { border-bottom-left-radius: 7px; background: #1c1d19; }
.msg--operator .msg-bubble { border-bottom-left-radius: 7px; background: #202020; }

.msg-author {
  display: block;
  margin-bottom: 3px;
  color: #a9a9a3;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.msg--ai .msg-author { color: var(--lime); }
.msg--operator .msg-author { color: #a9a9a3; }

.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }

.msg-time {
  position: absolute;
  right: 13px;
  bottom: 8px;
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0;
  font-size: 10px;
  opacity: .55;
}

.msg-files { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.msg-image {
  padding: 0;
  border: none;
  border-radius: 14px;
  background: none;
  cursor: zoom-in;
  overflow: hidden;
  line-height: 0;
}
.msg-image { cursor: zoom-in; }
.msg-image img { max-width: 220px; max-height: 240px; border-radius: 14px; object-fit: cover; }

.msg-video { position: relative; overflow: hidden; max-width: 260px; border-radius: 14px; line-height: 0; }
.msg-video video { display: block; width: 100%; max-height: 220px; border-radius: 14px; background: #000; }
/* Кнопка «развернуть» — поверх плеера, в стороне от его собственных кнопок */
.msg-video-expand {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  place-items: center;
  line-height: 0;
  opacity: .75;
  cursor: pointer;
  transition: opacity .2s, background-color .2s;
}
.msg-video-expand:hover { background: rgba(0, 0, 0, .8); opacity: 1; }
.msg-video-expand iconify-icon { font-size: 16px; }

.msg-file {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, .28);
  color: inherit;
  text-decoration: none;
}
.msg--client .msg-file { background: rgba(0, 0, 0, .12); }
.msg-file iconify-icon { font-size: 24px; }
.msg-file-info { display: flex; flex-direction: column; }
.msg-file-info strong { max-width: 170px; overflow: hidden; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.msg-file-info small { font-size: 10px; opacity: .6; }

.chat-loader, .chat-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 8px 18px;
  color: var(--muted);
  font-size: 12px;
}
.chat-typing { padding-top: 0; border: 0; background: #171717; }

.chat-loader .dot, .chat-typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  animation: support-bounce 1.2s infinite ease-in-out;
}
.chat-typing .dot:nth-child(2), .chat-loader .dot:nth-child(2) { animation-delay: .15s; }
.chat-typing .dot:nth-child(3), .chat-loader .dot:nth-child(3) { animation-delay: .3s; }
.chat-typing span:last-child { margin-left: 6px; }

@keyframes support-bounce {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.chat-rate {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border: 0;
  background: #171717;
  color: var(--muted);
  font-size: 13px;
}
.chat-rate-stars { display: flex; gap: 4px; }
.chat-rate-stars button {
  padding: 2px;
  border: none;
  background: none;
  color: #3a3a36;
  font-size: 20px;
  cursor: pointer;
  transition: color .15s ease, transform .15s ease;
}

/* --- Поле ввода --- */

.composer { flex: 0 0 auto; padding: 10px 12px 12px; border: 0; background: #171717; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }

.composer-input {
  flex: 1;
  max-height: 160px;
  min-width: 0;
  min-height: 48px;
  padding: 14px 16px;
  border: none;
  border-radius: 18px;
  background: #202020;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  outline: none;
  resize: none;
}
.composer-input::placeholder { color: #666; }
.composer-input:focus { background: #202020; box-shadow: none; }

.composer-attach { flex-shrink: 0; }

.composer-send {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--lime);
  color: #111;
  font-size: 20px;
  cursor: pointer;
  transition: transform .14s ease;
}
.composer-send:active { transform: scale(.96); }

/* --- Служебные слои --- */

.drop-hint {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(8, 8, 8, .82);
  backdrop-filter: blur(4px);
}
.drop-hint-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  padding: 42px 56px;
  border: 0;
  border-radius: 28px;
  background: #171717;
  color: var(--lime);
  font-size: 15px;
  font-weight: 700;
}
.drop-hint-inner iconify-icon { font-size: 48px; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(8, 8, 8, .92);
}
.lightbox img,
.lightbox video { max-width: 100%; max-height: 100%; border-radius: 16px; }
.lightbox video { background: #000; }
body.lightbox-open { overflow: hidden; }
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 0;
  border: none;
  background: none;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
}

.support-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 80;
  max-width: 90vw;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--lime);
  color: #111;
  font-size: 13px;
  font-weight: 700;
  transform: translateX(-50%);
}
.support-toast.is-error { background: #ff6b6b; color: #fff; }

.support-empty { padding: 48px 24px; text-align: center; }
.support-empty iconify-icon { color: var(--lime); font-size: 46px; }
.support-empty h1 { margin: 12px 0 8px; font-family: var(--font-display); font-size: 22px; }
.support-empty p { margin: 0; color: var(--muted); font-size: 14px; }
.support-empty a { color: var(--lime); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 720px) {
  body.support-chat-open { overflow: hidden; }
  .support-shell { width: min(calc(100% - 20px), var(--container)); padding: 80px 0 10px; }
  .support-header-inner { padding-left: 15px; }
  .support-back { padding-right: 10px; font-size: 11px; }
  .support-card { padding: 18px; border-radius: 24px; }
  .support-title { font-size: 27px; }
  .support-subtitle { font-size: 12px; line-height: 1.5; }
  .support-view.chat { height: calc(100dvh - 90px); min-height: 0; border-radius: 20px; }
  .chat-head { min-height: 72px; gap: 9px; padding: 10px; }
  .chat-head-main strong { font-size: 13px; }
  .chat-head-meta { gap: 5px; font-size: 9px; }
  .chat-status { padding: 3px 7px; font-size: 8px; }
  .chat-thread { gap: 7px; padding: 10px 11px; }
  .msg { max-width: min(90%, 600px); }
  .msg-bubble { padding: 9px 11px 19px; border-radius: 15px; font-size: 12px; line-height: 1.4; }
  .msg-author { margin-bottom: 3px; font-size: 8px; }
  .msg-time { right: 10px; bottom: 6px; font-size: 8px; }
  .msg--system { max-width: 84%; padding: 7px 10px; font-size: 9px; line-height: 1.35; }
  .msg-image img { max-width: 180px; max-height: 210px; }
  .msg-video { max-width: 210px; }
  .msg-video video { max-height: 190px; }
  .composer { padding: 7px max(8px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .composer-row { gap: 6px; }
  .composer-attach { width: 42px; height: 42px; flex: 0 0 42px; }
  .composer-input { min-height: 42px; padding: 12px 13px; font-size: 13px; }
  .composer-send { width: 44px; height: 44px; flex: 0 0 44px; }
  .composer-files { padding-left: 2px; }
  .file-chip { width: 52px; height: 52px; flex-basis: 52px; }
  .support-form-foot { flex-direction: column; align-items: stretch; }
  .support-submit { width: 100%; justify-content: center; }
}

@media (max-width: 390px) {
  .support-shell { width: min(calc(100% - 14px), var(--container)); }
  .chat-head .support-icon-btn { width: 36px; height: 36px; }
  .chat-head-main strong { font-size: 11px; }
  .chat-head-meta { font-size: 8px; }
  .msg { max-width: 92%; }
  .composer-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) 40px; gap: 5px; }
  .composer-attach { width: 38px; height: 38px; }
  .composer-input { width: 100%; min-height: 38px; padding: 10px 12px; font-size: 12px; }
  .composer-send { width: 40px; height: 40px; }
}

/* Атрибут hidden должен побеждать любой display у класса.
   Без этого правила скрытые слои (drag-drop, лайтбокс, полоса файлов) висят поверх страницы. */
[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------------------
   Поведение на сенсорных экранах.

   iOS Safari масштабирует страницу при фокусе на поле, если его шрифт меньше
   16px, — после ввода вернуть масштаб вручную уже нельзя. Поэтому на тач-устройствах
   поля получают ровно 16px. Двойной тап там же увеличивает вёрстку: touch-action
   это отключает, щипковый зум при этом остаётся и доступность не страдает.
   --------------------------------------------------------------------------- */
@media (pointer: coarse) {
  input,
  textarea,
  select { font-size: 16px !important; }
}

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { touch-action: manipulation; }
