/* COVTV web: shared styles for the user portal and the admin back-office. */
:root {
  --bg: #060a18;
  --bg-2: #0a1126;
  --surface: #0f1832;
  --surface-2: #142043;
  --border: #22315e;
  --border-strong: #31447f;
  --text: #e8eeff;
  --muted: #94a1cc;
  --faint: #66739e;
  --cyan: #22e5ff;
  --cyan-soft: rgba(34, 229, 255, 0.14);
  --violet: #9b6bff;
  --violet-soft: rgba(155, 107, 255, 0.16);
  --success: #2fe39b;
  --warn: #ffb648;
  --danger: #ff5577;
  --radius: 14px;
  --radius-sm: 9px;
  --glow: 0 0 0 2px var(--cyan), 0 0 22px rgba(34, 229, 255, 0.45);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Exo 2', 'Inter', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(155, 107, 255, 0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(34, 229, 255, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.01em; margin: 0; line-height: 1.2; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--cyan); }
code, .mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-14 { margin-top: 14px; }
.mb-6 { margin-bottom: 6px; }
.mb-10 { margin-bottom: 10px; }
.minw-0 { min-width: 0; }
.minw-220 { min-width: 220px; }
.w-80 { width: 80px; }
.narrow { max-width: 420px; }
.row-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 0 10px rgba(34, 229, 255, 0.5)); }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; letter-spacing: 0.12em; }
.brand-name span { color: var(--cyan); }
.brand-tag { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted); }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(6, 10, 24, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.container { width: 100%; max-width: 980px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 32px) 60px; }
.center-screen { min-height: calc(100vh - 140px); display: grid; place-items: center; padding: 32px 16px; }
.footer { text-align: center; color: var(--faint); font-size: 0.8rem; padding: 24px 16px 32px; }

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, rgba(20, 32, 67, 0.75), rgba(15, 24, 50, 0.75));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.login-card { width: 100%; max-width: 420px; position: relative; overflow: hidden; }
.login-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
}

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: 0.86rem; margin-bottom: 6px; color: #cdd6f6; }
.field + .field { margin-top: 14px; }
.hint { font-size: 0.8rem; color: var(--faint); margin-top: 5px; }
input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 90px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-soft);
}
input.big { font-size: 1.15rem; letter-spacing: 0.08em; font-family: ui-monospace, Menlo, Consolas, monospace; }
input[type='checkbox'] { width: 18px; height: 18px; accent-color: var(--cyan); vertical-align: middle; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; cursor: pointer; }
.form-error { color: var(--danger); font-size: 0.88rem; min-height: 1.2em; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-2 .field + .field { margin-top: 0; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: 600 0.92rem/1.2 var(--font);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--cyan); }
.btn:focus-visible { outline: none; box-shadow: var(--glow); transform: scale(1.03); }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--cyan), #3aa8ff);
  border-color: transparent; color: #031022;
  box-shadow: 0 6px 22px rgba(34, 229, 255, 0.28);
}
.btn-primary:hover { box-shadow: 0 6px 28px rgba(34, 229, 255, 0.45); border-color: transparent; }
.btn-violet { background: var(--violet-soft); border-color: rgba(155, 107, 255, 0.5); }
.btn-violet:hover { border-color: var(--violet); }
.btn-danger { background: rgba(255, 85, 119, 0.12); border-color: rgba(255, 85, 119, 0.45); color: #ffc2cf; }
.btn-danger:hover { border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn-sm { padding: 6px 11px; font-size: 0.82rem; }
.btn-block { width: 100%; padding: 12px 18px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  border: 1px solid currentColor;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-active { color: var(--success); background: rgba(47, 227, 155, 0.1); }
.badge-trial { color: var(--cyan); background: var(--cyan-soft); }
.badge-expired { color: var(--warn); background: rgba(255, 182, 72, 0.1); }
.badge-banned { color: var(--danger); background: rgba(255, 85, 119, 0.1); }
.badge-muted { color: var(--muted); background: transparent; }
.badge-violet { color: var(--violet); background: var(--violet-soft); }

/* ---------- lists & tables ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(10, 17, 38, 0.6);
}
.list-item + .list-item { margin-top: 10px; }
.list-item .title { font-weight: 600; }
.list-item .meta { font-size: 0.83rem; color: var(--muted); word-break: break-all; }
.type-chip {
  flex: none; width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center;
  font: 800 0.72rem var(--font-display); letter-spacing: 0.06em;
  background: var(--violet-soft); color: #cdb8ff; border: 1px solid rgba(155, 107, 255, 0.4);
}
.type-chip.m3u { background: var(--cyan-soft); color: var(--cyan); border-color: rgba(34, 229, 255, 0.4); }
.empty { text-align: center; padding: 30px 16px; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); background: rgba(10, 17, 38, 0.7); font-weight: 700; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover, tbody tr.clickable:focus-visible { background: rgba(34, 229, 255, 0.06); outline: none; }
tbody tr.clickable:focus-visible { box-shadow: inset 3px 0 0 var(--cyan); }
td.wrap { white-space: normal; }

/* ---------- key/value ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

/* ---------- status panel (portal) ---------- */
.status-panel { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.status-ring {
  width: 86px; height: 86px; border-radius: 50%; flex: none;
  display: grid; place-items: center; text-align: center;
  border: 2px solid currentColor;
  box-shadow: 0 0 26px -6px currentColor, inset 0 0 20px -8px currentColor;
}
.status-ring strong { display: block; font: 800 1.6rem/1 var(--font-display); }
.status-ring small { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em; }
.status-ring.active { color: var(--success); }
.status-ring.trial { color: var(--cyan); }
.status-ring.expired { color: var(--warn); }
.status-ring.banned { color: var(--danger); }
.device-id { font: 600 1.05rem ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.06em; }

.pay-placeholder {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px;
}
.pay-placeholder .btn { opacity: 0.55; }

/* ---------- stats (admin) ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.stat {
  padding: 16px 18px; border-radius: var(--radius-sm);
  background: rgba(10, 17, 38, 0.65); border: 1px solid var(--border);
}
.stat .label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.stat .value { font: 800 1.9rem/1.2 var(--font-display); margin-top: 4px; }
.stat.cyan .value { color: var(--cyan); }
.stat.violet .value { color: var(--violet); }
.stat.success .value { color: var(--success); }
.stat.warn .value { color: var(--warn); }
.stat.danger .value { color: var(--danger); }

/* ---------- admin shell ---------- */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 63px); }
.sidebar {
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  background: rgba(8, 13, 30, 0.6);
}
.nav { list-style: none; margin: 0; padding: 0; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 4px;
  border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.nav a:focus-visible { outline: none; box-shadow: var(--glow); color: var(--text); }
.nav a[aria-current='page'] {
  color: var(--text); background: linear-gradient(90deg, var(--cyan-soft), transparent);
  border-color: rgba(34, 229, 255, 0.3);
}
.nav a[aria-current='page'] .dot { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.nav .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.main { padding: 28px clamp(16px, 3vw, 36px) 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }
.toolbar .grow input { width: 100%; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; font-size: 0.86rem; color: var(--muted); }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); padding: 10px; }
  .nav { display: flex; gap: 6px; overflow-x: auto; }
  .nav a { white-space: nowrap; margin: 0; }
}

/* ---------- dialogs ---------- */
dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(34, 229, 255, 0.08);
}
dialog.wide { width: min(780px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(3, 6, 16, 0.72); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.dialog-body { padding: 20px 22px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.actions-grid { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 40px); }
.toast {
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-left: 4px solid var(--cyan);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 0.9rem; animation: toast-in 0.2s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.codes-box {
  font: 600 0.95rem/1.9 ui-monospace, Menlo, Consolas, monospace;
  background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 12px 14px; max-height: 260px; overflow-y: auto; white-space: pre; user-select: all;
}
.progress { height: 8px; background: var(--bg-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--violet)); transition: width 0.2s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .btn:focus-visible { transform: none; }
}
