/* ══════════════════════════════════════════════════
   TutorNow Web — Global Styles
   ══════════════════════════════════════════════════
   Design tokens (CSS custom properties) define all
   colors, spacing, radii, and shadows. Components
   reference these tokens so dark mode only needs to
   override the variables — not every selector.
   ══════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
  /* Brand */
  --primary: #007AFF;
  --primary-light: #5AC8FA;
  --primary-dark: #0051A8;
  --accent: #34C759;
  --accent-light: #30D158;
  --danger: #FF3B30;
  --warning: #FF9500;
  --purple: #AF52DE;

  /* Surfaces */
  --bg: #F2F2F7;
  --bg-card: #FFFFFF;

  /* Text */
  --text: #000000;
  --text-secondary: #8E8E93;
  --text-light: #8E8E93;          /* lighter than --text-secondary in dark mode */

  /* Borders & effects */
  --border: #D1D1D6;
  --border-focus: #007AFF;
  --radius: 12px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);

  /* Layout & motion */
  --transition: 0.25s ease;
  --max-width: 1200px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

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

/* ── Typography ── */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.375rem; font-weight: 600; }
h3 { font-size: 1.125rem; font-weight: 600; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm); font-size: 0.9375rem;
  font-weight: 600; border: none; cursor: pointer; transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: #E5E5EA; color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #D1D1D6; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #D70015; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: #248A3D; }
.btn-outline {
  background: transparent; color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover:not(:disabled) { background: var(--primary); color: #fff; }
.btn-outline:hover:not(:disabled) .custom-icon { filter: brightness(0) invert(1); }
.btn-outline-danger {
  background: transparent; color: var(--danger);
  border: 2px solid var(--danger);
}
.btn-outline-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 0.8125rem; }
.btn-lg { padding: 14px 28px; font-size: 1.0625rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; border-radius: 50%; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px; font-size: 0.875rem;
  font-weight: 500; color: var(--text-secondary);
}
.form-control {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.9375rem; background: var(--bg-card);
  transition: border-color var(--transition);
}
.form-control:focus {
  outline: none; border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0,122,255,0.15);
}
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Cards ── */
.card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

/* ── Layout ── */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }
.page { flex: 1; padding: 20px 0; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* ── Navbar ── */
.navbar {
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 12px 0; position: sticky; top: 0; z-index: 100;
}
.navbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--max-width); margin: 0 auto; padding: 0 20px;
}
.navbar-brand {
  display: flex; align-items: center; gap: 8px; font-size: 1.25rem;
  font-weight: 700; color: var(--primary); text-decoration: none;
}
.navbar-brand:hover { text-decoration: none; }
.navbar-links { display: flex; align-items: center; gap: 8px; }
.nav-link {
  padding: 8px 16px; border-radius: var(--radius-sm); font-size: 0.875rem;
  font-weight: 500; color: var(--text-secondary); transition: all var(--transition);
  cursor: pointer; text-decoration: none; border: none; background: none;
}
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }

/* ── Icon Tinting System ──
   All icons are PNGs with blue (#007AFF) pixels on transparent bg.
   CSS `filter` controls their visible color in every context:

   State                  Filter                          Result
   ─────────────────────  ──────────────────────────────  ──────────
   Inactive (nav/tab)     grayscale(1) opacity(0.4)       faint grey
   Hover (inactive)       grayscale(1) opacity(0.6)       medium grey
   Active on colored bg   brightness(0) invert(1)         white
     (nav-link, toggle,
      btn-primary, etc.)
   Active tab-item        filter: none                    original blue
     (mobile tab bar)
   Badge icon             filter: none                    original color

   Dark mode overrides only the inactive/hover states (see Dark Mode
   section below). Active icons inherit the base white filter. */

.custom-icon { transition: filter var(--transition); }

/* Inactive icons — greyed out */
.nav-link:not(.active) .custom-icon,
.tab-item:not(.active) .custom-icon { filter: grayscale(1) opacity(0.4); }

/* Active icons on colored backgrounds — white */
.nav-link.active .custom-icon,
.toggle-option.active .custom-icon,
.admin-tab.active .custom-icon,
.btn-primary .custom-icon,
.btn-accent .custom-icon,
.btn-danger .custom-icon,
.video-btn .custom-icon { filter: brightness(0) invert(1); }

/* Active tab-item + badges — keep original icon color */
.tab-item.active .custom-icon,
.badge .custom-icon { filter: none; }

/* Hover (inactive only) — slightly lighter */
.nav-link:hover:not(.active) .custom-icon { filter: grayscale(1) opacity(0.6); }

/* Slash-through overlay for off-state video buttons */
.btn-icon-wrap {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon-wrap.slash::after {
  content: ''; position: absolute; top: -2px; left: 50%; width: 2px; height: 28px;
  background: #fff; transform: translateX(-50%) rotate(-45deg);
  pointer-events: none;
}

/* ── Tab bar (bottom on mobile) ── */
.tab-bar {
  display: flex; background: var(--bg-card); border-top: 1px solid var(--border);
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  padding: 8px 0; padding-bottom: env(safe-area-inset-bottom, 8px);
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 6px; font-size: 0.6875rem; color: var(--text-light);
  cursor: pointer; border: none; background: none; transition: color var(--transition);
  text-decoration: none;
}
.tab-item.active { color: var(--primary); }
.tab-item .tab-icon { font-size: 1.25rem; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
}
/* note: badge-primary is an alias for badge-blue (kept for backward compat) */
.badge-primary,
.badge-blue { background: rgba(0,122,255,0.12); color: #007AFF; }
.badge-green { background: rgba(52,199,89,0.12); color: #248A3D; }
.badge-red { background: rgba(255,59,48,0.12); color: #FF3B30; }
.badge-yellow { background: rgba(255,149,0,0.12); color: #C25700; }
.badge-purple { background: rgba(175,82,222,0.12); color: #AF52DE; }
.badge-gray { background: #E5E5EA; color: #8E8E93; }

/* ── Star ratings ── */
.stars { display: flex; gap: 2px; }
.star { color: #D1D1D6; font-size: 1.125rem; cursor: pointer; }
.star.filled { color: #FF9500; }
.star-display { cursor: default; }

/* ── Toggle / Switch ── */
.toggle {
  display: flex; background: var(--border); border-radius: 999px;
  padding: 3px; width: fit-content;
}
.toggle-option {
  padding: 8px 20px; border-radius: 999px; font-size: 0.8125rem;
  font-weight: 600; cursor: pointer; transition: all var(--transition);
  border: none; background: none; color: var(--text-secondary);
}
.toggle-option.active { background: var(--primary); color: #fff; }

/* ── Map ── */
.map-container { width: 100%; height: 400px; border-radius: var(--radius); overflow: hidden; }
#map { height: 100%; width: 100%; }

/* ── Tutor Card ── */
.tutor-card {
  display: flex; gap: 16px; padding: 16px; background: var(--bg-card);
  border-radius: var(--radius); border: 1px solid var(--border);
  cursor: pointer; transition: all var(--transition);
}
.tutor-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.tutor-card .avatar {
  width: 56px; height: 56px; border-radius: 50%; background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; color: #fff; font-weight: 700; flex-shrink: 0;
}
.tutor-card .info { flex: 1; min-width: 0; }
.tutor-card .name { font-weight: 600; font-size: 1rem; }
.tutor-card .subjects {
  font-size: 0.8125rem; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tutor-card .rate { font-size: 1.125rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.tutor-card .rate.free { color: var(--primary); }
.tutor-card .meta { display: flex; align-items: center; gap: 12px; margin-top: 4px; font-size: 0.8125rem; }

/* ── Request Card (tutor side) ── */
.request-card {
  background: var(--bg-card); border-radius: var(--radius);
  border: 2px solid var(--border); padding: 16px;
  transition: border-color var(--transition), opacity var(--transition);
}
.request-card.expiring { border-color: var(--warning); }
.request-card.urgent { border-color: var(--danger); }
.request-card .countdown {
  font-size: 0.75rem; font-weight: 700; padding: 2px 8px;
  border-radius: 999px;
}
.request-card .countdown.green { background: rgba(52,199,89,0.12); color: #34C759; }
.request-card .countdown.orange { background: rgba(255,149,0,0.12); color: #FF9500; }
.request-card .countdown.red { background: rgba(255,59,48,0.12); color: #FF3B30; }
.request-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ── Session Overlay ── */
.session-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.session-overlay .overlay-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 32px; max-width: 400px; width: 90%; text-align: center;
}

/* ── Video Call ── */
.video-container {
  position: fixed; inset: 0; background: #000; z-index: 300;
  display: flex; flex-direction: column;
}
.video-main { flex: 1; position: relative; overflow: hidden; }
.video-placeholder {
  width: 100%; height: 100%;
  color: #fff; font-size: 1.25rem; text-align: center;
  display: flex; align-items: center; justify-content: center;
}
.video-local {
  position: absolute; top: 16px; right: 16px; width: 120px; height: 90px;
  background: #374151; border-radius: var(--radius-sm); border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center; color: #9CA3AF;
  overflow: hidden; z-index: 10;
}
#remote-video-wrapper {
  position: absolute; inset: 0; overflow: hidden;
}
#remote-video-wrapper video,
.video-local video {
  position: absolute; top: 0; left: 0;
  width: 100% !important; height: 100% !important;
  object-fit: cover !important;
}
.video-controls {
  display: flex; justify-content: center; gap: 16px; padding: 20px;
  background: rgba(0,0,0,0.8);
}
.video-btn {
  width: 48px; height: 48px; border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; cursor: pointer; transition: all var(--transition);
}
.video-btn.active { background: #374151; color: #fff; }
.video-btn.inactive { background: #EF4444; color: #fff; }
.video-btn.hidden { display: none; }
.video-btn.end-call { background: #EF4444; color: #fff; width: 64px; border-radius: 24px; }
.video-btn.end-session { background: #EF4444; color: #fff; width: auto; border-radius: 24px; padding: 0 20px; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.video-btn .custom-icon { filter: brightness(0) invert(1); opacity: 1; }

/* ── Screen Share ── */
.screen-share-wrapper {
  position: absolute; inset: 0; z-index: 15; background: #000;
  display: flex; align-items: center; justify-content: center;
}
.screen-share-wrapper.hidden { display: none; }
.screen-share-wrapper video {
  max-width: 100%; max-height: 100%; object-fit: contain;
}

/* ── Whiteboard ── */
.whiteboard-overlay {
  position: absolute; inset: 0; z-index: 20;
  background: #1a1a2e;
  display: flex; flex-direction: column;
}
.whiteboard-overlay.hidden { display: none; }
.whiteboard-overlay canvas {
  flex: 1; cursor: crosshair;
  touch-action: none;
}
#whiteboard-toolbar {
  display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  background: rgba(0,0,0,0.85); justify-content: center; flex-wrap: wrap;
}
.wb-tools { display: flex; gap: 4px; }
.wb-tool-btn {
  width: 32px; height: 32px; border-radius: 6px; border: 1px solid #555;
  background: #374151; color: #fff; cursor: pointer; display: flex;
  align-items: center; justify-content: center; padding: 0;
  transition: background 0.15s, border-color 0.15s;
}
.wb-tool-btn:hover { background: #4B5563; }
.wb-tool-btn.active { border-color: #fff; background: #4B5563; }
.wb-divider { width: 1px; height: 24px; background: #555; }
.wb-text-input {
  position: absolute; background: transparent; border: 1px dashed rgba(255,255,255,0.5);
  color: #fff; font-family: sans-serif; outline: none; padding: 2px 4px;
  min-width: 80px; z-index: 30;
}
.wb-colors { display: flex; gap: 6px; }
.wb-color-btn {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0; transition: border-color 0.15s;
}
.wb-color-btn.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,0.4); }
.wb-sizes { display: flex; gap: 6px; align-items: center; }
.wb-size-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid #555;
  background: #374151; cursor: pointer; display: flex; align-items: center;
  justify-content: center; padding: 0;
}
.wb-size-btn span {
  display: block; border-radius: 50%; background: #fff;
}
.wb-size-btn.active { border-color: #fff; background: #4B5563; }
.wb-clear-btn {
  padding: 4px 12px; border-radius: 6px; border: 1px solid #555;
  background: #374151; color: #fff; cursor: pointer; font-size: 0.75rem;
}
.wb-clear-btn:hover { background: #4B5563; }

/* Whiteboard toolbar mobile */
@media (max-width: 600px) {
  #whiteboard-toolbar {
    gap: 6px; padding: 6px 8px; overflow-x: auto; flex-wrap: nowrap;
    justify-content: flex-start; -webkit-overflow-scrolling: touch;
  }
  .wb-tool-btn { width: 28px; height: 28px; min-width: 28px; }
  .wb-color-btn { width: 20px; height: 20px; min-width: 20px; }
  .wb-size-btn { width: 24px; height: 24px; min-width: 24px; }
  .wb-colors { gap: 4px; }
  .wb-sizes { gap: 4px; }
  .wb-tools { gap: 2px; }
  .wb-divider { height: 20px; min-width: 1px; }
  .wb-clear-btn { padding: 3px 8px; font-size: 0.6875rem; white-space: nowrap; }
}

/* Whiteboard mode: camera strip at top-center, whiteboard below */
.wb-mode::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 110px;
  background: #1a1a2e; z-index: 21; pointer-events: none;
}
.wb-mode #remote-video-wrapper {
  inset: auto;
  position: absolute; top: 10px; left: calc(50% - 124px);
  width: 120px; height: 90px; border-radius: 8px; overflow: hidden;
  border: 2px solid rgba(255,255,255,0.3); z-index: 25;
}
.wb-mode .video-local {
  inset: auto;
  top: 10px; left: calc(50% + 4px); right: auto;
  width: 120px; height: 90px; z-index: 25;
}
.wb-mode .whiteboard-overlay {
  top: 110px;
}

/* ── Toast ── */
#toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm);
  color: #fff; font-weight: 500; font-size: 0.875rem;
  animation: slideIn 0.3s ease; min-width: 250px; max-width: 400px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
}
.toast-success { background: #34C759; }
.toast-error { background: #FF3B30; }
.toast-info { background: #007AFF; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Request Notification Banner ── */
.request-notification-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 300;
  background: linear-gradient(135deg, #007AFF, #0051D5);
  color: #fff; padding: 0; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: bannerSlideDown 0.3s ease-out;
}
.request-banner-content {
  max-width: 800px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
}
.request-banner-icon { font-size: 1.5rem; }
.request-banner-icon .custom-icon { filter: brightness(0) invert(1); }
.request-banner-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.request-banner-text strong { font-size: 0.9375rem; }
.request-banner-text span { font-size: 0.8125rem; opacity: 0.9; }
.request-banner-close {
  background: none; border: none; color: #fff; font-size: 1.5rem;
  cursor: pointer; padding: 0 4px; opacity: 0.7; line-height: 1;
}
.request-banner-close:hover { opacity: 1; }
@keyframes bannerSlideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* ── Loading ── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,0.8);
  display: flex; align-items: center; justify-content: center; z-index: 500;
}
.spinner {
  width: 40px; height: 40px; border: 4px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-sm { width: 20px; height: 20px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Searching animation ── */
.searching-pulse {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary); animation: pulse 1.5s ease infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: 0.5; } }

/* ── Auth page ── */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.auth-card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 40px; max-width: 420px; width: 100%;
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo .icon { font-size: 3rem; }
.auth-logo h1 { margin-top: 8px; color: var(--primary); }
.auth-divider {
  display: flex; align-items: center; gap: 12px; margin: 20px 0;
  color: var(--text-light); font-size: 0.8125rem;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.social-btn {
  width: 100%; padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-card);
  font-size: 0.9375rem; cursor: pointer; display: flex;
  align-items: center; justify-content: center; gap: 10px;
  transition: all var(--transition); font-weight: 500;
}
.social-btn:hover { background: var(--bg); border-color: var(--text-light); }
.social-buttons { display: flex; flex-direction: column; gap: 10px; }
.social-btn-apple { background: #000; color: #fff; border-color: #000; }
.social-btn-apple:hover { background: #222; border-color: #222; }
.social-btn-phone { color: var(--primary); border-color: var(--primary); }
.social-btn-phone:hover { background: rgba(0,122,255,0.06); }

/* ── Profile ── */
.profile-header {
  display: flex; align-items: center; gap: 20px; margin-bottom: 24px;
}
.profile-avatar {
  width: 80px; height: 80px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: #fff; font-weight: 700; flex-shrink: 0;
}
img.profile-avatar {
  display: block; object-fit: cover;
}
.profile-avatar-wrapper { position: relative; flex-shrink: 0; }
.avatar-overlay {
  position: absolute; bottom: 0; right: 0; width: 28px; height: 28px;
  border-radius: 50%; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s;
}
.profile-avatar-wrapper:hover .avatar-overlay { opacity: 1; }
.stat-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.stat-card {
  text-align: center; padding: 16px; background: var(--bg);
  border-radius: var(--radius-sm);
}
.stat-card .value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 0.75rem; color: var(--text-secondary); }

/* ── Settings ── */
.settings-list { list-style: none; }
.settings-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--border); cursor: pointer;
}
.settings-item:last-child { border-bottom: none; }
.settings-item:hover { color: var(--primary); }

/* ── Session History ── */
.session-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px; border-bottom: 1px solid var(--border);
}
.session-item:last-child { border-bottom: none; }

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-secondary);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

/* ── Payment card ── */
.payment-card-display {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; background: var(--bg); border-radius: var(--radius-sm);
}
.payment-card-display .card-icon { font-size: 2rem; }

/* ── Desktop layout ── */
@media (min-width: 768px) {
  .tab-bar { display: none; }
  .page-with-sidebar {
    display: grid; grid-template-columns: 280px 1fr; gap: 24px;
    max-width: var(--max-width); margin: 0 auto; padding: 24px 20px;
  }
  .sidebar {
    background: var(--bg-card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px; height: fit-content;
    position: sticky; top: 80px;
  }
  .main-content { min-width: 0; }
  .map-container { height: 500px; }
}

/* ── Mobile layout ── */
@media (max-width: 767px) {
  .navbar-links { display: none; }
  .page { padding-bottom: 80px; }
  .auth-card { padding: 24px; }
  .profile-header { flex-direction: column; text-align: center; }
  .stat-grid { grid-template-columns: repeat(3,1fr); gap: 8px; }
  .stat-card { padding: 10px; }
  .stat-card .value { font-size: 1.125rem; }
  h1 { font-size: 1.375rem; }
}

/* ── Stripe Element ── */
.stripe-element {
  padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-card);
}

/* ── Multi-select tags ── */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 4px 12px; border-radius: 999px; font-size: 0.75rem;
  font-weight: 500; cursor: pointer; border: 1px solid var(--border);
  transition: all var(--transition);
}
.tag.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.tag:hover:not(.selected) { border-color: var(--primary); }

/* ── Searchable picker ── */
.searchable-picker { position: relative; }
.searchable-picker .picker-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.875rem;
  background: var(--bg-card); color: var(--text);
}
.searchable-picker .picker-input:focus { border-color: var(--border-focus); outline: none; }
.searchable-picker .picker-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
  max-height: 200px; overflow-y: auto; background: var(--bg-card);
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow-lg); display: none;
}
.searchable-picker .picker-dropdown.open { display: block; }
.searchable-picker .picker-option {
  padding: 8px 12px; cursor: pointer; font-size: 0.8125rem;
  border-bottom: 1px solid var(--bg);
}
.searchable-picker .picker-option:hover { background: rgba(0,122,255,0.08); }
.searchable-picker .picker-option.selected-opt { background: rgba(0,122,255,0.12); font-weight: 600; }
.searchable-picker .picker-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.searchable-picker .picker-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; background: var(--primary); color: #fff;
  border-radius: 999px; font-size: 0.75rem; font-weight: 500;
}
.searchable-picker .picker-chip .chip-remove {
  cursor: pointer; font-size: 0.875rem; line-height: 1; opacity: 0.8;
}
.searchable-picker .picker-chip .chip-remove:hover { opacity: 1; }
.searchable-picker .picker-no-results {
  padding: 8px 12px; color: var(--text-secondary); font-size: 0.8125rem; font-style: italic;
}

/* ── Admin Dashboard ── */
.admin-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.admin-tab {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary);
}
.admin-tab.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
/* admin-tab.active .custom-icon now handled by consolidated icon rule above */

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-width: 500px; width: 90%;
  max-height: 90vh; overflow-y: auto; padding: 24px;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.modal-close {
  background: none; border: none; font-size: 1.5rem;
  cursor: pointer; color: var(--text-secondary);
}

/* ── Calendar ── */
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.cal-nav {
  display: flex; align-items: center; gap: 8px;
}
.cal-title {
  font-size: 1.125rem; font-weight: 600; min-width: 180px; text-align: center;
}
.cal-body { min-height: 300px; }

/* ── Day view ── */
.cal-day-grid { display: flex; flex-direction: column; }
.cal-time-slot {
  display: flex; min-height: 56px; border-bottom: 1px solid var(--border);
}
.cal-time-label {
  width: 64px; flex-shrink: 0; font-size: 0.75rem; color: var(--text-secondary);
  padding: 4px 8px 0 0; text-align: right;
}
.cal-time-content { flex: 1; padding: 2px 4px; display: flex; flex-wrap: wrap; gap: 4px; }

/* ── Week view ── */
.cal-week-grid { overflow-x: auto; }
.cal-week-header {
  display: flex; position: sticky; top: 0; z-index: 2;
  background: var(--bg-card); border-bottom: 2px solid var(--border);
}
.cal-day-header {
  flex: 1; min-width: 90px; text-align: center; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center;
}
.cal-day-name { font-size: 0.75rem; text-transform: uppercase; color: var(--text-secondary); font-weight: 600; }
.cal-day-num { font-size: 1rem; font-weight: 600; margin-top: 2px; }
.cal-today .cal-day-name { color: var(--primary); }
.cal-today-num {
  background: var(--primary); color: #fff; border-radius: 50%;
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
}
.cal-week-row {
  display: flex; border-bottom: 1px solid var(--border);
}
.cal-time-gutter {
  width: 64px; flex-shrink: 0; padding: 4px 8px 0 0;
  display: flex; justify-content: flex-end;
}
.cal-time-gutter .cal-time-label { width: auto; }
.cal-week-cell {
  flex: 1; min-width: 90px; min-height: 48px; padding: 2px;
  border-left: 1px solid var(--border);
}

/* ── Month view ── */
.cal-month-grid { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-card); }
.cal-month-header { display: flex; background: var(--bg); }
.cal-month-day-label {
  flex: 1; text-align: center; padding: 8px 4px; font-size: 0.75rem;
  font-weight: 600; text-transform: uppercase; color: var(--text-secondary);
}
.cal-month-body { display: flex; flex-wrap: wrap; }
.cal-month-cell {
  width: calc(100% / 7); min-height: 80px; padding: 4px;
  border-top: 1px solid var(--border); border-right: 1px solid var(--border);
  cursor: pointer; transition: background var(--transition);
}
.cal-month-cell:nth-child(7n) { border-right: none; }
.cal-month-cell:hover { background: var(--bg); }
.cal-month-cell-empty { background: var(--bg); cursor: default; }
.cal-month-cell-empty:hover { background: var(--bg); }
.cal-month-num { font-size: 0.8125rem; font-weight: 600; display: block; margin-bottom: 2px; }
.cal-month-dots { display: flex; gap: 3px; margin-bottom: 2px; align-items: center; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.cal-dot-more { font-size: 0.625rem; color: var(--text-secondary); }
.cal-month-event {
  font-size: 0.6875rem; padding: 1px 4px; border-radius: 4px;
  margin-bottom: 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  cursor: pointer; font-weight: 500;
}
.cal-month-event-time { font-weight: 400; }
.cal-month-more { font-size: 0.6875rem; color: var(--text-secondary); cursor: pointer; }

/* ── Event blocks ── */
.cal-event {
  padding: 6px 8px; border-radius: 6px; margin-bottom: 4px;
  cursor: pointer; transition: box-shadow var(--transition);
}
.cal-event:hover { box-shadow: var(--shadow); }
.cal-event-compact {
  padding: 3px 6px; border-radius: 4px; margin-bottom: 2px;
  cursor: pointer; font-size: 0.75rem;
}
.cal-event-header { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.cal-event-title { font-weight: 600; font-size: 0.8125rem; }
.cal-event-compact .cal-event-title { font-size: 0.75rem; }
.cal-event-details { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.cal-event-actions { margin-top: 4px; display: flex; gap: 6px; }
.cal-join-btn { font-size: 0.6875rem; padding: 2px 8px; }

/* ── Empty state ── */
.cal-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; color: var(--text-secondary); text-align: center; gap: 12px;
}
.cal-empty p { font-size: 1rem; }

/* ── Calendar responsive ── */
@media (max-width: 600px) {
  .cal-header { flex-direction: column; align-items: stretch; }
  .cal-nav { justify-content: center; }
  .cal-title { min-width: auto; font-size: 1rem; }
  .cal-week-cell { min-width: 48px; }
  .cal-day-header { min-width: 48px; }
  .cal-time-label, .cal-time-gutter { width: 48px; font-size: 0.625rem; }
  .cal-month-cell { min-height: 56px; }
  .cal-month-event { display: none; }
}

/* ── Clickable time slots ── */
.cal-slot-clickable { cursor: pointer; position: relative; }
.cal-slot-clickable:hover { background: var(--primary)08; }
.cal-slot-clickable:hover::after {
  content: '+'; position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  color: var(--primary); font-size: 1.25rem; font-weight: 600; opacity: 0.5; pointer-events: none;
}

/* ── Schedule modal ── */
.schedule-modal .form-group { margin-bottom: 12px; }
.schedule-modal label { display: block; font-weight: 600; font-size: 0.8125rem; margin-bottom: 4px; }

.booking-mode-btn { background: var(--card); color: var(--text-secondary); }
.booking-mode-btn.active { background: var(--primary); color: #fff; }

.sched-tutor-chip {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--primary)12; border: 1px solid var(--primary);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 0.875rem; font-weight: 500;
}
.sched-tutor-remove {
  background: none; border: none; font-size: 1.25rem; cursor: pointer;
  color: var(--text-secondary); padding: 0 0 0 8px; line-height: 1;
}
.sched-tutor-dropdown {
  max-height: 200px; overflow-y: auto; border-radius: var(--radius-sm);
}
.sched-tutor-item {
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.sched-tutor-item:hover { background: var(--bg); }
.sched-tutor-item:last-child { border-bottom: none; }
.sched-tutor-empty {
  padding: 8px 12px; color: var(--text-secondary); font-size: 0.8125rem;
  cursor: default;
}

/* ── Chat panel ── */
.chat-panel {
  max-width: 500px; width: 100%; margin: 16px auto 0;
}
.chat-toggle {
  width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text); font-weight: 600; font-size: 0.875rem;
  cursor: pointer; text-align: center;
}
.chat-toggle:hover { background: var(--bg); }
.chat-body {
  display: flex; flex-direction: column; border: 1px solid var(--border);
  border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--card-bg); max-height: 350px;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 12px; min-height: 120px; max-height: 260px;
}
.chat-msg { margin-bottom: 8px; }
.chat-msg-mine { text-align: right; }
.chat-msg-other { text-align: left; }
.chat-msg-meta { font-size: 0.6875rem; color: var(--text-light); margin-bottom: 2px; }
.chat-msg-text {
  display: inline-block; padding: 6px 12px; border-radius: 12px; font-size: 0.875rem;
  max-width: 80%; text-align: left; word-break: break-word;
}
.chat-msg-mine .chat-msg-text { background: var(--primary); color: #fff; }
.chat-msg-other .chat-msg-text { background: var(--bg); color: var(--text); }
.chat-input-row {
  display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border);
}
.chat-input-row input { flex: 1; }

/* ── Booking codes ── */
.booking-code-row {
  display: flex; align-items: center; gap: 12px; padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.booking-code-row:last-child { border-bottom: none; }
.booking-code-value {
  font-family: var(--font-mono, monospace); font-size: 0.9375rem; font-weight: 600;
  background: var(--bg); padding: 4px 8px; border-radius: var(--radius-sm);
}

/* ── Dark Mode ──
   Two activation paths, same overrides:
   1. Manual:  user picks "Dark" → JS adds .dark-mode to <html>
   2. System:  user picks "System" → @media query applies when OS is dark
              (html has NO class, so html:not(.light-mode) matches)

   Token overrides swap surface/text/border colors.
   Component overrides only touch elements that can't rely on
   tokens alone (e.g. btn-secondary uses hardcoded hex). */

/* Shared dark-mode token overrides (manual) */
.dark-mode {
  --bg: #1C1C1E;
  --bg-card: #2C2C2E;
  --text: #F2F2F7;
  --text-secondary: #AEAEB2;
  --text-light: #98989D;
  --border: #3A3A3C;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
  color-scheme: dark;
}

/* System dark-mode token overrides */
@media (prefers-color-scheme: dark) {
  html:not(.light-mode) :root {
    --bg: #1C1C1E;
    --bg-card: #2C2C2E;
    --text: #F2F2F7;
    --text-secondary: #AEAEB2;
    --text-light: #98989D;
    --border: #3A3A3C;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
  }
  html:not(.light-mode) body { color-scheme: dark; }
}

/* Dark-mode component overrides (manual .dark-mode class) */
.dark-mode a { color: var(--primary); }
.dark-mode .btn-secondary { background: #48484A; color: #F2F2F7; }
.dark-mode .btn-secondary:hover:not(:disabled) { background: #5A5A5E; }

/* Inactive icons get slightly brighter in dark mode for visibility */
.dark-mode .nav-link:not(.active) .custom-icon,
.dark-mode .tab-item:not(.active) .custom-icon { filter: grayscale(1) opacity(0.7); }
.dark-mode .nav-link:hover:not(.active) .custom-icon { filter: grayscale(1) opacity(0.85); }
/* Active icons — explicitly white in dark mode */
.dark-mode .nav-link.active .custom-icon { filter: brightness(0) invert(1); }

.dark-mode .btn-outline { border-color: var(--border); color: var(--text); }
.dark-mode .btn-outline:hover { background: var(--border); }
.dark-mode .badge-outline { border-color: var(--border); color: var(--text-secondary); }
.dark-mode input, .dark-mode select, .dark-mode textarea {
  background: var(--bg); color: var(--text); border-color: var(--border);
}
.dark-mode .modal-backdrop { background: rgba(0,0,0,0.7); }

/* Badges: the light-mode tints are dark text on a pale fill; in dark mode use a translucent
   fill with lighter text. Gray needs its own fill (its light-mode one is opaque). */
.dark-mode .badge-gray { background: rgba(235,235,245,0.16); color: var(--text-secondary); }
.dark-mode .badge-blue, .dark-mode .badge-primary { background: rgba(10,132,255,0.22); color: #64B5FF; }
.dark-mode .badge-green { background: rgba(48,209,88,0.20); color: #4CD964; }
.dark-mode .badge-red { background: rgba(255,69,58,0.22); color: #FF6B63; }
.dark-mode .badge-yellow { background: rgba(255,159,10,0.22); color: #FFB340; }
.dark-mode .badge-purple { background: rgba(191,90,242,0.22); color: #D08CF7; }

/* System dark-mode component overrides (same rules, scoped to @media) */
@media (prefers-color-scheme: dark) {
  html:not(.light-mode) a { color: var(--primary); }
  html:not(.light-mode) .btn-secondary { background: #48484A; color: #F2F2F7; }
  html:not(.light-mode) .btn-secondary:hover:not(:disabled) { background: #5A5A5E; }
  html:not(.light-mode) .nav-link:not(.active) .custom-icon,
  html:not(.light-mode) .tab-item:not(.active) .custom-icon { filter: grayscale(1) opacity(0.7); }
  html:not(.light-mode) .nav-link:hover:not(.active) .custom-icon { filter: grayscale(1) opacity(0.85); }
  html:not(.light-mode) .nav-link.active .custom-icon { filter: brightness(0) invert(1); }
  html:not(.light-mode) .btn-outline { border-color: var(--border); color: var(--text); }
  html:not(.light-mode) .btn-outline:hover { background: var(--border); }
  html:not(.light-mode) .badge-outline { border-color: var(--border); color: var(--text-secondary); }
  html:not(.light-mode) input, html:not(.light-mode) select, html:not(.light-mode) textarea {
    background: var(--bg); color: var(--text); border-color: var(--border);
  }
  html:not(.light-mode) .modal-backdrop { background: rgba(0,0,0,0.7); }
  html:not(.light-mode) .badge-gray { background: rgba(235,235,245,0.16); color: var(--text-secondary); }
  html:not(.light-mode) .badge-blue, html:not(.light-mode) .badge-primary { background: rgba(10,132,255,0.22); color: #64B5FF; }
  html:not(.light-mode) .badge-green { background: rgba(48,209,88,0.20); color: #4CD964; }
  html:not(.light-mode) .badge-red { background: rgba(255,69,58,0.22); color: #FF6B63; }
  html:not(.light-mode) .badge-yellow { background: rgba(255,159,10,0.22); color: #FFB340; }
  html:not(.light-mode) .badge-purple { background: rgba(191,90,242,0.22); color: #D08CF7; }
}

/* ── Accessibility: Focus Styles ── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.25);
}

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  padding: 8px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  z-index: 9999;
  font-weight: 600;
}
.skip-link:focus { top: 8px; }

/* ── Reduce Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Loading Skeleton ── */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, transparent 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-text { height: 1em; margin-bottom: 8px; border-radius: 4px; }
.skeleton-text:last-child { width: 60%; }
.skeleton-card { height: 100px; margin-bottom: 12px; }
.skeleton-avatar { width: 48px; height: 48px; border-radius: 50%; }
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Offline Banner ── */
.offline-banner {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--warning); color: #000;
  text-align: center; padding: 8px;
  font-weight: 600; font-size: 0.875rem;
  z-index: 9999;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.offline-banner.show { transform: translateY(0); }

/* ── Page transitions ── */
.page { transition: opacity 0.12s ease, transform 0.12s ease; }
.page-exit { opacity: 0; transform: translateY(4px); pointer-events: none; }
.page-enter { opacity: 0; transform: translateY(4px); }

/* ── Confirm dialog entrance ── */
.confirm-backdrop { animation: backdrop-in 0.15s ease; }
.confirm-backdrop .modal { animation: modal-pop 0.2s ease; }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* ── Toast slide-in ── */
.toast { animation: toast-in 0.3s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }

/* ── Button press feedback ── */
.btn { transition: all var(--transition); }
.btn:active:not(:disabled) { transform: scale(0.97); }

/* ── Card stagger animation ── */
.tutor-card, .request-card { animation: card-in 0.3s ease both; }
@keyframes card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Smooth cost ticker ── */
#running-cost, #elapsed-time { transition: opacity 0.2s ease; }

/* ── History filter tabs ── */
.history-tabs {
  display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.history-tabs::-webkit-scrollbar { display: none; }
.history-tab {
  padding: 8px 16px; border-radius: 999px; font-size: 0.875rem;
  font-weight: 600; border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-secondary); cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
}
.history-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.history-tab:hover:not(.active) { background: var(--bg); }

/* ── Favorite button on tutor cards ── */
.fav-btn {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; cursor: pointer; padding: 4px;
  transition: transform var(--transition);
}
.fav-btn:active { transform: scale(1.3); }
