:root {
  --bg: #F2F3EE;
  --surface: #FFFFFF;
  --ink: #202B25;
  --ink-soft: #57655D;
  --accent: #2F6F5E;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3ECE7;
  --gold: #C9A15A;
  --border: #DBD8CC;
  --danger: #A64B3C;

  --cat-therapists-bg: #E3ECE7;
  --cat-therapists-border: #AFC9BC;
  --cat-medical-bg: #E3EAF4;
  --cat-medical-border: #B7C9E3;
  --cat-admin-bg: #F5EEDC;
  --cat-admin-border: #E0CB98;
  --cat-other-bg: var(--surface);
  --cat-other-border: var(--border);

  --font-display: 'Newsreader', Georgia, serif;
  --font-ui: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over components (like .lock-screen)
   that set their own `display` for layout purposes. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-tap-highlight-color: transparent;
  height: 100%;
}

button, input {
  font-family: inherit;
}

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.4rem;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: #275c4e; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
}
.btn-ghost:hover { border-color: var(--accent); }

.btn-small { padding: 0.5rem 0.9rem; font-size: 0.85rem; }

.btn-danger { color: var(--danger); }

/* ---------- Kiosk screen ---------- */

.kiosk-body {
  min-height: 100vh;
  padding: 3vh 4vw 6vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.clinic-logo {
  position: absolute;
  top: 2vh;
  right: 4vw;
  width: 150px;
  height: auto;
}

.kiosk-header {
  max-width: 46rem;
  margin: 0 auto 3.2vh;
  text-align: center;
}

.kiosk-welcome {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  color: var(--ink);
}

.kiosk-instruction {
  margin: 0;
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  color: var(--ink-soft);
}

.kiosk-sections {
  flex: 1;
  max-width: 72rem;
  margin: 0 auto;
  width: 100%;
}

.clinician-section {
  margin-bottom: 2.4rem;
  background: var(--cat-other-bg);
  border: 1px solid var(--cat-other-border);
  border-radius: 8px;
  padding: 1.6rem 1.7rem 2.1rem;
}
.clinician-section:last-child {
  margin-bottom: 0;
}

.clinician-section.cat-therapists {
  background: var(--cat-therapists-bg);
  border-color: var(--cat-therapists-border);
}
.clinician-section.cat-medical {
  background: var(--cat-medical-bg);
  border-color: var(--cat-medical-border);
}
.clinician-section.cat-admin {
  background: var(--cat-admin-bg);
  border-color: var(--cat-admin-border);
}

.section-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.3rem;
  color: var(--ink);
  margin: 0 0 1.4rem;
  padding-bottom: 0.7rem;
  border-bottom: 2px solid var(--cat-other-border);
}
.cat-therapists .section-heading { border-bottom-color: var(--cat-therapists-border); }
.cat-medical .section-heading { border-bottom-color: var(--cat-medical-border); }
.cat-admin .section-heading { border-bottom-color: var(--cat-admin-border); }

.clinician-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--photo-w, 104px), 1fr));
  gap: 1.7rem 1rem;
  align-content: start;
}

.clinician-tile {
  background: transparent;
  border: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.clinician-photo {
  width: var(--photo-w, 104px);
  height: var(--photo-h, 138px);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: transform 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--ink-soft);
}

.clinician-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.clinician-tile:active .clinician-photo {
  transform: scale(0.96);
}

.clinician-name {
  font-family: var(--font-display);
  font-size: var(--name-font-size, 17px);
  color: var(--ink);
  text-align: center;
  line-height: 1.3;
}

.admin-link {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--ink-soft);
  opacity: 0.35;
  text-decoration: none;
  font-size: 1.1rem;
}
.admin-link:hover { opacity: 0.8; }

/* ---------- Confirmation overlay ---------- */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 43, 37, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.confirm-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.confirm-card {
  max-width: 28rem;
  text-align: center;
  padding: 2rem;
  color: #FFFFFF;
}

.confirm-check {
  color: var(--gold);
  margin-bottom: 1.2rem;
}

.confirm-name {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin: 0 0 0.6rem;
}

.confirm-status {
  font-size: 1.05rem;
  color: #D9E2DC;
  margin: 0;
}

/* ---------- Shared empty state ---------- */

.admin-empty-state {
  text-align: center;
  color: var(--ink-soft);
  max-width: 30rem;
  margin: 2rem auto;
}

/* ---------- Admin: lock screen ---------- */

.admin-body { min-height: 100vh; }

.lock-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lock-form {
  width: 100%;
  max-width: 22rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lock-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.7rem;
  margin: 0 0 0.5rem;
}

.lock-notice {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0 0 0.5rem;
}

.lock-back {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

/* ---------- Admin: main screen ---------- */

.admin-screen {
  max-width: 44rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

.admin-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.admin-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 2rem;
  margin: 0;
}

.clinician-list {
  list-style: none;
  margin: 0 0 2.5rem;
  padding: 0;
  border-top: 1px solid var(--border);
}

.clinician-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.clinician-row-photo {
  width: 40px;
  height: 53px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--accent-soft);
  flex-shrink: 0;
}
.clinician-row-photo img { width: 100%; height: 100%; object-fit: cover; }

.clinician-row-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.clinician-row-name { font-weight: 600; }
.clinician-row-detail { font-size: 0.85rem; color: var(--ink-soft); overflow-wrap: anywhere; }

.clinician-row-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ---------- Admin: clinic settings ---------- */

.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 2.5rem;
}

.settings-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.3rem;
  margin: 0 0 1.25rem;
}

.settings-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.settings-row:last-child { margin-bottom: 0; }

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.settings-status {
  font-size: 0.85rem;
  color: var(--accent);
  padding-bottom: 0.6rem;
}

.logo-row {
  display: flex;
  align-items: flex-start;
  gap: 1.1rem;
}

.logo-preview {
  width: 108px;
  height: 72px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  overflow: hidden;
  flex-shrink: 0;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }

.logo-controls {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.logo-ratio-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.logo-ratio-label .text-input {
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
}

.logo-buttons {
  display: flex;
  gap: 0.6rem;
}

.logo-size-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.logo-size-row input[type="range"] { flex: 1; max-width: 20rem; }
.logo-size-row span { font-size: 0.85rem; color: var(--ink-soft); min-width: 3.5rem; }

.logo-size-preview-wrap {
  margin-top: 0.75rem;
  padding: 1.5rem 1rem;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 6px;
  display: flex;
  justify-content: flex-end;
}
#logo-size-preview { height: auto; }

.clinician-display-controls {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.display-slider-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.clinician-display-preview-wrap {
  justify-content: center;
}
.clinician-display-preview-wrap .clinician-photo--placeholder {
  background: var(--accent-soft);
}

/* ---------- Admin: form ---------- */

.clinician-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.75rem;
}

.form-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.3rem;
  margin: 0 0 1.25rem;
}

.form-row {
  display: flex;
  gap: 1.75rem;
  margin-bottom: 1.5rem;
}

.form-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  flex-shrink: 0;
}

.photo-preview {
  width: 96px;
  height: 128px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  overflow: hidden;
  text-align: center;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

.photo-upload-label { cursor: pointer; }

.form-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-top: 0.5rem;
}
.field-label:first-child { margin-top: 0; }

.text-input {
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
}
.text-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ---------- Photo cropper modal ---------- */

.cropper-overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 43, 37, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.cropper-panel {
  background: var(--surface);
  border-radius: 6px;
  padding: 1.5rem;
  width: 100%;
  max-width: 26rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.cropper-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin: 0;
  align-self: flex-start;
}

.cropper-stage {
  position: relative;
}

.cropper-canvas {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  touch-action: none;
  cursor: grab;
}

.cropper-zoom-label {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.cropper-zoom { width: 100%; }

.cropper-actions {
  display: flex;
  gap: 0.75rem;
  align-self: flex-end;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .confirm-overlay, .clinician-photo { transition: none; }
}

/* ---------- Small screens ---------- */

@media (max-width: 480px) {
  .form-row { flex-direction: column; align-items: flex-start; }
}
