/* ============================================================
   NIGHTSTAND ADMIN — admin.css
   Shared design tokens, shell layout, and component library.
   Type: DM Mono (display/labels) · Inter (body/UI)
   ============================================================ */

:root {
  --bg:           #0B0F14;
  --surface:      #141A23;
  --surface2:     #1C2733;
  --border:       #1C2733;
  --border-light: #263545;
  --text:         #E8ECF1;
  --text-dim:     #8FA1B8;
  --text-faint:   #4F6278;
  --blue:         #3B82F6;
  --blue-dim:     #1E3A5F;
  --green:        #22D3A8;
  --green-dim:    #143B33;
  --amber:        #F4B740;
  --amber-dim:    #3A2E10;
  --red:          #EF5B5B;
  --red-dim:      #3D1A1A;
  --sidebar-w:    240px;
  --topbar-h:     56px;
  --radius:       10px;
  --radius-sm:    6px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Shell ────────────────────────────────────────────────── */
#admin-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
#admin-shell.hidden { display: none; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.shell-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

/* ── Typography ───────────────────────────────────────────── */
.mono { font-family: 'DM Mono', monospace; }

.page-title {
  font-family: 'DM Mono', monospace;
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.page-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 24px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 14px;
}
.eyebrow::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

/* ── Stat cards ───────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-card-val {
  font-family: 'DM Mono', monospace;
  font-size: 28px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-card-lbl { font-size: 12px; color: var(--text-dim); }
.stat-card.green { border-color: rgba(34,211,168,0.2); }
.stat-card.green .stat-card-val { color: var(--green); }
.stat-card.red   { border-color: rgba(239,91,91,0.2);  }
.stat-card.red   .stat-card-val { color: var(--red);   }
.stat-card.blue  { border-color: rgba(59,130,246,0.2); }
.stat-card.blue  .stat-card-val { color: var(--blue);  }
.stat-card.amber { border-color: rgba(244,183,64,0.2); }
.stat-card.amber .stat-card-val { color: var(--amber); }

/* ── Table ────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface2); cursor: pointer; }
.data-table .td-main { color: var(--text); font-weight: 500; }
.data-table .td-mono {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Pills ────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill-green { background: var(--green-dim); color: var(--green); border-color: rgba(34,211,168,0.2); }
.pill-red   { background: var(--red-dim);   color: var(--red);   border-color: rgba(239,91,91,0.2);  }
.pill-blue  { background: var(--blue-dim);  color: var(--blue);  border-color: rgba(59,130,246,0.2); }
.pill-amber { background: var(--amber-dim); color: var(--amber); border-color: rgba(244,183,64,0.2); }
.pill-grey  { background: var(--surface2);  color: var(--text-dim); border-color: var(--border-light); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.12s, transform 0.1s;
  white-space: nowrap;
}
.btn:active   { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary  { background: var(--blue); color: #05101F; }
.btn-danger   { background: var(--red);  color: #fff; }
.btn-ghost    { background: transparent; color: var(--text-dim); border: 1px solid var(--border-light); }
.btn-sm       { padding: 5px 10px; font-size: 12px; }

/* ── Form controls ────────────────────────────────────────── */
.field-group  { margin-bottom: 16px; }
.field-lbl {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field-ctrl {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  outline: none;
}
.field-ctrl:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.field-ctrl::placeholder { color: var(--text-faint); }
select.field-ctrl { cursor: pointer; }
select.field-ctrl option { background: var(--surface2); }
textarea.field-ctrl { min-height: 80px; resize: vertical; }

/* ── Toolbar ──────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar-search {
  flex: 1;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  outline: none;
}
.toolbar-search:focus  { border-color: var(--blue); }
.toolbar-search::placeholder { color: var(--text-faint); }
.toolbar-filter {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--text-dim);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.toolbar-filter option { background: var(--surface2); }

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}
.pag-btn {
  background: var(--surface2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}
.pag-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pag-info {
  flex: 1;
  text-align: center;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
}

/* ── Toast notifications ──────────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  max-width: 340px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  animation: toast-in 0.2s ease;
  pointer-events: all;
}
.toast.success { border-color: rgba(34,211,168,0.3); }
.toast.error   { border-color: rgba(239,91,91,0.3);  }
.toast.warning { border-color: rgba(244,183,64,0.3); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 24px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-family: 'DM Mono', monospace;
  font-size: 16px;
  font-weight: 500;
  margin: 0 0 20px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ── Utility ──────────────────────────────────────────────── */
.hidden       { display: none !important; }
.text-green   { color: var(--green); }
.text-red     { color: var(--red);   }
.text-amber   { color: var(--amber); }
.text-dim     { color: var(--text-dim); }
.text-faint   { color: var(--text-faint); }
.text-right   { text-align: right; }
.mt-0         { margin-top: 0; }
.mb-0         { margin-bottom: 0; }

.page-loading {
  display: flex;
  justify-content: center;
  padding: 80px 0;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border-light);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-faint);
  font-size: 13px;
}
.empty-state-title {
  font-family: 'DM Mono', monospace;
  font-size: 15px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

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