/* ==========================================================================
   Dr Nikhil's Vighnaharta Clinic — Component Library
   Glassmorphism cards, buttons, nav, toast, modal, skeletons, badges, forms.
   ========================================================================== */

/* ---- Glass surface (the signature look) ---- */
.glass {
  background: var(--color-surface-glass);
  backdrop-filter: blur(var(--blur-glass)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-glass)) saturate(160%);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  transition: transform var(--duration-base) var(--ease-standard), box-shadow var(--duration-base) var(--ease-standard);
}
.card.glass { border-radius: var(--radius-lg); }
.card:hover { box-shadow: var(--shadow-md); }
.card-hover:hover { transform: translateY(-3px); }

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.card-subtitle { color: var(--color-text-muted); font-size: 0.85rem; margin-top: 0.15rem; }

/* ---- Theme toggle (dashboard topbar, public nav, auth pages — shared
   here rather than per-layout so it looks the same, and actually looks
   like something, everywhere it's used) ---- */
.theme-toggle {
  position: relative;
  width: 52px; height: 30px;
  border-radius: var(--radius-full);
  background: var(--color-border-strong);
  border: none;
  cursor: pointer;
  padding: 3px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: background var(--duration-base) var(--ease-standard);
}
.theme-toggle:hover { background: var(--color-border); }
.theme-toggle:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.theme-toggle-knob {
  position: relative;
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-gold), var(--brand-navy));
  box-shadow: var(--shadow-sm);
  color: #fff;
  transition: transform var(--duration-base) var(--ease-out-back);
}
:root[data-theme="dark"] .theme-toggle-knob { transform: translateX(22px); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle-knob { transform: translateX(22px); }
}

/* Sun (light) / moon (dark) glyphs cross-fade inside the knob instead of
   showing one static icon, so the button reads correctly at a glance in
   both themes rather than just being a generic unlabeled switch. */
.theme-toggle-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.6) rotate(-45deg);
  transition: opacity var(--duration-base) var(--ease-standard), transform var(--duration-base) var(--ease-standard);
}
.theme-toggle-icon-sun { opacity: 1; transform: scale(1) rotate(0deg); }
:root[data-theme="dark"] .theme-toggle-icon-sun { opacity: 0; transform: scale(0.6) rotate(45deg); }
:root[data-theme="dark"] .theme-toggle-icon-moon { opacity: 1; transform: scale(1) rotate(0deg); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle-icon-sun { opacity: 0; transform: scale(0.6) rotate(45deg); }
  :root:not([data-theme="light"]) .theme-toggle-icon-moon { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-standard);
  white-space: nowrap;
  min-height: 44px; /* touch target */
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand-navy), var(--brand-navy-700));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: var(--shadow-md); }

.btn-accent {
  background: linear-gradient(135deg, var(--brand-teal), var(--brand-teal-600));
  color: #fff;
}
.btn-accent:hover { filter: brightness(1.08); box-shadow: var(--shadow-glow); }

.btn-outline {
  background: transparent;
  border-color: var(--color-border-strong);
  color: var(--color-text);
}
.btn-outline:hover { background: var(--color-border); }

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

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }

.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.8rem; min-height: 36px; }
.btn-lg { padding: 0.85rem 1.75rem; font-size: 1rem; min-height: 52px; }
.btn-block { width: 100%; }
.btn-icon { padding: 0.6rem; min-width: 44px; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-info    { background: var(--color-info-bg); color: var(--color-info); }
.badge-neutral { background: var(--color-border); color: var(--color-text-muted); }

/* ---- Forms ---- */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
  color: var(--color-text);
}
.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
  min-height: 44px;
}
.form-control:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px rgba(20, 152, 138, 0.15);
  outline: none;
}
.form-hint { font-size: 0.78rem; color: var(--color-text-subtle); margin-top: 0.35rem; }
.form-error { font-size: 0.78rem; color: var(--color-danger); margin-top: 0.35rem; }

.input-group { position: relative; }
.input-group .form-control { padding-left: 2.75rem; }
.input-group-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-subtle);
  pointer-events: none;
}

/* ---- Toast notifications ---- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  left: 1rem;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: none;
}
@media (min-width: 640px) {
  .toast-container { left: auto; width: 380px; }
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(var(--blur-glass));
  -webkit-backdrop-filter: blur(var(--blur-glass));
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--duration-base) var(--ease-out-back);
}
.toast.toast-leaving { animation: toast-out var(--duration-fast) var(--ease-standard) forwards; }
.toast-icon { flex-shrink: 0; width: 22px; height: 22px; margin-top: 1px; }
.toast-body { flex: 1; font-size: 0.88rem; }
.toast-title { font-weight: 700; margin-bottom: 0.15rem; }
.toast-close { background: none; border: none; cursor: pointer; color: var(--color-text-subtle); padding: 0.2rem; min-height: auto; }
.toast-success { border-left: 4px solid var(--color-success); }
.toast-error   { border-left: 4px solid var(--color-danger); }
.toast-warning { border-left: 4px solid var(--color-warning); }
.toast-info    { border-left: 4px solid var(--color-info); }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 15, 24, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-standard);
}
.modal-backdrop.is-open { opacity: 1; pointer-events: auto; }

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(var(--blur-glass)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-glass)) saturate(160%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 1.75rem;
  transform: scale(0.94) translateY(10px);
  opacity: 0;
  transition: transform var(--duration-base) var(--ease-out-back), opacity var(--duration-base) var(--ease-standard);
}
.modal-backdrop.is-open .modal { transform: scale(1) translateY(0); opacity: 1; }

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.modal-title { font-size: 1.15rem; font-weight: 700; margin: 0; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--color-text-subtle); min-height: 36px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.5rem; }

/* ---- Skeleton loaders ---- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--color-border);
  border-radius: var(--radius-sm);
}
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  animation: skeleton-shimmer 1.4s infinite;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent); }
}
:root[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent); }
.skeleton-text { height: 0.9em; margin-bottom: 0.5em; border-radius: 4px; }
.skeleton-title { height: 1.4em; width: 40%; margin-bottom: 0.75em; }
.skeleton-avatar { width: 48px; height: 48px; border-radius: 50%; }
.skeleton-card { height: 120px; border-radius: var(--radius-lg); }

/* ---- Empty states ---- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--color-text-muted); }
.empty-state svg { margin: 0 auto 1rem; opacity: 0.5; }

/* ---- Stat tile ---- */
.stat-tile {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--color-accent);
  color: #fff;
}
.stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 0.8rem; color: var(--color-text-muted); }

/* ---- Tabs ---- */
.tabs-nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.25rem;
  -webkit-overflow-scrolling: touch;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  transition: color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
}
.tab-btn:hover { color: var(--color-text); }
.tab-btn.is-active { color: var(--color-accent); border-bottom-color: var(--color-accent); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fade-in var(--duration-base) var(--ease-standard); }

/* ---- Rich text editor ---- */
.rte { border: 1.5px solid var(--color-border-strong); border-radius: var(--radius-md); overflow: hidden; }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: 0.25rem; padding: 0.5rem; background: var(--color-border); border-bottom: 1px solid var(--color-border-strong); }
.rte-toolbar button {
  background: var(--color-surface); border: 1px solid var(--color-border-strong);
  border-radius: 6px; padding: 0.35rem 0.6rem; font-size: 0.8rem; font-weight: 700;
  cursor: pointer; color: var(--color-text); min-height: 32px;
}
.rte-toolbar button:hover { background: var(--color-accent); color: #fff; border-color: transparent; }
.rte-surface {
  min-height: 200px; padding: 1rem; background: var(--color-surface); color: var(--color-text);
  font-size: 0.9rem; line-height: 1.6; outline: none;
}
.rte-surface:focus { box-shadow: inset 0 0 0 2px var(--color-accent); }
.rte-surface p { margin: 0 0 0.75em; }
.rte-surface ul, .rte-surface ol { margin: 0 0 0.75em; padding-left: 1.5em; }
.rte-surface h2, .rte-surface h3 { margin: 0.5em 0; }

/* Rendered rich content on public pages */
.rich-content { line-height: 1.75; }
.rich-content p { margin: 0 0 1em; }
.rich-content ul, .rich-content ol { margin: 0 0 1em; padding-left: 1.5em; }
.rich-content img { border-radius: var(--radius-md); }
.rich-content a { text-decoration: underline; }

/* ---- Appearance picker (Site Builder blocks, Services) ---- */
.appearance-picker {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.25rem 1rem 1rem;
  margin: 0 0 1rem;
}
.appearance-picker legend {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-subtle);
  padding: 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.color-field { display: flex; align-items: center; gap: 0.5rem; }
.color-field input[type="color"] {
  width: 42px; height: 38px; padding: 2px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}
.color-field input[type="text"] { font-family: monospace; text-transform: uppercase; }

/* ---- Patient autocomplete picker ---- */
.patient-picker { position: relative; }
.patient-picker-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(var(--blur-glass));
  -webkit-backdrop-filter: blur(var(--blur-glass));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.35rem;
  max-height: 240px;
  overflow-y: auto;
}
/* The shared .dropdown-menu is hidden (opacity 0 / no pointer events) until
   .is-open is added; picker result lists are shown via [hidden] instead. */
.patient-picker-results.dropdown-menu { opacity: 1; transform: none; pointer-events: auto; transition: none; }

/* ---- Appointment slot picker ---- */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 0.6rem; }
.slot-pill {
  padding: 0.55rem 0.5rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all var(--duration-fast) var(--ease-standard);
  min-height: 44px;
}
.slot-pill:hover { border-color: var(--color-accent); color: var(--color-accent); }
.slot-pill.is-selected {
  background: linear-gradient(135deg, var(--brand-teal), var(--brand-teal-600));
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

/* ---- Timeline ---- */
.timeline { position: relative; padding-left: 1.75rem; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--color-border); }
.timeline-item { position: relative; padding-bottom: 1.5rem; }
.timeline-item::before {
  content: "";
  position: absolute; left: -1.75rem; top: 3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-surface);
  box-shadow: 0 0 0 2px var(--color-border);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-date { font-size: 0.72rem; color: var(--color-text-subtle); text-transform: uppercase; letter-spacing: 0.03em; }
.timeline-title { font-weight: 700; margin: 0.15rem 0; }
.timeline-subtitle { font-size: 0.85rem; color: var(--color-text-muted); }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--color-border); }
table.data-table { width: 100%; border-collapse: collapse; min-width: 480px; }
.data-table th, .data-table td { padding: 0.85rem 1rem; text-align: left; border-bottom: 1px solid var(--color-border); font-size: 0.88rem; }
.data-table th { font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.04em; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--duration-fast) var(--ease-standard); }
.data-table tbody tr:hover { background: var(--color-border); }

/* ---- About page ---- */
.about-hero { display: flex; align-items: center; gap: 1.5rem; margin-bottom: 1.5rem; }
.about-logo { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 3px solid var(--color-border); flex-shrink: 0; background: #fff; }
.about-name { font-size: 1.6rem; margin: 0 0 .15rem; }
.about-section { margin-bottom: 1.5rem; }
.about-features { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.about-feature { display: flex; gap: .9rem; padding: 1rem; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface-glass, transparent); }
.about-feature-icon { flex-shrink: 0; width: 44px; height: 44px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; color: var(--color-accent); background: var(--color-border); }
.about-feature-title { font-size: .95rem; margin: 0 0 .2rem; }
.about-feature-text { margin: 0; font-size: .85rem; color: var(--color-text-muted); }
.about-steps { list-style: none; margin: 0; padding: 0; }
.about-steps li { display: flex; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--color-border); }
.about-steps li:last-child { border-bottom: 0; }
.about-step-num { flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--color-accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; }
.about-dev { display: flex; align-items: center; gap: 1.5rem; }
.about-dev-logo { width: 120px; height: 120px; border-radius: 18px; object-fit: cover; flex-shrink: 0; background: #050a1a; }
.about-dev-list { margin: 0; display: grid; gap: .5rem; min-width: 0; }
.about-dev-list > div { display: grid; grid-template-columns: 110px 1fr; gap: .75rem; align-items: baseline; }
.about-dev-list dt { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-subtle); }
.about-dev-list dd { margin: 0; }
.about-accent { color: var(--color-accent); }
.about-whatsapp { background: #25d366; color: #fff; border: 0; gap: .5rem; }
.about-whatsapp:hover { background: #1ebe5b; color: #fff; text-decoration: none; }
@media (max-width: 639px) {
  .about-hero, .about-dev { flex-direction: column; align-items: flex-start; }
  .about-dev-list > div { grid-template-columns: 1fr; gap: .1rem; }
}
