/* ============================================================
   Tickets — модуль заявок (webmacter2)
   Цвета и переменные из style/main.css
   ============================================================ */

/* Кнопка .btn — используется в шаблонах плагина */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  background: var(--clr-primary, #5794ba);
  color: #fff;
  font-size: 0.82rem;
  font-weight: bold;
  border-radius: var(--radius-sm, 4px);
  text-decoration: none;
  transition: background 0.2s;
  white-space: nowrap;
  border: none;
  cursor: pointer;
}
.btn:hover {
  background: var(--clr-primary-dark, #367ead);
  color: #fff;
  text-decoration: none;
}

/* ── Обёртка страницы ──────────────────────────────────────── */
.tk-page {
  background: var(--clr-white, #fff);
  border: 1px solid var(--clr-border-light, #e0e8ed);
  border-radius: var(--radius-md, 6px);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  margin-bottom: 16px;
}

/* ── Шапка страницы ────────────────────────────────────────── */
.tk-page__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  border-left: 4px solid var(--clr-accent, #64ab35);
  padding: 12px 16px 10px;
  background: var(--clr-bg-light, #f4f8fb);
  border-bottom: 1px solid var(--clr-border-light, #e0e8ed);
}
.tk-page__back {
  display: block;
  flex-basis: 100%;
  color: var(--clr-primary, #5794ba);
  font-size: 0.82rem;
  text-decoration: none;
}
.tk-page__back::before { content: "← "; }
.tk-page__back:hover { text-decoration: underline; }

.tk-page__title {
  font-size: 1.25rem;
  font-weight: bold;
  margin: 0;
  line-height: 1.3;
  color: var(--clr-accent, #64ab35);
  flex: 1;
  min-width: 0;
}

.tk-page__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-basis: 100%;
  font-size: 0.8rem;
  color: var(--clr-text-light, #898989);
  border-top: 1px solid var(--clr-border-light, #e0e8ed);
  padding-top: 8px;
}
.tk-page__meta-item {}

.tk-page__body { padding: 0; }
.tk-page__denied {
  padding: 20px;
  color: var(--clr-text-light, #898989);
  font-size: 0.9rem;
}

/* ── Таблица заявок ────────────────────────────────────────── */
.tk-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tk-table th {
  padding: 10px 16px;
  background: var(--clr-bg-light, #f4f8fb);
  border-bottom: 1px solid var(--clr-border-light, #e0e8ed);
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--clr-text-muted, #a0a7ac);
}
.tk-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--clr-border-light, #e0e8ed);
  vertical-align: middle;
}
.tk-table tr:last-child td { border-bottom: none; }
.tk-table tr:hover td { background: var(--clr-bg-light, #f4f8fb); }
.tk-table__link { color: var(--clr-primary, #5794ba); font-weight: 600; text-decoration: none; }
.tk-table__link:hover { color: var(--clr-primary-dark, #367ead); text-decoration: underline; }
.tk-empty { text-align: center; color: var(--clr-text-muted, #a0a7ac); padding: 28px 16px; }
.tk-assigned-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 9px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #e7f4ec;
  color: #1f7a45;
  white-space: nowrap;
  vertical-align: middle;
}

/* ── Статусы ───────────────────────────────────────────────── */
.tk-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.tk-status--new         { background: #e8f0fd; color: #2563a8; }
.tk-status--in_progress { background: #fdf3da; color: #9a6c00; }
.tk-status--closed      { background: var(--clr-border-light, #e0e8ed); color: var(--clr-text-light, #898989); }

/* ── Вкладки «Активные / Архив» ───────────────────────────────────────── */
.tk-tabs {
  display: flex;
  gap: 4px;
  flex-basis: 100%;
  border-top: 1px solid var(--clr-border-light, #e0e8ed);
  padding-top: 8px;
}
.tk-tabs__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--clr-text-light, #898989);
  background: var(--clr-white, #fff);
  border: 1px solid var(--clr-border-light, #e0e8ed);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.tk-tabs__item:hover { background: var(--clr-bg-light, #f4f8fb); text-decoration: none; }
.tk-tabs__item--active,
.tk-tabs__item--active:hover {
  background: var(--clr-primary, #5794ba);
  border-color: var(--clr-primary, #5794ba);
  color: #fff;
}
.tk-tabs__count {
  font-size: 0.74rem;
  opacity: 0.85;
}

/* ── Переписка по заявке ───────────────────────────────────── */
.tk-thread { padding: 4px 0; }
.tk-msg {
  padding: 12px 20px;
  border-bottom: 1px solid var(--clr-border-light, #e0e8ed);
}
.tk-msg:last-child { border-bottom: none; }
.tk-msg--admin { background: var(--clr-bg-light, #f4f8fb); }
.tk-msg__head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
  font-size: 0.8rem;
}
.tk-msg__author { font-weight: 700; color: var(--clr-text, #5c5c5c); }
.tk-msg__role {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--clr-primary, #5794ba);
  background: rgba(87,148,186,.12);
  padding: 1px 8px;
  border-radius: 10px;
}
.tk-msg__date { color: var(--clr-text-muted, #a0a7ac); margin-left: auto; }
.tk-msg__text {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--clr-text, #5c5c5c);
}

/* ── Форма ответа и закрытие заявки ───────────────────────── */
.tk-reply-form {
  padding: 16px 20px;
  border-top: 1px solid var(--clr-border-light, #e0e8ed);
}
.tk-reply-form__footer { margin-top: 8px; }
.tk-close-form { padding: 0 20px 16px; }
.tk-close-btn {
  display: inline-block;
  padding: 6px 16px;
  background: none;
  color: #c0392b;
  font-size: 0.82rem;
  font-weight: bold;
  border: 1px solid #e3b2ac;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.tk-close-btn:hover { background: #fdecea; }

/* ── Уведомления ───────────────────────────────────────────── */
.tk-notice {
  margin: 16px 20px 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm, 4px);
  font-size: 0.88rem;
}
.tk-notice--ok  { background: #e8f7ee; color: #1f7a44; border: 1px solid #b9e6c9; }
.tk-notice--err { background: #fdecea; color: #a4322a; border: 1px solid #f3c3bd; }

/* ── Форма создания заявки ─────────────────────────────────── */
.tk-form { padding: 16px 20px 20px; }
.tk-form__row { margin-bottom: 14px; }
.tk-form__label {
  display: block;
  font-weight: bold;
  font-size: 0.85rem;
  color: var(--clr-text, #5c5c5c);
  margin-bottom: 5px;
}
.tk-form__req { color: #e74c3c; }
.tk-form__input { width: 100%; margin-top: 5px; }
.tk-form__footer { margin-top: 8px; }

/* ── Капча (штатный движок DLE: antibot / reCAPTCHA / hCaptcha / Turnstile / SmartCaptcha) ─ */
.tk-captcha__box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 5px;
}
.tk-captcha__box img {
  border: 1px solid var(--clr-border-light, #e0e8ed);
  border-radius: var(--radius-sm, 4px);
  display: block;
}
.tk-captcha__input { width: 160px; }

/* ── Вложения (чипсы в переписке) ──────────────────────────── */
.tk-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.tk-attach {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--clr-border-light, #e0e8ed);
  border-radius: var(--radius-sm, 4px);
  background: var(--clr-bg-light, #f4f8fb);
  font-size: 0.78rem;
  color: var(--clr-text, #5c5c5c);
  text-decoration: none;
  max-width: 220px;
}
.tk-attach:hover { background: #fff; border-color: var(--clr-primary, #5794ba); text-decoration: none; }
.tk-attach--image img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}
.tk-attach__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-attach__size { color: var(--clr-text-muted, #a0a7ac); flex-shrink: 0; }

/* ── Зона загрузки вложений (drag&drop), формы создания/ответа ─ */
.tk-mz {
  border: 1px solid var(--clr-border-light, #e0e8ed);
  border-radius: var(--radius-sm, 4px);
  background: var(--clr-bg-light, #f4f8fb);
  overflow: hidden;
  margin-top: 6px;
}
.tk-mz-drop {
  padding: 14px 16px;
  text-align: center;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  border-bottom: 1px solid var(--clr-border-light, #e0e8ed);
  font-size: 0.85rem;
}
.tk-mz-drop.tk-over { background: #e8f7ee; }
.tk-mz-icon { font-size: 22px; color: #b7bec2; display: block; margin-bottom: 4px; }
.tk-mz-hint { color: var(--clr-text-light, #898989); }
.tk-mz-hint a { color: var(--clr-primary, #5794ba); }
.tk-mz-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  min-height: 4px;
}
.tk-mc {
  position: relative;
  width: 96px;
  border: 1px solid var(--clr-border-light, #e0e8ed);
  border-radius: var(--radius-sm, 4px);
  overflow: hidden;
  background: #fff;
  flex-shrink: 0;
}
.tk-mc img { width: 96px; height: 70px; object-fit: cover; display: block; }
.tk-mc-file {
  width: 96px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #b7bec2;
}
.tk-mc-foot {
  padding: 3px 6px;
  font-size: 10px;
  color: var(--clr-text-light, #898989);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid var(--clr-border-light, #e0e8ed);
}
.tk-mc-actions {
  position: absolute;
  inset: 0 0 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.45);
  opacity: 0;
  transition: opacity .14s;
}
.tk-mc:hover .tk-mc-actions { opacity: 1; }
.tk-mc-actions button {
  background: rgba(255,255,255,.92);
  border: none;
  border-radius: 3px;
  padding: 5px 8px;
  cursor: pointer;
  color: #c0392b;
}
.tk-mc-prog { position: absolute; bottom: 22px; left: 0; height: 3px; background: var(--clr-primary, #5794ba); width: 0; transition: width .15s; }
.tk-mc-uploading { opacity: .6; }

/* ── Кнопки в шапке (Создать заявку / Правила) ─────────────── */
.tk-page__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tk-btn--rules {
  gap: 6px;
  background: var(--clr-accent, #64ab35);
  color: #fff;
}
.tk-btn--rules:hover {
  background: var(--clr-accent-dark, #55922d);
  color: #fff;
}
.tk-btn--rules .fa { font-size: 0.95em; }

/* ── Всплывающее окно «Правила» ────────────────────────────── */
.tk-modal[hidden] { display: none; }
.tk-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.tk-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 32, 43, .55);
}
.tk-modal__dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: var(--clr-white, #fff);
  border-radius: var(--radius-md, 6px);
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
  overflow: hidden;
}
.tk-modal__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--clr-border-light, #e0e8ed);
  background: var(--clr-bg-light, #f4f8fb);
}
.tk-modal__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--clr-accent, #64ab35);
  flex: 1;
  min-width: 0;
}
.tk-modal__close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  line-height: 1;
  font-size: 1.5rem;
  color: var(--clr-text-light, #898989);
  background: none;
  border: none;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tk-modal__close:hover { background: var(--clr-border-light, #e0e8ed); color: var(--clr-text, #5c5c5c); }
.tk-modal__body {
  padding: 18px 20px;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--clr-text, #5c5c5c);
}
.tk-modal__body p { margin: 0 0 10px; }
.tk-modal__body ul,
.tk-modal__body ol { margin: 0 0 10px; padding-left: 22px; }
.tk-modal__body li { margin-bottom: 4px; }
.tk-modal__body a { color: var(--clr-primary, #5794ba); }
.tk-modal__body table { border-collapse: collapse; width: 100%; margin: 0 0 10px; }
.tk-modal__body th,
.tk-modal__body td { border: 1px solid var(--clr-border-light, #e0e8ed); padding: 6px 10px; text-align: left; }

/* ── Оценка качества (CSAT) ─────────────────────────────────── */
.tk-rating {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--clr-border-light, #e0e8ed);
  border-radius: var(--radius-sm, 4px);
  background: var(--clr-bg-light, #f4f8fb);
}
.tk-rating--done { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tk-rating__label { font-weight: 600; color: var(--clr-text, #5c5c5c); }
.tk-rating .tk-stars { font-size: 1.15rem; }
.tk-rating__comment {
  flex-basis: 100%;
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--clr-text-light, #898989);
  font-style: italic;
}
.tk-rating__title { font-weight: 600; margin-bottom: 10px; color: var(--clr-text, #5c5c5c); }
.tk-rating--form .tk-rating__select { max-width: 18em; margin-bottom: 10px; }
.tk-rating__comment-input {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid var(--clr-border, #c6d4de);
  border-radius: var(--radius-sm, 4px);
  font: inherit;
  box-sizing: border-box;
  resize: vertical;
}
.tk-rating__btn { align-self: flex-start; }

/* ── Поиск по заявкам ───────────────────────────────────────── */
.tk-search { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.tk-search__input {
  flex: 1 1 220px;
  padding: 8px 12px;
  border: 1px solid var(--clr-border, #c6d4de);
  border-radius: var(--radius-sm, 4px);
  font: inherit;
  box-sizing: border-box;
}
.tk-search__btn { flex-shrink: 0; }
.tk-search__clear { font-size: 0.85rem; color: var(--clr-text-light, #898989); text-decoration: underline; }

/* ============================================================
   Адаптив — телефоны/планшеты
   ============================================================ */
@media (max-width: 640px) {
  /* Таблица заявок → карточки (строка = карточка, ячейка = «подпись: значение») */
  .tk-table thead { display: none; }
  .tk-table,
  .tk-table tbody,
  .tk-table tr,
  .tk-table td { display: block; width: 100%; }
  .tk-table tr {
    padding: 10px 16px;
    border-bottom: 1px solid var(--clr-border-light, #e0e8ed);
  }
  .tk-table tr:hover td { background: none; }
  .tk-table td {
    border: none;
    padding: 3px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }
  .tk-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--clr-text-muted, #a0a7ac);
  }
  /* Заголовок заявки — крупно, на всю ширину, без подписи */
  .tk-table td[data-label="Заголовок"] {
    display: block;
    font-size: 1rem;
    margin-bottom: 4px;
  }
  .tk-table td[data-label="Заголовок"]::before { display: none; }
  .tk-empty { display: block; text-align: center; }
  .tk-empty::before { display: none; }

  /* Переписка/формы — компактнее по краям */
  .tk-msg,
  .tk-reply-form,
  .tk-close-form,
  .tk-form,
  .tk-notice { padding-left: 14px; padding-right: 14px; }
  .tk-notice { margin-left: 14px; margin-right: 14px; }

  /* Элементы форм на всю ширину */
  .tk-captcha__input { width: 100%; }
  .tk-search__input { flex-basis: 100%; }
  .tk-page__actions { width: 100%; }
  .tk-page__actions .btn { flex: 1; justify-content: center; }
}