/* ── Bates PM Admin Panel styles ──────────────────────────────────────
   Entirely separate from app.css — admin is a standalone screen not
   shown to families.  Uses a neutral dark-on-light palette so the
   admin panel looks different from the family app.
   ─────────────────────────────────────────────────────────────────── */

/* ── Container ─────────────────────────────────────────────────────── */

/* #screen-admin lives outside #app in the DOM.
   #app is hidden via JS (admin-ui.js init) so its min-height:100vh
   does not push this panel down.  This element fills the viewport
   independently.                                                      */
#screen-admin {
  position: fixed;
  inset: 0;                /* top/right/bottom/left: 0 */
  overflow-y: auto;
  padding: 0 !important;   /* override .screen { padding: 1rem } */
  background: #f5f7fa;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: #1a1a2e;
  z-index: 1000;
}

#adm-body {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

/* ── Login ──────────────────────────────────────────────────────────── */
.adm-login-wrap {
  max-width: 360px;
  margin: 80px auto 0;
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 2px 16px rgba(0,0,0,.10);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.adm-login-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
}

.adm-login-err {
  color: #c0392b;
  margin: 0;
  font-size: 0.85rem;
}

/* ── Top bar ────────────────────────────────────────────────────────── */
.adm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.adm-logo {
  font-size: 1.1rem;
  font-weight: 700;
}

/* ── Stat cards ─────────────────────────────────────────────────────── */
.adm-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.adm-stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
}

.adm-stat-val {
  font-size: 1.6rem;
  font-weight: 700;
  color: #2d3a8c;
}

.adm-stat-lbl {
  font-size: 0.75rem;
  color: #666;
  margin-top: 2px;
}

/* ── Tabs ───────────────────────────────────────────────────────────── */
.adm-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid #e0e4ef;
  margin-bottom: 16px;
}

.adm-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  color: #555;
  border-radius: 6px 6px 0 0;
  transition: background .15s;
}

.adm-tab:hover    { background: #eef0f8; }
.adm-tab.active   { color: #2d3a8c; border-bottom-color: #2d3a8c; font-weight: 600; }

.adm-tab-body {
  background: #fff;
  border-radius: 0 10px 10px 10px;
  padding: 16px;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
  overflow-x: auto;
}

/* ── Tables ─────────────────────────────────────────────────────────── */
.adm-table {
  width: 100%;
  border-collapse: collapse;
}

.adm-table th,
.adm-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #eef0f8;
}

.adm-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #888;
  background: #f8f9fc;
}

.adm-table-sm td,
.adm-table-sm th { padding: 5px 8px; font-size: 0.82rem; }

.adm-table tbody tr:hover { background: #f4f6ff; }

.adm-nowrap { white-space: nowrap; }
.adm-detail { max-width: 320px; word-break: break-all; font-size: 0.78rem; color: #555; }

/* ── Buttons ────────────────────────────────────────────────────────── */
.adm-btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: opacity .15s;
}

.adm-btn:hover  { opacity: .85; }
.adm-btn-sm     { padding: 4px 10px; font-size: 0.8rem; }

.adm-btn-primary { background: #2d3a8c; color: #fff; }
.adm-btn-warn    { background: #e67e22; color: #fff; }
.adm-btn-danger  { background: #c0392b; color: #fff; }

/* Default adm-btn (no modifier) */
.adm-btn:not(.adm-btn-primary):not(.adm-btn-warn):not(.adm-btn-danger) {
  background: #eef0f8;
  color: #2d3a8c;
}

/* ── Inputs ─────────────────────────────────────────────────────────── */
.adm-input {
  padding: 8px 12px;
  border: 1px solid #ccd3e8;
  border-radius: 6px;
  font-size: 0.9rem;
  width: 100%;
  box-sizing: border-box;
  outline: none;
}

.adm-input:focus { border-color: #2d3a8c; }
.adm-input-sm    { width: 220px; padding: 4px 8px; font-size: 0.82rem; }

/* ── Badges / labels ────────────────────────────────────────────────── */
.adm-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.78rem;
  background: #eef0f8;
  color: #333;
}

.adm-badge-ok  { background: #d4efdf; color: #1e6c3b; }
.adm-badge-off { background: #fde8e8; color: #8c2020; }

.adm-action-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: #eef0f8;
  font-family: monospace;
  font-size: 0.78rem;
}

/* ── Audit filter row ───────────────────────────────────────────────── */
.adm-audit-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.adm-audit-total {
  margin-left: auto;
  font-size: 0.8rem;
  color: #888;
}

/* ── Feedback ───────────────────────────────────────────────────────── */
.adm-loading { color: #888; font-style: italic; }
.adm-err     { color: #c0392b; }
.adm-empty   { color: #888; font-style: italic; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .adm-stats-row { grid-template-columns: repeat(3, 1fr); }
  .adm-table th:nth-child(5),
  .adm-table td:nth-child(5),
  .adm-table th:nth-child(6),
  .adm-table td:nth-child(6) { display: none; }
}

/* ── Inline settings edit panel ─────────────────────────────────────── */
.adm-edit-row td {
  padding: 0;
  background: #f8faff;
  border-bottom: 2px solid #2d3a8c;
}

.adm-edit-panel {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.adm-edit-section { display: flex; flex-direction: column; gap: 10px; }

.adm-edit-heading {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #2d3a8c;
}

.adm-edit-hint {
  margin: 0;
  font-size: 0.8rem;
  color: #888;
}

.adm-flags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 16px;
}

.adm-flag-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
}

.adm-flag-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #2d3a8c;
}

.adm-textarea {
  font-family: monospace;
  font-size: 0.82rem;
  resize: vertical;
  min-height: 80px;
  width: 100%;
  box-sizing: border-box;
}

.adm-edit-btns {
  display: flex;
  gap: 10px;
}

/* ── Toast notifications ─────────────────────────────────────────────── */
.adm-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e6c3b;
  color: #fff;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 3px 12px rgba(0,0,0,.18);
  z-index: 9999;
  pointer-events: none;
  animation: adm-toast-in .2s ease;
}

.adm-toast-err { background: #c0392b; }

@keyframes adm-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Server config note ──────────────────────────────────────────────── */
.adm-env-note {
  font-size: 0.82rem;
  color: #666;
  background: #fff8e1;
  border-left: 3px solid #f0a500;
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 12px;
}

.adm-env-note-cell {
  font-size: 0.8rem;
  color: #666;
}

/* ── Actions cell ────────────────────────────────────────────────────── */
.adm-actions-cell { white-space: nowrap; }

/* ── Subscription grid ───────────────────────────────────────────────── */
.adm-sub-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.adm-sub-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
}

.adm-sub-label-check {
  flex-direction: row;
  align-items: center;
  font-weight: 400;
  padding-bottom: 4px;
}

.adm-sub-notes-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
  width: 100%;
  margin-bottom: 12px;
}

.adm-notes-ta { min-height: 56px; }

.adm-select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #ccd3e8;
  font-size: 0.88rem;
  background: #fff;
  cursor: pointer;
  min-width: 120px;
}

/* Edit panel section separator */
.adm-edit-section-sep {
  border-top: 1px solid #e0e4ef;
  padding-top: 16px;
  margin-top: 4px;
}

/* Beta badge */
.adm-badge-beta { background: #e8d5fb; color: #5b1a9c; }

/* Locked-off feature label */
.adm-flag-locked { opacity: 0.6; }

.adm-lock-badge {
  font-size: 0.72rem;
  background: #fde8e8;
  color: #8c2020;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

/* Warn badge (locked count in table) */
.adm-badge-warn { background: #fff0cd; color: #7a4800; }

/* ── Feature usage tab ──────────────────────────────────────────────── */
.adm-usage-nil { color: #aaa; font-size: 0.85rem; }
.adm-code-sm { font-size: 0.78rem; color: #666; }

/* ── Server config: runtime settings ───────────────────────────────── */
.adm-section-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #2c3e6e;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Toggle switch for runtime booleans */
.adm-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.adm-toggle-wrap input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.adm-toggle-track {
  display: inline-block;
  width: 38px;
  height: 22px;
  background: #ccc;
  border-radius: 11px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.adm-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.adm-toggle-wrap input:checked + .adm-toggle-track { background: #3a7bd5; }
.adm-toggle-wrap input:checked + .adm-toggle-track::after { transform: translateX(16px); }

/* ── Tier defaults grid ─────────────────────────────────────────────── */
.adm-tier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}
@media (max-width: 680px) {
  .adm-tier-grid { grid-template-columns: 1fr; }
}
.adm-tier-col {
  background: #fff;
  border: 1px solid #e0e4ef;
  border-radius: 10px;
  padding: 16px;
}
.adm-tier-heading {
  font-size: 0.88rem;
  font-weight: 700;
  color: #2c3e6e;
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.adm-feat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f8;
}
.adm-feat-row:last-of-type { border-bottom: none; }
.adm-feat-row input[type="checkbox"] { accent-color: #3a7bd5; width: 15px; height: 15px; }
/* Indented sub-feature rows (e.g. calendar event types under the Events feature) */
.adm-feat-row-sub {
  padding-left: 22px;
  font-size: 0.84rem;
  color: #556;
  border-bottom-color: #f5f6fb;
}
.adm-quota-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e0e4ef;
  font-size: 0.88rem;
  color: #555;
}
.adm-quota-row label { display: flex; flex-direction: column; gap: 6px; }
.adm-input-sm {
  padding: 5px 8px;
  border: 1px solid #d0d5e8;
  border-radius: 6px;
  font-size: 0.88rem;
  width: 100px;
}

/* ── Feature usage: clickable rows + detail panel ───────────────────── */
.adm-feat-table tbody tr { cursor: pointer; }
.adm-feat-table tbody tr:hover { background: #f0f4ff; }
.adm-row-active { background: #e8f0fe !important; }

.adm-detail-panel {
  background: #fff;
  border: 1px solid #d0d8ef;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.adm-detail-header {
  overflow: hidden;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid #e8ecf8;
  font-size: 1rem;
}
.adm-detail-section { margin-bottom: 14px; }
.adm-detail-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #889;
  margin: 0 0 8px;
}
.adm-detail-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.adm-detail-pill {
  background: #f0f4ff;
  border: 1px solid #d0d8ef;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.82rem;
}
.adm-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}
.adm-detail-card {
  background: #f8faff;
  border: 1px solid #e0e6f8;
  border-radius: 8px;
  padding: 10px 12px;
}
.adm-detail-card-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 4px; }
.adm-detail-card-body  { font-size: 0.82rem; color: #444; line-height: 1.5; }
