/* FeinX Admin — Sanctuary editorial-light theme (cream / terracotta).
   Tokens mirror the marketing site (FeinX-landing/styles.css). */

:root {
  --background: #fbfaf6;
  --surface: #f3f1ea;
  --surface-elevated: #ffffff;
  --border: #ebe7db;
  --border-light: #ece5d9;

  --text-primary: #2b2a26;
  --text-secondary: #77746b;
  --text-tertiary: #b5ab9c;

  --accent: #c58a52;
  --accent-dark: #b4832f;
  --accent-light: #e8c4a0;
  --accent-muted: #f6efe6;

  --ink: #2b2a26;

  --good: #4f7a5b;
  --good-bg: #eaf1eb;
  --warn: #b4832f;
  --warn-bg: #f8f0df;
  --danger: #b4544a;
  --danger-bg: #f6e6e2;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(43, 42, 38, 0.04), 0 8px 24px rgba(43, 42, 38, 0.05);
}

* { box-sizing: border-box; }

/* Ensure the `hidden` attribute always wins over class-based `display`
   (e.g. .modal-host/.login-screen/.app set display, which otherwise
   overrides the UA [hidden] { display:none } rule). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--text-primary);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; }

a { color: inherit; text-decoration: none; }

.muted { color: var(--text-secondary); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, color 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--text-primary); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent-light); background: var(--accent-muted); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger-bg); }
.btn-danger:hover { background: var(--danger-bg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Login ─────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--accent-muted), transparent),
    var(--background);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { font-size: 26px; margin-top: 8px; }
.login-card .muted { margin: -6px 0 8px; font-size: 14px; }
.login-card label,
.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.login-card input,
.form input,
.form select,
.form textarea {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}
.login-card input:focus,
.form input:focus,
.form select:focus,
.form textarea:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px var(--accent-muted);
}
.form textarea { resize: vertical; min-height: 84px; }
.form-error {
  color: var(--danger);
  font-size: 13px;
  background: var(--danger-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0;
}

/* ── Brand ─────────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { color: var(--accent); font-size: 18px; }
.brand-name { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.brand-tag {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 2px;
}

/* ── App shell ─────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text-secondary);
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--accent-muted); color: var(--text-primary); }
.nav-item.active { background: var(--surface-elevated); color: var(--text-primary); box-shadow: var(--shadow); }
.nav-ico { color: var(--accent); width: 18px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 1px 8px;
}
.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.who-name { font-weight: 600; font-size: 14px; }
.who-email { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { font-size: 24px; }
.view { padding: 28px 32px 64px; }

/* ── Cards / stat grid ─────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.stat-value { font-family: var(--serif); font-size: 36px; margin-top: 6px; line-height: 1; }
.stat-value.alert { color: var(--danger); }
.stat-sub { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }

.card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 18px; }
.card-body { padding: 6px 0; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.section-head h2 { font-size: 20px; }

/* ── Tables ────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 600;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 14px 22px; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(246, 239, 230, 0.4); }
.table .num { font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { margin-left: 6px; }

/* ── Badges / chips ────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.badge-user { background: var(--surface); color: var(--text-secondary); }
.badge-therapist { background: var(--accent-muted); color: var(--accent-dark); }
.badge-admin { background: var(--ink); color: var(--background); }
.badge-good { background: var(--good-bg); color: var(--good); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.chip {
  display: inline-block;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  margin: 2px 4px 2px 0;
}

.report-body {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
  max-width: 520px;
  line-height: 1.5;
}
.report-title { font-weight: 600; }

/* ── States ────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-secondary);
}
.empty .empty-mark { font-size: 32px; color: var(--accent-light); display: block; margin-bottom: 10px; }
.loading { padding: 48px; text-align: center; color: var(--text-tertiary); }
.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-host { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(43, 42, 38, 0.28); backdrop-filter: blur(2px); }
.modal {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface-elevated);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(43, 42, 38, 0.2);
  padding: 28px;
}
.modal h2 { font-size: 22px; margin-bottom: 4px; }
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.form label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--text-primary);
}
.form label.check input { width: auto; }
.check-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px 12px; margin: 0; }
.check-group legend { font-size: 13px; font-weight: 500; color: var(--text-secondary); padding: 0 6px; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }

/* ── Filters / misc ────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar input,
.filter-bar select {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  outline: none;
}
.filter-bar input { flex: 1 1 220px; }
.filter-bar input:focus,
.filter-bar select:focus { border-color: var(--accent-light); box-shadow: 0 0 0 3px var(--accent-muted); }
.quote {
  margin: 8px 0 0;
  padding: 6px 12px;
  border-left: 2px solid var(--accent-light);
  color: var(--text-secondary);
  font-size: 13px;
  font-style: italic;
  max-width: 520px;
}
.table .empty-row td { text-align: center; padding: 22px; }
.table td.wide { min-width: 220px; }

/* ── Toasts ────────────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--ink);
  color: var(--background);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
  max-width: 340px;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--good); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: 12px;
  }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; }
  .sidebar-foot { flex-direction: row; align-items: center; border-top: none; padding-top: 0; margin-left: auto; }
  .view, .topbar { padding-left: 18px; padding-right: 18px; }
  .form-row, .check-grid { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
}
