// ─────────────────────────────────────────────────────────────
// Admin — backend panel
// Marketing-site aesthetic, denser/more functional
// ─────────────────────────────────────────────────────────────
@import "variables.less";

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

// Theme tokens (light only for admin)
:root {
  --bg: @light-bg;
  --bg-elev: @light-bg-elev;
  --bg-sub: @light-bg-sub;
  --ink: @light-ink;
  --ink-2: @light-ink-2;
  --ink-3: @light-ink-3;
  --line: @light-line;
  --line-2: @light-line-2;
  --accent: @light-accent;
}

// ── Login page ───────────────────────────────────────────────
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background:
    radial-gradient(1100px 700px at 80% -10%, color-mix(in oklab, var(--ink) 5%, transparent), transparent 70%),
    radial-gradient(900px 600px at -10% 110%, color-mix(in oklab, var(--ink) 4%, transparent), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: @radius-lg;
  padding: 44px 40px 36px;
  box-shadow: 0 30px 80px -40px rgba(0,0,0,0.18);
}
.login-brand {
  font-family: @font-mono;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 28px;
}
.login-brand strong { color: var(--ink); font-weight: 600; }
.login-h {
  font-family: @font-display;
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
}
.login-sub {
  margin: 0 0 32px;
  color: var(--ink-3);
  font-size: 14px;
}
.field {
  display: flex; flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}
.field label {
  font-family: @font-mono;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.field input,
.field textarea,
.field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  transition: border-color .15s @ease-out, box-shadow .15s @ease-out;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 0;
  border-color: var(--ink);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--ink) 8%, transparent);
}
.field textarea { resize: vertical; min-height: 90px; }
.field-hint { font-size: 12px; color: var(--ink-3); margin-top: -4px; }

.btn-admin {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-family: inherit; font-size: 14px; font-weight: 500;
  background: var(--ink);
  color: var(--bg);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .15s @ease-out, opacity .2s ease;
}
.btn-admin:hover { transform: translateY(-1px); }
.btn-admin:active { transform: translateY(0); }
.btn-admin.ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line-2);
}
.btn-admin.ghost:hover { background: var(--bg-sub); }
.btn-admin.danger {
  background: #DC2626; color: white;
}
.btn-admin.full { width: 100%; }
.btn-admin[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

.login-error {
  background: rgba(239,68,68,0.08);
  color: #B91C1C;
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 18px;
  display: none;
}
.login-error.show { display: block; }

.login-foot {
  margin-top: 24px;
  text-align: center;
  font-family: @font-mono;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.login-foot a { color: var(--ink-2); text-decoration: none; }
.login-foot a:hover { color: var(--ink); }

// ── Admin shell ──────────────────────────────────────────────
.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}
.admin-side {
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  padding: 28px 18px 24px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.admin-brand {
  font-family: @font-mono;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 10px;
  margin-bottom: 28px;
}
.admin-brand strong { color: var(--ink); font-weight: 600; }
.admin-nav {
  display: flex; flex-direction: column; gap: 2px;
}
.admin-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
  text-decoration: none;
  letter-spacing: -0.005em;
  transition: background .15s ease, color .15s ease;
}
.admin-nav a:hover { background: var(--bg-sub); color: var(--ink); }
.admin-nav a.active {
  background: var(--ink); color: var(--bg);
}
.admin-nav a svg { width: 16px; height: 16px; flex: 0 0 auto; }
.admin-side-foot {
  margin-top: auto;
  padding: 14px 12px 0;
  border-top: 1px solid var(--line);
}
.admin-side-foot .who {
  font-size: 12px; color: var(--ink-3); margin-bottom: 8px;
}
.admin-side-foot .who strong { color: var(--ink); font-weight: 500; }
.admin-side-foot button {
  background: none; border: 0; cursor: pointer;
  font-family: inherit; font-size: 12.5px;
  color: var(--ink-3);
  padding: 6px 0;
  letter-spacing: -0.005em;
}
.admin-side-foot button:hover { color: var(--ink); }

.admin-main {
  padding: 32px 40px 80px;
  max-width: 1200px;
}
.admin-h {
  font-family: @font-display;
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
}
.admin-sub {
  color: var(--ink-3);
  font-size: 14px;
  margin: 0 0 32px;
  max-width: 640px;
}
.admin-section {
  margin-bottom: 44px;
}
.admin-section-h {
  font-family: @font-mono;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 16px;
}

// ── Cards & grids ───────────────────────────────────────────
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: @radius-md;
  padding: 22px;
}
.cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: @radius-md;
  padding: 20px;
}
.stat .stat-label {
  font-family: @font-mono;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 12px;
}
.stat .stat-value {
  font-family: @font-display;
  font-weight: 600;
  font-size: 32px;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1;
}
.stat .stat-delta {
  margin-top: 6px;
  font-size: 12px;
  color: #047857;
}
.stat .stat-delta.down { color: #B91C1C; }

// ── Apps manager ────────────────────────────────────────────
.apps-list {
  display: grid;
  gap: 14px;
}
.app-row {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: @radius-md;
  padding: 20px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
}
.app-row .app-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--bg-sub);
  border: 1px solid var(--line-2);
  display: grid; place-items: center;
  color: var(--ink);
}
.app-row .app-icon svg { width: 22px; height: 22px; }
.app-row .app-meta strong {
  font-family: @font-display;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.018em;
  display: block;
  margin-bottom: 2px;
}
.app-row .app-meta .slug {
  font-family: @font-mono;
  font-size: 11px;
  color: var(--ink-3);
}
.app-row .app-meta .tagline {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 4px;
}
.app-row .app-actions {
  display: flex; gap: 8px; align-items: center;
}

// Toggle switch
.toggle {
  position: relative;
  width: 38px; height: 22px;
  background: var(--line-2);
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s ease;
  flex: 0 0 auto;
}
.toggle::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform .2s @ease-out;
}
.toggle.on { background: #10B981; }
.toggle.on::after { transform: translateX(16px); }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .label {
  font-size: 13.5px;
  color: var(--ink);
}
.toggle-row .label .muted {
  font-family: @font-mono;
  font-size: 11px;
  color: var(--ink-3);
  display: block;
  margin-top: 2px;
}

// ── Editor (content fields) ─────────────────────────────────
.field-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}
.field-grid.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .field-grid.cols-2 { grid-template-columns: 1fr; } }

.editor-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}
.editor-tabs .tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  letter-spacing: -0.005em;
}
.editor-tabs .tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

// ── Submissions / inbox ─────────────────────────────────────
.submissions {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: @radius-md;
  overflow: hidden;
}
.sub-row {
  display: grid;
  grid-template-columns: 1fr 200px 140px 100px;
  gap: 18px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  cursor: pointer;
  transition: background .15s ease;
}
.sub-row:hover { background: var(--bg-sub); }
.sub-row:last-child { border-bottom: 0; }
.sub-row.unread { background: color-mix(in oklab, var(--ink) 3%, var(--bg-elev)); }
.sub-row.unread::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #10B981;
  margin-right: 10px;
  vertical-align: middle;
}
.sub-row .who {
  font-family: @font-display;
  font-weight: 500;
  font-size: 14px;
  color: var(--ink);
}
.sub-row .who small {
  display: block;
  font-family: @font-text;
  font-weight: 400;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 2px;
}
.sub-row .preview {
  font-size: 13px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sub-row .meta-tag {
  font-family: @font-mono;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.sub-row .when {
  font-size: 12px; color: var(--ink-3);
  text-align: right;
}

// Modal
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(10,10,10,0.4);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 200;
  padding: 24px;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: @radius-lg;
  padding: 28px 30px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 {
  font-family: @font-display;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.022em;
  margin: 0 0 18px;
}
.modal .from-line {
  font-size: 13px; color: var(--ink-3); margin-bottom: 8px;
}
.modal .from-line strong { color: var(--ink); font-weight: 500; }
.modal .msg-body {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  margin: 18px 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-2);
  white-space: pre-wrap;
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 20px;
}

// ── Analytics ───────────────────────────────────────────────
.chart-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: @radius-md;
  padding: 24px;
  margin-bottom: 14px;
}
.chart-card-h {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 18px;
}
.chart-card-h .t {
  font-family: @font-display;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.018em;
}
.chart-card-h .meta {
  font-family: @font-mono;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.chart-svg { display: block; width: 100%; height: 220px; }

.analytics-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 900px) {
  .analytics-cols { grid-template-columns: 1fr; }
  .cards-row { grid-template-columns: repeat(2, 1fr); }
}
.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-list .row {
  display: grid;
  grid-template-columns: 130px 1fr 56px;
  gap: 12px; align-items: center;
}
.bar-list .row .name { font-size: 13px; color: var(--ink); }
.bar-list .row .bar {
  height: 8px;
  background: var(--bg-sub);
  border-radius: 999px;
  overflow: hidden;
}
.bar-list .row .bar > div {
  height: 100%;
  background: var(--ink);
  border-radius: 999px;
}
.bar-list .row .num {
  font-family: @font-mono;
  font-size: 12px;
  color: var(--ink-3);
  text-align: right;
}

// ── Toast ───────────────────────────────────────────────────
.toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--bg);
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 13.5px;
  letter-spacing: -0.005em;
  z-index: 300;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s @ease-out;
}
.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.toast.error { background: #DC2626; color: white; }

// ── Responsive ──────────────────────────────────────────────
@media (max-width: 800px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side {
    position: relative; height: auto;
    flex-direction: row; flex-wrap: wrap;
    padding: 16px 18px;
    align-items: center;
    gap: 14px;
  }
  .admin-brand { margin-bottom: 0; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .admin-side-foot { margin-left: auto; padding: 0; border: 0; }
  .admin-main { padding: 24px 22px 60px; }
  .app-row { grid-template-columns: 1fr; gap: 14px; }
  .sub-row { grid-template-columns: 1fr; gap: 4px; }
  .sub-row .when { text-align: left; }
}
