/* admin.css — all styles for the Yed Town backoffice SPA (login page + app shell + views).
   Strict CSP build: this file is the only stylesheet; no inline styles anywhere. */

:root {
  --bg: #0b0f17;
  --panel: #121826;
  --panel-2: #182134;
  --panel-3: #1f2a40;
  --border: #232e45;
  --text: #e6ebf5;
  --muted: #8b96ad;
  --faint: #5a6579;
  --blue: #4d8dff;
  --amber: #f5a524;
  --green: #2ecc8f;
  --red: #f0506e;
  --gray: #6b7689;
  --purple: #9b6dff;
  --radius: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Consolas, 'Liberation Mono', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 700; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }

::selection { background: rgba(77, 141, 255, .35); }

/* ---------- App shell ---------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: none;
  border-right: 1px solid var(--border);
  background: #0d121d;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 18px 20px 14px; }
.brand-mark {
  width: 36px; height: 36px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #fff; font-weight: 800; font-size: 14px; letter-spacing: .02em;
}
.brand-text h1 { font-size: 15px; line-height: 1.2; }
.brand-text p { margin: 0; font-size: 11.5px; color: var(--faint); }

.nav { flex: 1; padding-bottom: 12px; }
.nav-sec {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--faint); padding: 16px 22px 5px; font-weight: 700;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  margin: 2px 10px; padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted); font-weight: 500; text-decoration: none;
}
.nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.nav a.active { color: #fff; background: rgba(77, 141, 255, .14); }
.nav a.active .ni { color: var(--blue); }
.ni { width: 18px; height: 18px; flex: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 58px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 23, .85);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 16px; font-weight: 600; }
.user-chip { display: flex; align-items: center; gap: 12px; }
.user-chip .user-name { font-weight: 600; font-size: 13.5px; }

#view { flex: 1; padding: 24px 26px 48px; width: 100%; max-width: 1440px; margin: 0 auto; }

/* ---------- Cards / layout ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  min-width: 0;
}
.card-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin: 0 0 12px; font-weight: 700;
}

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 0 0 16px;
}
.page-head h2 { font-size: 20px; }
.page-head .head-actions { display: flex; gap: 10px; align-items: center; }

.back-link { color: var(--muted); font-size: 13px; display: inline-block; margin-bottom: 12px; }
.back-link:hover { color: var(--text); text-decoration: none; }

.detail-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px; align-items: start;
}

.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 7px 12px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }

/* ---------- Dashboard ---------- */

.stats-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-card { margin-bottom: 0; padding: 15px 18px; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.15; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.c-blue { color: #7cacff; }
.c-amber { color: #ffc45e; }
.c-green { color: #57e0ac; }
.c-red { color: #ff7d96; }

.dash-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; }
.dash-col { min-width: 0; }

.chart-canvas { display: block; width: 100%; height: 232px; }
.donut-canvas { display: block; width: 100%; height: 185px; }

.legend { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend-item .count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch.cat-bug { background: var(--red); }
.swatch.cat-player { background: var(--amber); }
.swatch.cat-feedback { background: var(--green); }
.swatch.cat-question { background: var(--blue); }

.server-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.server-count { font-size: 24px; font-weight: 700; }
.server-meta { font-size: 12.5px; color: var(--muted); }

/* ---------- Pills / dots ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.st-open { background: rgba(77, 141, 255, .15); color: #7cacff; }
.st-in_progress { background: rgba(245, 165, 36, .15); color: #ffc45e; }
.st-resolved { background: rgba(46, 204, 143, .15); color: #57e0ac; }
.st-rejected { background: rgba(240, 80, 110, .15); color: #ff7d96; }
.st-closed { background: rgba(107, 118, 137, .2); color: #a4aec2; }

.pr-low { background: rgba(107, 118, 137, .2); color: #a4aec2; }
.pr-normal { background: rgba(77, 141, 255, .15); color: #7cacff; }
.pr-high { background: rgba(245, 165, 36, .15); color: #ffc45e; }
.pr-urgent { background: rgba(240, 80, 110, .2); color: #ff7d96; }

.role-owner { background: rgba(155, 109, 255, .16); color: #c2a4ff; }
.role-admin { background: rgba(77, 141, 255, .15); color: #7cacff; }
.role-moderator { background: rgba(245, 165, 36, .15); color: #ffc45e; }
.role-viewer { background: rgba(107, 118, 137, .2); color: #a4aec2; }

.pill-on { background: rgba(46, 204, 143, .15); color: #57e0ac; }
.pill-off { background: rgba(107, 118, 137, .2); color: #a4aec2; }
.pill-warn { background: rgba(245, 165, 36, .15); color: #ffc45e; }
.pill-flag { background: rgba(240, 80, 110, .18); color: #ff8ba1; }
.pill-internal { background: rgba(245, 165, 36, .18); color: #ffc45e; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.online { background: var(--green); }
.dot.offline { background: var(--gray); }
.dot.stale { background: var(--red); }
.dot.unread { background: var(--blue); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); font-weight: 700; padding: 6px 12px 8px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid rgba(35, 46, 69, .55); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(24, 33, 52, .6); }
td.num { font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 600; }
.cell-sub { display: flex; align-items: center; gap: 8px; }

.details-cell {
  max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: 11.5px; color: var(--muted); cursor: pointer;
}
.details-cell.open { white-space: pre-wrap; word-break: break-all; color: var(--text); }

/* ---------- Filters / pager ---------- */

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input[type='search'], .filters input[type='text'] { width: auto; min-width: 150px; }
.filters .grow { flex: 1; min-width: 200px; }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 12px 12px 2px; }
.pager-info { margin-right: auto; color: var(--muted); font-size: 12.5px; }
.pager-page { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ---------- Forms / buttons ---------- */

input, select, textarea {
  background: #0e1420;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 11px;
  border-radius: 8px;
  font: inherit;
  width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(77, 141, 255, .18);
}
textarea { resize: vertical; min-height: 80px; }
input[type='checkbox'] { width: auto; accent-color: var(--blue); margin: 0; }

.field { margin-bottom: 14px; min-width: 0; }
.field label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 160px; }
.form-hint { font-size: 12px; color: var(--faint); margin-top: 5px; }
.form-error {
  background: rgba(240, 80, 110, .1); border: 1px solid rgba(240, 80, 110, .3);
  color: #ff9db0; padding: 9px 13px; border-radius: 8px; margin-bottom: 12px; font-size: 13px;
}
.check-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 15px; border-radius: 8px;
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-3); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(77, 141, 255, .25); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--blue); border-color: transparent; color: #fff; }
.btn-primary:hover { background: #3d7bed; }
.btn-danger {
  background: rgba(240, 80, 110, .13); border-color: rgba(240, 80, 110, .35); color: #ff8ba1;
}
.btn-danger:hover { background: rgba(240, 80, 110, .22); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Report thread ---------- */

.thread { display: flex; flex-direction: column; }
.msg {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel-2); padding: 10px 14px; margin-bottom: 10px;
  max-width: 88%;
}
.msg.player { margin-right: auto; }
.msg.staff { margin-left: auto; background: rgba(77, 141, 255, .1); border-color: rgba(77, 141, 255, .28); }
.msg.internal { background: rgba(245, 165, 36, .08); border-color: rgba(245, 165, 36, .32); }
.msg.system {
  max-width: 100%; background: transparent; border-style: dashed;
  text-align: center; color: var(--muted); font-size: 12.5px; padding: 6px 12px;
}
.msg-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 5px; flex-wrap: wrap; }
.msg-head .msg-sender { font-weight: 700; color: var(--text); }
.msg.system .msg-head { justify-content: center; margin-bottom: 2px; }
.msg-body { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; }

.reply-box { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 6px; }
.reply-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Misc components ---------- */

.error-box {
  background: rgba(240, 80, 110, .1); border: 1px solid rgba(240, 80, 110, .3);
  color: #ff9db0; padding: 11px 15px; border-radius: 8px; margin-bottom: 14px;
}
.banner-warn {
  background: rgba(245, 165, 36, .1); border: 1px solid rgba(245, 165, 36, .35);
  color: #ffd08a; padding: 12px 16px; border-radius: 10px; margin-bottom: 16px;
}
.empty { color: var(--muted); text-align: center; padding: 34px 12px; font-size: 13.5px; }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--blue);
  animation: yt-spin .8s linear infinite;
  margin: 34px auto;
}
@keyframes yt-spin { to { transform: rotate(360deg); } }

.toast-wrap {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  background: #1c2536; border: 1px solid var(--border); border-left: 3px solid var(--blue);
  color: var(--text); padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  max-width: 380px; font-size: 13.5px;
  animation: yt-toast-in .18s ease-out;
  transition: opacity .25s ease;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.gone { opacity: 0; }
@keyframes yt-toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.qr-box { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; margin-top: 14px; }
.qr-box img { width: 176px; height: 176px; border-radius: 10px; background: #fff; padding: 8px; flex: none; }
.qr-steps { flex: 1; min-width: 230px; }
.secret-box {
  font-family: var(--mono); font-size: 13px; letter-spacing: .05em;
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 8px; word-break: break-all;
  user-select: all; margin: 8px 0 14px;
}

/* ---------- Login page ---------- */

.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background: radial-gradient(1100px 560px at 70% -10%, #17233c 0%, var(--bg) 58%);
}
.login-card {
  width: 100%; max-width: 384px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px 30px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .brand-mark { width: 44px; height: 44px; font-size: 16px; margin-bottom: 10px; }
.login-brand h1 { font-size: 19px; }
.login-brand p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.login-card .btn { margin-top: 4px; }
.login-card .btn + .btn { margin-top: 10px; }

/* ---------- Responsive ---------- */

@media (max-width: 1250px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1150px) {
  .dash-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .sidebar { width: 64px; }
  .brand { justify-content: center; padding: 16px 8px 10px; }
  .brand-text, .nav-label, .nav-sec { display: none; }
  .nav a { justify-content: center; padding: 10px 8px; margin: 2px 8px; }
  #view { padding: 18px 16px 40px; }
  .topbar { padding: 0 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- message links & media attachments --- */
.msg-link { color: var(--accent, #4d8dff); word-break: break-all; text-decoration: underline; text-underline-offset: 2px; }
.msg-attachment { margin-top: 8px; }
.msg-image { display: block; max-height: 220px; max-width: 100%; border-radius: 8px; cursor: pointer; border: 1px solid var(--line, rgba(255,255,255,0.08)); }
.msg-image.expanded { max-height: none; width: 100%; }
.msg-video {
  display: block; max-height: 260px; max-width: 100%;
  border-radius: 8px; background: #000;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.08));
}
.hidden-file-input { display: none; }

/* --- forgot-password / reset flow + email section --- */
.link-btn {
  background: none; border: none; padding: 0;
  color: var(--blue); font: inherit; font-size: 13px; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.login-alt { text-align: center; margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.form-info {
  background: rgba(46, 204, 143, .1); border: 1px solid rgba(46, 204, 143, .3);
  color: #7fe6bd; padding: 11px 15px; border-radius: 8px; margin-bottom: 14px; font-size: 13px;
}
a.btn, a.btn:hover { text-decoration: none; }
.email-current {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px; font-size: 13.5px;
}

/* --- media lightbox --- */
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(6, 9, 15, 0.88); display: flex; align-items: center; justify-content: center; }
.lightbox-img { max-width: 96vw; max-height: 96vh; object-fit: contain; border-radius: 6px; box-shadow: 0 12px 48px rgba(0,0,0,0.6); }
.lightbox-close { position: absolute; top: 16px; right: 20px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.25); background: rgba(0,0,0,0.45); color: #fff; font-size: 17px; cursor: pointer; }
.lightbox-close:hover { background: rgba(255,255,255,0.15); }

/* --- email verification --- */
.pill-ok { background: rgba(46, 204, 143, .15); color: #5feba8; }
.email-pending { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; font-size: 13.5px; }
.staff-email { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12px; }
