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

:root {
  --primary:       #1a56a0;
  --primary-dark:  #0f3d7a;
  --primary-light: #e8f0fb;
  --accent:        #3b82f6;
  --success:       #16a34a;
  --danger:        #dc2626;
  --warning:       #d97706;
  --text:          #1e293b;
  --muted:         #64748b;
  --border:        #e2e8f0;
  --bg:            #f8fafc;
  --white:         #ffffff;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-sm:     0 1px 2px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── FLASH MESSAGES ─────────────────────────────── */
.flash {
  padding: 14px 18px;
  margin-bottom: 20px;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
  font-size: 14px;
}
.flash-notice { background: #eff6ff; border-color: var(--accent); color: #1e40af; }
.flash-alert  { background: #fef2f2; border-color: var(--danger); color: #991b1b; }
.flash-token  { background: #fffbeb; border-color: var(--warning); color: #92400e; }
.flash-token code { display: block; margin-top: 8px; font-family: monospace; font-size: 13px; word-break: break-all; background: rgba(0,0,0,0.05); padding: 6px 10px; border-radius: 4px; }

/* ── BUTTONS ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  transition: all 0.15s ease;
  line-height: 1;
  white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: var(--white); box-shadow: 0 1px 2px rgba(26,86,160,0.3); }
.btn-secondary { background: var(--white); color: var(--primary); border: 1.5px solid var(--border); }
.btn-danger    { background: var(--danger); color: var(--white); }
.btn-primary:hover   { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 8px rgba(26,86,160,0.25); text-decoration: none; color: var(--white); }
.btn-secondary:hover { background: var(--bg); border-color: var(--primary); text-decoration: none; }
.btn-danger:hover    { background: #b91c1c; transform: translateY(-1px); text-decoration: none; color: var(--white); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 28px; font-size: 16px; }

/* ── ADMIN LAYOUT ────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  background: linear-gradient(160deg, #1a3a6b 0%, #1a56a0 100%);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 0;
  flex-shrink: 0;
}
.sidebar-brand {
  padding: 28px 20px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.sidebar-brand h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; color: #ffffff; text-shadow: 0 1px 4px rgba(0,0,0,0.3); }
.sidebar-brand small { opacity: 0.75; font-size: 12px; display: block; margin-top: 3px; color: #ffffff; }
.sidebar ul { list-style: none; margin-top: 12px; flex: 1; padding: 0 10px; }
.sidebar ul li a {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
}
.sidebar ul li a:hover { background: rgba(255,255,255,0.12); color: var(--white); text-decoration: none; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 13px;
}
.sidebar-footer small { color: rgba(255,255,255,0.6); display: block; margin-bottom: 6px; }
.sidebar-footer button, .sidebar-footer form { display: inline; }
.sidebar-footer button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  font-family: inherit;
  transition: color 0.15s;
}
.sidebar-footer button:hover { color: var(--white); }

/* ── CLINICIAN LAYOUT ────────────────────────────── */
.clinician-layout { display: flex; flex-direction: column; min-height: 100vh; }

.topnav {
  background: linear-gradient(90deg, #1a3a6b 0%, #1a56a0 100%);
  display: flex;
  align-items: center;
  padding: 0 28px;
  height: 60px;
  gap: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.topnav-brand { color: var(--white); font-weight: 700; font-size: 17px; letter-spacing: -0.3px; }
.topnav ul { display: flex; list-style: none; gap: 4px; margin-left: auto; align-items: center; }
.topnav ul li a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
.topnav ul li a:hover { background: rgba(255,255,255,0.15); color: var(--white); text-decoration: none; }
.topnav ul li button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.topnav ul li button:hover { background: rgba(255,255,255,0.15); color: var(--white); }

/* ── MAIN CONTENT ────────────────────────────────── */
.main-content { flex: 1; padding: 32px 36px; }
.admin-layout .main-content { overflow-y: auto; }

h1 { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.4px; margin-bottom: 24px; }
h2 { font-size: 17px; font-weight: 600; color: var(--text); margin: 24px 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 20px 0 10px; }
p  { line-height: 1.6; margin-bottom: 12px; color: var(--muted); }

/* ── PAGE HEADER ─────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 { margin-bottom: 0; }

/* ── STAT CARDS (legacy) ─────────────────────────── */
.stat-cards { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 32px; }
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 160px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-number { font-size: 40px; font-weight: 700; color: var(--primary); }
.stat-label  { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

/* ── TABLE ───────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table th { background: var(--primary); color: var(--white); padding: 13px 16px; text-align: left; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 14px; }
.table tr:last-child td { border-bottom: none; }
.table tr.inactive td { opacity: 0.5; }
.table tr:hover td { background: var(--bg); }
.text-center { text-align: center; }

/* ── BADGES ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-active   { background: #dcfce7; color: #15803d; }
.badge-inactive { background: #fee2e2; color: #dc2626; }
.badge-pending  { background: #fef9c3; color: #a16207; }
.badge-current  { background: #dcfce7; color: #15803d; }
.badge-desired  { background: #ede9fe; color: #6d28d9; }

/* ── FORMS ───────────────────────────────────────── */
.form-group { margin-bottom: 22px; }
.form-group label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 7px; color: var(--text); }
.form-control {
  width: 100%;
  max-width: 480px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
textarea.form-control { resize: vertical; }
.form-check { display: flex; align-items: center; gap: 10px; }
.form-check-input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }
.form-actions { margin-top: 32px; display: flex; gap: 12px; align-items: center; }
.form-errors {
  background: #fef2f2;
  border-left: 4px solid var(--danger);
  padding: 14px 16px;
  margin-bottom: 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: #991b1b;
}
.form-errors ul { margin-left: 16px; }

/* ── DETAIL LIST ─────────────────────────────────── */
.detail-list { margin-bottom: 24px; }
.detail-list dt { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 18px; }
.detail-list dd { font-size: 15px; margin-top: 3px; }

/* ── QUICK ACTIONS ───────────────────────────────── */
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }

/* ── SKILLS GRID ─────────────────────────────────── */
.skills-grid { display: flex; flex-direction: column; gap: 20px; }
.skill-category {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.skill-category h3 {
  background: var(--primary);
  color: var(--white);
  margin: 0;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.skills-table { width: 100%; border-collapse: collapse; }
.skills-table th { background: var(--bg); padding: 10px 18px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); }
.skills-table td { padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: 14px; }
.skills-table tr:last-child td { border-bottom: none; }
.skill-desc { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ── ALERT ───────────────────────────────────────── */
.alert { padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14px; }
.alert-info { background: #eff6ff; border-left: 4px solid var(--accent); color: #1e40af; }
.alert-info a { color: var(--primary); font-weight: 600; }

/* ── DEVISE FORMS ────────────────────────────────── */
#new_user, #edit_user {
  max-width: 440px;
  background: var(--white);
  padding: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin: 60px auto;
}

/* ── SKILL SHOW ──────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}
.two-col h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.two-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.two-col ul li {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
}
.two-col ul li:last-child { border-bottom: none; }

/* ── DASHBOARD CARDS ─────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 4px;
}
.dash-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}
.dash-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
.dash-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--white) 100%);
}
.dash-stat {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -1px;
}
.dash-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 4px;
}
.dash-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 340px;
  overflow-y: auto;
}
.dash-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  transition: background 0.1s;
}
.dash-list li:last-child { border-bottom: none; }
.dash-list li:hover { background: var(--bg); }
.dash-list-category {
  font-size: 11px !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted) !important;
  background: var(--bg) !important;
  padding: 7px 24px !important;
}
.dash-empty {
  color: var(--muted);
  font-style: italic;
  font-size: 14px;
}
.dash-meta {
  font-size: 12px;
  color: var(--muted);
}
.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── ANALYTICS ───────────────────────────────────── */
.analytics-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.analytics-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  transition: width 0.3s ease;
}
.analytics-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-left: 16px;
  white-space: nowrap;
}

/* ── PLAN BADGES ─────────────────────────────────── */
.badge-gold   { background: #fef3c7; color: #92400e; }
.badge-silver { background: #f1f5f9; color: #475569; }
.badge-bronze { background: #fde8d8; color: #9a3412; }

/* ── FIXED SIGN OUT (clinician) ──────────────────── */
.fixed-signout {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 200px;
  padding: 12px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  z-index: 100;
}
.fixed-signout small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fixed-signout button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  font-family: inherit;
  transition: color 0.15s;
}
.fixed-signout button:hover { color: var(--text); }

/* ── SCHEDULE GRID ───────────────────────────────── */
.schedule-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.schedule-row {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}
.schedule-row--active {
  border-color: var(--primary);
}
.schedule-row-header {
  padding: 14px 18px;
}
.schedule-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.schedule-toggle input[type=checkbox] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.schedule-slot-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.schedule-locations {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 14px;
}
.location-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  background: var(--bg);
  transition: all 0.12s;
  user-select: none;
}
.location-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.location-chip--selected {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* ── SCHEDULE SAVE BAR ───────────────────────────── */
.schedule-save-bar {
  position: fixed;
  bottom: 24px;
  right: 32px;
  z-index: 99;
}
