/* DCRM Kiosk Dashboard Admin */
:root {
  --accent: #5E81FB;
  --accent-press: #4A6BE0;
  --accent-soft: rgba(94, 129, 251, 0.10);
  --grad: linear-gradient(90deg, #5E81FB 0%, #7329F9 46%, #BC34FF 69%, #FB00DD 100%);

  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;

  --text-primary: #000000;
  --text-secondary: #374151;
  --text-tertiary: #6B7280;

  --border: #E8E9ED;
  --surface: #FFFFFF;
  --surface-alt: #FAFBFC;
  --surface-elevated: #F5F6F8;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04), 0 1px 3px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 4px 12px rgba(17, 24, 39, 0.08);

  --font: "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--text-primary); }

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; font-size: 14px; }

/* ── Brand mark ──────────────────────────────────────────────────────────── */
.brand-word {
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.brand-sub {
  color: var(--text-tertiary);
  font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-press); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-elevated); color: var(--text-primary); }
.btn-block { width: 100%; padding: 12px 18px; }

/* ── Auth screens (login / change password) ──────────────────────────────── */
[hidden] { display: none !important; }
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  position: relative;
  width: 100%;
  max-width: 408px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px 36px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.auth-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--grad);
}
.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.brand-mark .brand-word { font-size: 22px; }
.brand-mark .brand-sub { font-size: 13px; }
.brand-logo { height: 24px; width: auto; display: block; }
.topbar-brand .brand-logo { height: 20px; }
.auth-card h1 {
  margin: 0 0 6px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.auth-lede {
  margin: 0 0 28px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ── Fields ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}
.alert-error {
  color: var(--error);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.18);
}
.alert-success {
  color: #047857;
  background: rgba(16, 185, 129, 0.10);
  border: 1px solid rgba(16, 185, 129, 0.20);
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar-brand .brand-word { font-size: 18px; }
.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}
.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.005em;
}
.topbar-actions { display: flex; gap: 10px; }

/* ── Admin shell ─────────────────────────────────────────────────────────── */
.admin-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 56px;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}

/* Clinic rail */
.clinic-rail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  position: sticky;
  top: 88px;
}
.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 12px;
}
.rail-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.rail-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
}
.clinic-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.clinic-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.clinic-list li:hover { background: var(--surface-elevated); }
.clinic-list li.active {
  background: var(--accent-soft);
  border-color: rgba(94, 129, 251, 0.25);
}
.clinic-list .clinic-name {
  flex: 1;
  font-weight: 700;
  color: var(--text-primary);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clinic-list .clinic-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d5db;
  flex-shrink: 0;
}
.clinic-list .clinic-dot.on { background: var(--success); }
.rail-empty {
  padding: 16px 12px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* Detail panel */
.detail-panel { min-width: 0; }
.detail-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 420px;
}
.detail-empty-card {
  text-align: center;
  color: var(--text-tertiary);
  max-width: 320px;
}
.detail-empty-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 8px;
}
.detail-empty-card p { margin: 0; font-size: 14px; }

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.detail-head {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
}
.detail-head h2 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.detail-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.detail-body { padding: 24px 28px; }

/* Kiosk URL block */
.kiosk-url {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 24px;
}
.kiosk-url .kiosk-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.kiosk-url code {
  flex: 1;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kiosk-url .copy-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.kiosk-url .copy-btn:hover { background: var(--surface-elevated); color: var(--text-primary); }

/* Form sections */
.name-edit {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--accent); background: var(--accent-soft); }
.name-input {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  width: 100%;
  max-width: 360px;
}
.name-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo-preview {
  width: 96px;
  height: 64px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview.empty span { font-size: 12px; color: var(--text-tertiary); }
.logo-actions { display: flex; gap: 8px; }
.logo-error { color: var(--error); }

.section-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
}
.form-grid .span-2 { grid-column: 1 / -1; }

/* Toggle switch */
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.toggle-text { min-width: 0; }
.toggle-title {
  display: block;
  font-weight: 700;
  color: var(--text-primary);
  font-size: 13px;
}
.toggle-desc {
  display: block;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
  line-height: 1.4;
}
.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: #cbd2dc;
  border-radius: 999px;
  transition: background 0.18s;
}
.slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Detail footer / save bar */
.detail-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 18px 28px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}
.save-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
}
.save-status.ok { color: #047857; }
.save-status.err { color: var(--error); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 880px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }
  .clinic-rail { position: static; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .topbar-title { display: none; }
}
