/*
 * Tickets admin: settings panels, group editor, member picker and toasts.
 *
 * The rest of the admin area styles inline. These screens have enough repeated
 * structure (panels, cards, chips, a data table, toasts) that inline styles made
 * them inconsistent and hard to adjust, so they live here instead.
 */

:root {
  --tk-gold: #c9a961;
  --tk-gold-soft: rgba(201, 169, 97, 0.16);
  --tk-gold-line: rgba(201, 169, 97, 0.34);
  --tk-surface: rgba(255, 255, 255, 0.032);
  --tk-surface-raised: rgba(255, 255, 255, 0.055);
  --tk-line: rgba(255, 255, 255, 0.1);
  --tk-line-soft: rgba(255, 255, 255, 0.06);
  --tk-text: #f2f2f2;
  --tk-text-dim: rgba(255, 255, 255, 0.62);
  --tk-text-faint: rgba(255, 255, 255, 0.4);
  --tk-ok: #10b981;
  --tk-err: #ef4444;
  --tk-radius: 12px;
}

/* ============================ Settings panels ============================ */

.tk-panel {
  border: 1px solid var(--tk-line);
  border-radius: var(--tk-radius);
  background: var(--tk-surface);
  padding: 24px;
  margin-bottom: 20px;
}

.tk-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.tk-panel__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--tk-text);
  margin: 0;
  letter-spacing: 0.2px;
}

.tk-panel__hint {
  font-size: 13px;
  color: var(--tk-text-dim);
  line-height: 1.6;
  margin: 0 0 20px 0;
  max-width: 78ch;
}

/* ============================ Form furniture ============================ */

.tk-field { margin-bottom: 18px; }

.tk-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--tk-text-faint);
  margin-bottom: 8px;
}

.tk-input,
.tk-textarea {
  width: 100%;
  max-width: 460px;
  padding: 11px 14px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid var(--tk-line);
  border-radius: 9px;
  color: var(--tk-text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.tk-textarea {
  max-width: 640px;
  min-height: 110px;
  resize: vertical;
  line-height: 1.6;
}

.tk-input:focus,
.tk-textarea:focus {
  outline: none;
  border-color: var(--tk-gold-line);
  box-shadow: 0 0 0 3px rgba(201, 169, 97, 0.12);
}

.tk-input::placeholder,
.tk-textarea::placeholder { color: rgba(255, 255, 255, 0.28); }

.tk-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ============================ Buttons ============================ */

.tk-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.tk-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.tk-btn:not(:disabled):hover { filter: brightness(1.12); }

.tk-btn--primary { background: var(--tk-gold); color: #10100c; }
.tk-btn--ghost {
  background: var(--tk-surface-raised);
  color: var(--tk-text);
  border-color: var(--tk-line);
}
.tk-btn--danger {
  background: rgba(239, 68, 68, 0.13);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.5);
}
.tk-btn--sm { padding: 6px 13px; font-size: 12px; }

/* ============================ Group cards ============================ */

.tk-group-list { display: flex; flex-direction: column; gap: 12px; }

.tk-group-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border: 1px solid var(--tk-line);
  border-radius: var(--tk-radius);
  background: rgba(0, 0, 0, 0.26);
  flex-wrap: wrap;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.tk-group-card:hover {
  border-color: var(--tk-gold-line);
  background: rgba(0, 0, 0, 0.36);
}

.tk-group-card__main { min-width: 0; flex: 1 1 320px; }

.tk-group-card__name {
  font-size: 15px;
  font-weight: 600;
  color: var(--tk-text);
  margin-bottom: 8px;
}

.tk-group-card__cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tk-group-card__meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--tk-text-faint);
}

.tk-group-card__meta strong { color: var(--tk-text-dim); font-weight: 600; }

.tk-group-card__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================ Chips ============================ */

.tk-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--tk-gold-soft);
  color: var(--tk-gold);
  border: 1px solid var(--tk-gold-line);
  white-space: nowrap;
}

.tk-chip--muted {
  background: rgba(255, 255, 255, 0.05);
  color: var(--tk-text-faint);
  border-color: var(--tk-line);
}

/* Category toggles: a checkbox styled as a selectable pill. */
.tk-toggle-grid { display: flex; flex-wrap: wrap; gap: 10px; }

.tk-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border: 1px solid var(--tk-line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 13px;
  color: var(--tk-text-dim);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.tk-toggle:hover { border-color: rgba(255, 255, 255, 0.22); color: var(--tk-text); }

.tk-toggle input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--tk-gold); margin: 0; }

.tk-toggle:has(input:checked) {
  background: var(--tk-gold-soft);
  border-color: var(--tk-gold-line);
  color: var(--tk-gold);
  font-weight: 600;
}

/* ============================ Back bar ============================ */

.tk-backbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--tk-line-soft);
}

.tk-backbar__title { font-size: 17px; font-weight: 600; margin: 0; color: var(--tk-text); }

/* ============================ Member picker ============================ */

.tk-members-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tk-table-wrap {
  border: 1px solid var(--tk-line);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.24);
}

.tk-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.tk-table thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--tk-text-faint);
  background: rgba(255, 255, 255, 0.028);
  border-bottom: 1px solid var(--tk-line);
  white-space: nowrap;
}

.tk-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--tk-line-soft);
  color: var(--tk-text-dim);
  vertical-align: middle;
}

.tk-table tbody tr:last-child td { border-bottom: none; }
.tk-table tbody tr { transition: background 0.12s ease; }
.tk-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.tk-table tbody tr.is-member { background: rgba(201, 169, 97, 0.06); }
.tk-table tbody tr.is-member:hover { background: rgba(201, 169, 97, 0.1); }

.tk-table__user { display: flex; align-items: center; gap: 10px; min-width: 0; }

.tk-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--tk-gold-soft);
  color: var(--tk-gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

.tk-table__name { color: var(--tk-text); font-weight: 600; }
.tk-cb { width: 17px; height: 17px; cursor: pointer; accent-color: var(--tk-gold); }

.tk-pager {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.tk-pager__info { font-size: 12px; color: var(--tk-text-faint); }
.tk-pager__spacer { flex: 1 1 auto; }

.tk-empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--tk-text-faint);
  font-size: 13px;
}

/* ============================ Category rows ============================ */

.tk-cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid var(--tk-line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.26);
  flex-wrap: wrap;
  transition: border-color 0.15s ease;
}

.tk-cat-row:hover { border-color: rgba(255, 255, 255, 0.18); }
.tk-cat-row__main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.tk-cat-row__name { font-size: 14px; font-weight: 600; color: var(--tk-text); }

/* ============================ Toasts ============================ */

.tk-toasts {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top, 0px));
  right: 18px;
  z-index: 13000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 36px));
}

.tk-toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border-radius: 10px;
  background: #16160f;
  border: 1px solid var(--tk-line);
  border-left: 3px solid var(--tk-text-faint);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
  color: var(--tk-text);
  font-size: 13.5px;
  line-height: 1.55;
  pointer-events: auto;
  animation: tk-toast-in 0.22s ease-out;
}

.tk-toast--out { animation: tk-toast-out 0.18s ease-in forwards; }
.tk-toast--success { border-left-color: var(--tk-ok); }
.tk-toast--error { border-left-color: var(--tk-err); }
.tk-toast--info { border-left-color: var(--tk-gold); }

.tk-toast__icon { font-size: 15px; line-height: 1.4; flex-shrink: 0; }
.tk-toast--success .tk-toast__icon { color: var(--tk-ok); }
.tk-toast--error .tk-toast__icon { color: var(--tk-err); }
.tk-toast--info .tk-toast__icon { color: var(--tk-gold); }

.tk-toast__body { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.tk-toast__title { font-weight: 600; margin-bottom: 2px; }
.tk-toast__detail { color: var(--tk-text-dim); font-size: 12.5px; }

.tk-toast__close {
  background: transparent;
  border: none;
  color: var(--tk-text-faint);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  flex-shrink: 0;
}

.tk-toast__close:hover { color: var(--tk-text); }

@keyframes tk-toast-in {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes tk-toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(14px); }
}

@media (prefers-reduced-motion: reduce) {
  .tk-toast, .tk-toast--out { animation: none; }
}

/* ============================ Inline save note ============================ */

.tk-save-note {
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tk-save-note--ok { color: var(--tk-ok); }
.tk-save-note--err { color: var(--tk-err); }

/* ============================ Narrow screens ============================ */

@media (max-width: 720px) {
  .tk-panel { padding: 18px 16px; }
  .tk-group-card, .tk-cat-row { flex-direction: column; align-items: stretch; }
  .tk-group-card__actions, .tk-cat-row .tk-actions { justify-content: flex-start; }
  .tk-input, .tk-textarea { max-width: 100%; }
  .tk-toasts { left: 12px; right: 12px; max-width: none; }
  .tk-table thead { display: none; }
  .tk-table tbody td { display: block; border-bottom: none; padding: 5px 14px; }
  .tk-table tbody tr {
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid var(--tk-line-soft);
  }
}
