/* ── OPDFlow Shared Stylesheet ── */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables ── */
:root {
  /* Light theme (default) */
  --bg:          #f5f7fa;
  --surface:     #ffffff;
  --surface2:    #f0f4f8;
  --border:      #e2e8f0;
  --border2:     #cbd5e1;
  --accent:      #2563eb;
  --accent-light:#eff6ff;
  --accent-dark: #1d4ed8;
  --text:        #0f172a;
  --text2:       #334155;
  --muted:       #64748b;
  --muted-light: #94a3b8;
  --success:     #16a34a;
  --success-bg:  #f0fdf4;
  --success-bdr: #bbf7d0;
  --warning:     #d97706;
  --warning-bg:  #fffbeb;
  --warning-bdr: #fde68a;
  --error:       #dc2626;
  --error-bg:    #fef2f2;
  --error-bdr:   #fecaca;
  --shadow:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   16px;
  --nav-height:  64px;
}

/* Dark theme */
[data-theme="dark"] {
  --bg:          #0f172a;
  --surface:     #1e293b;
  --surface2:    #0f172a;
  --border:      #334155;
  --border2:     #475569;
  --accent:      #3b82f6;
  --accent-light:#1e3a5f;
  --accent-dark: #60a5fa;
  --text:        #f1f5f9;
  --text2:       #cbd5e1;
  --muted:       #94a3b8;
  --muted-light: #64748b;
  --success:     #22c55e;
  --success-bg:  #052e16;
  --success-bdr: #166534;
  --warning:     #f59e0b;
  --warning-bg:  #1c1400;
  --warning-bdr: #78350f;
  --error:       #ef4444;
  --error-bg:    #2d0000;
  --error-bdr:   #7f1d1d;
  --shadow:      0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:   0 4px 6px rgba(0,0,0,0.4);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

/* ── Typography ── */
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p  { color: var(--text2); }

/* ── Header ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow);
}

.header-left { display: flex; flex-direction: column; }

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.clinic-info {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Theme Toggle ── */
.theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.theme-toggle:hover { background: var(--border); }

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 90;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  text-decoration: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  transition: color 0.15s;
  border: none;
  background: transparent;
  padding: 0;
}

.nav-item svg { width: 22px; height: 22px; stroke-width: 1.8; }
.nav-item.active { color: var(--accent); }
.nav-item.active svg { stroke-width: 2.2; }

.nav-item.danger { color: var(--error); }
.nav-item.danger:hover { opacity: 0.8; }

/* ── Page content wrapper (accounts for bottom nav) ── */
.page-content {
  padding-bottom: calc(var(--nav-height) + 20px);
  min-height: 100vh;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-num {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 500;
}

.stat-num.blue   { color: var(--accent); }
.stat-num.green  { color: var(--success); }
.stat-num.red    { color: var(--error); }

/* ── Up Next banner ── */
.up-next {
  margin: 0 20px 16px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.up-next-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 6px;
}

.up-next-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.up-next-time {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Date bar ── */
.date-bar {
  padding: 4px 20px 14px;
  font-size: 13px;
  color: var(--muted);
}

.date-bar strong { color: var(--text); }

/* ── Section heading ── */
.section-heading {
  padding: 0 20px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

/* ── Appointment list ── */
.apt-list {
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.apt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: opacity 0.3s, border-color 0.3s;
}

.apt-card.is-completed {
  opacity: 0.55;
  border-color: var(--success-bdr);
  background: var(--success-bg);
  box-shadow: none;
}

.apt-card.is-cancelled {
  opacity: 0.45;
  border-color: var(--border);
  box-shadow: none;
}

.apt-card.is-completed .apt-name {
  text-decoration: line-through;
  text-decoration-color: var(--success);
  text-decoration-thickness: 2px;
}

.apt-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.token {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 9px;
  white-space: nowrap;
  flex-shrink: 0;
}

[data-theme="dark"] .token {
  background: rgba(59,130,246,0.15);
  border-color: rgba(59,130,246,0.4);
}

.apt-info { min-width: 0; }

.apt-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.apt-time { font-size: 12px; color: var(--muted); margin-top: 2px; }

.apt-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn-primary:hover  { background: var(--accent-dark); }
.btn-primary:active { transform: scale(0.96); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-ghost:hover { border-color: var(--error); color: var(--error); }

.btn-full {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  border-radius: var(--radius);
}

.btn-danger {
  background: var(--error);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-danger:hover { opacity: 0.85; }

/* ── Status badges ── */
.badge {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-bdr);
}

.badge-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-bdr);
}

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-icon { font-size: 44px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text2); }
.empty-sub { font-size: 13px; margin-top: 4px; }

/* ── Follow-up Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-backdrop.show { display: flex; }

.modal {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 12px 24px 32px;
  width: 100%;
  max-width: 540px;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-handle {
  width: 36px; height: 4px;
  background: var(--border2);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.modal-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.modal-subtitle strong { color: var(--text); font-weight: 600; }

/* Days input */
.days-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.days-row label { font-size: 13px; color: var(--muted); white-space: nowrap; }

.days-big {
  background: transparent;
  border: none;
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  width: 70px;
  outline: none;
  text-align: center;
  font-family: inherit;
  -moz-appearance: textfield;
}

.days-big::-webkit-outer-spin-button,
.days-big::-webkit-inner-spin-button { -webkit-appearance: none; }

.days-suffix { font-size: 14px; color: var(--muted); }

/* Preset chips */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 5px 14px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.chip.active, .chip:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

[data-theme="dark"] .chip.active,
[data-theme="dark"] .chip:hover {
  background: rgba(59,130,246,0.15);
}

.modal-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Form elements ── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.4;
}

/* ── Alert box ── */
.alert {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
  line-height: 1.4;
}

.alert.show { display: block; }
.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid var(--error-bdr); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-bdr); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-bdr); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--surface);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 18px;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Page sections ── */
.page-section {
  padding: 20px;
}

.page-section + .page-section {
  padding-top: 0;
}

/* ── Info card (leave/absence) ── */
.info-card {
  background: var(--warning-bg);
  border: 1px solid var(--warning-bdr);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--warning);
  line-height: 1.5;
}

/* ── Loading skeleton ── */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Login page specific ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}

.login-footer {
  text-align: center;
  font-size: 11px;
  color: var(--muted-light);
  margin-top: 24px;
}

/* ── Responsive ── */
@media (min-width: 600px) {
  .stats-grid   { padding: 20px 28px; }
  .apt-list     { padding: 0 28px; }
  .date-bar     { padding: 4px 28px 14px; }
  .up-next      { margin: 0 28px 16px; }
  .section-heading { padding: 0 28px 10px; }
  .page-section { padding: 20px 28px; }
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; }
}