/* VideoConnect app shell — menu bar / title banner / home pane / status bar / dialogs
   Menu bar + status bar + splash patterns ported from repos/citation-formatter/index.html.
   Preferences + Close dialog behavior ported from repos/calendarviewer/calendarview.py. */

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

:root {
  --bg: #f4f6f9;
  --bg2: #eef1f5;
  --surface: #ffffff;
  --surface2: #f8f9fb;
  --border: #d1d9e0;
  --accent: #2c5f8a;
  --accent-light: #e8f0f8;
  --accent-hover: #1e4a6e;
  --text: #1a2332;
  --text-muted: #5a6e82;
  --titlebar: #17324a;
  --titlebar-text: #ffffff;
  --danger: #9e1515;
  --danger-hover: #7a0f0f;
  --success: #206e28;
  --success-hover: #185420;
  --shadow: 0 4px 16px rgba(0,0,0,0.18);
}

html[data-theme="dark"] {
  --bg: #1a1d23;
  --bg2: #1e2530;
  --surface: #22262e;
  --surface2: #2a2f3a;
  --border: #3a4050;
  --accent: #5b8fc7;
  --accent-light: #1e3050;
  --accent-hover: #7aaee0;
  --text: #e4e8f0;
  --text-muted: #8a96a8;
  --titlebar: #0f1d2c;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body { display: flex; flex-direction: column; height: 100vh; min-width: 900px; min-height: 640px; }

/* ── Splash ──────────────────────────────────────────────────────────────── */
#splashOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
  transition: opacity 0.6s;
}
#splashOverlay.fade-out { opacity: 0; pointer-events: none; }
.splash-card {
  background: var(--accent); color: white; padding: 22px 36px; border-radius: 12px;
  text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  display: flex; flex-direction: column; align-items: center;
}
.splash-icon { width: 56px; height: 56px; margin-bottom: 8px; border-radius: 10px; }
.splash-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.splash-version { font-size: 0.88rem; opacity: 0.85; margin-bottom: 10px; }
.splash-noai { font-size: 0.75rem; font-weight: 700; line-height: 1.45; margin-bottom: 10px; max-width: 320px; }
.splash-suite { font-size: 0.72rem; opacity: 0.88; margin-bottom: 14px; max-width: 320px; }
.splash-skip {
  background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.4); color: white;
  padding: 5px 18px; border-radius: 6px; cursor: pointer; font-size: 0.8rem; font-family: inherit;
}
.splash-skip:hover { background: rgba(255,255,255,0.35); }

/* ── Title banner (OS-Title-bar analog; 44px per StreetLocator geometry) ───── */
#titleBanner {
  height: 44px; flex: 0 0 44px; background: var(--titlebar); color: var(--titlebar-text);
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
}
#titleBanner img { width: 26px; height: 26px; border-radius: 5px; }
#titleBanner .app-name { font-size: 1.02rem; font-weight: 700; }
#titleBanner .app-version { font-size: 0.78rem; opacity: 0.75; margin-left: 2px; }

/* ── Menu bar (ported from citation-formatter .app-menubar) ────────────────── */
.app-menubar {
  background: #e4eaf0; border-bottom: 1px solid var(--border); padding: 0 8px;
  display: flex; align-items: stretch; position: relative; z-index: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); flex: 0 0 auto;
}
html[data-theme="dark"] .app-menubar { background: #1e2530; }
.app-menubar .menu-item { position: relative; }
.app-menubar .menu-btn {
  padding: 4px 12px; background: transparent; border: none; cursor: pointer;
  font-size: 0.9rem; font-family: inherit; color: var(--text); white-space: nowrap;
  transition: background 0.1s, color 0.1s; height: 28px; border-radius: 3px; margin: 2px 1px;
}
.app-menubar .menu-btn:hover,
.app-menubar .menu-btn.open { background: var(--accent); color: white; }
.menu-dropdown {
  display: none; position: absolute; top: 100%; left: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: 4px; box-shadow: var(--shadow);
  min-width: 210px; z-index: 600; padding: 3px 0;
}
.menu-dropdown.open { display: block; }
.menu-dropdown-right { left: auto; right: 0; }
.menu-dropdown button {
  display: block; width: 100%; padding: 5px 18px 5px 16px; background: transparent; border: none;
  cursor: pointer; font-size: 0.82rem; font-family: inherit; color: var(--text);
  text-align: left; white-space: nowrap; line-height: 1.5;
}
.menu-dropdown button:hover { background: var(--accent); color: white; }
.menu-dropdown button:disabled { opacity: 0.45; cursor: default; }
.menu-dropdown button:disabled:hover { background: transparent; color: var(--text); }
.menu-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 3px 0; }
.menu-empty-note { padding: 5px 16px; font-size: 0.78rem; color: var(--text-muted); font-style: italic; }
.alt-hint-label {
  font-size: 0.78rem; font-style: italic; color: var(--text-muted); align-self: center;
  margin-left: auto; padding: 0 12px; cursor: help; user-select: none; white-space: nowrap;
}

/* ── Home pane (geometry ported from StreetLocator._build_main_area) ───────── */
#homeMain { flex: 1; display: flex; min-height: 0; }
#sidebar {
  width: 300px; flex: 0 0 300px; background: var(--bg2); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 14px;
}
#sidebar h2 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 10px; }
#sidebar .sidebar-empty { font-size: 0.84rem; color: var(--text-muted); line-height: 1.5; }
#mainContent { flex: 1; overflow-y: auto; padding: 24px; background: var(--bg); }
.empty-state { color: var(--text-muted); font-size: 0.92rem; max-width: 460px; }
.session-form { max-width: 560px; }
.session-form label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin: 14px 0 4px; }
.session-form label:first-child { margin-top: 0; }
.session-form input[type="text"],
.session-form input[type="date"],
.session-form input[type="time"],
.session-form input[type="number"] {
  width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface); color: var(--text); font-size: 0.9rem; font-family: inherit;
}
.session-form .dur-row { display: flex; gap: 10px; }
.session-form .dur-row > div { flex: 1; }
.session-form .checkbox-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.home-pane-actions { margin-top: 20px; display: flex; gap: 8px; }
.btn {
  padding: 6px 16px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer; font-size: 0.85rem; font-family: inherit;
}
.btn:hover { background: var(--accent-light); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }

/* ── Status bar ──────────────────────────────────────────────────────────── */
#statusBar {
  flex: 0 0 auto; background: #e4eaf0; border-top: 1px solid var(--border); padding: 3px 16px;
  font-size: 0.75rem; color: var(--text-muted); display: flex; gap: 10px; align-items: center;
}
html[data-theme="dark"] #statusBar { background: #1e2530; }
.status-sep { opacity: 0.5; }
#statusVersion { margin-left: auto; font-weight: 600; }
.status-screen-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 4px; padding: 1px 8px;
  font-size: 0.72rem; cursor: pointer; color: var(--text-muted); font-family: inherit;
}
.status-screen-btn:hover { background: var(--accent-light); }

/* ── Modal overlay (About/Help/License/Print stub) ──────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 1500;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  position: relative; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow);
  max-width: 520px; width: 90%; max-height: 80vh; overflow-y: auto; padding: 20px 24px;
}
.modal h2 { font-size: 1.05rem; margin-bottom: 12px; }
.modal p, .modal pre { font-size: 0.86rem; line-height: 1.55; color: var(--text); }
.modal pre { white-space: pre-wrap; font-family: inherit; }
.modal .modal-actions { margin-top: 18px; text-align: right; }
.modal-close-x {
  position: absolute; top: 10px; right: 12px; background: transparent; border: none;
  font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--text-muted); padding: 4px;
}
.modal-close-x:hover { color: var(--text); }

/* ── Preferences panel (non-modal — CalendarView port: Save persists+toasts,
     does NOT close; only Close/X unmounts it) ────────────────────────────── */
#preferencesPanel {
  display: none; position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  width: 560px; max-width: 92vw; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); z-index: 1600;
}
#preferencesPanel.open { display: block; }
.prefs-header {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 18px;
  border-bottom: 1px solid var(--border); font-weight: 700;
}
.prefs-header button { background: transparent; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text-muted); }
.prefs-tabs { display: flex; border-bottom: 1px solid var(--border); }
.prefs-tab { padding: 8px 16px; cursor: pointer; font-size: 0.85rem; color: var(--text-muted); border-bottom: 2px solid transparent; }
.prefs-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.prefs-body { padding: 16px 18px; min-height: 180px; }
.prefs-body label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin: 12px 0 4px; }
.prefs-body label:first-child { margin-top: 0; }
.prefs-body select, .prefs-body input[type=text] {
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface);
  color: var(--text); font-family: inherit; font-size: 0.85rem; width: 100%;
}
.prefs-note { font-size: 0.78rem; color: var(--text-muted); font-style: italic; margin-top: 10px; }
.prefs-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.prefs-toast {
  position: absolute; bottom: -34px; right: 18px; background: var(--success); color: white;
  padding: 5px 12px; border-radius: 5px; font-size: 0.78rem; opacity: 0; transition: opacity 0.3s;
  pointer-events: none;
}
.prefs-toast.show { opacity: 1; }

/* ── Close dialog (CalendarView port: anchored upper-right, 390x140-ish,
     own X/Escape cancels only) ───────────────────────────────────────────── */
#closeDialogBackdrop {
  display: none; position: fixed; inset: 0; background: transparent; z-index: 1700;
}
#closeDialogBackdrop.open { display: block; }
#closeDialogPanel {
  display: none; position: fixed; top: 12px; right: 12px; width: 390px; min-height: 140px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); z-index: 1701; padding: 16px 18px;
}
#closeDialogPanel.open { display: block; }
.close-dialog-title { font-size: 1rem; font-weight: 700; text-align: center; margin-bottom: 14px; }
.close-dialog-row { display: flex; gap: 10px; justify-content: center; margin-bottom: 6px; }
.close-dialog-row button { padding: 7px 16px; border-radius: 5px; border: none; color: white; cursor: pointer; font-family: inherit; font-size: 0.85rem; }
#closeSaveBtn { background: var(--success); }
#closeSaveBtn:hover { background: var(--success-hover); }
#closeNoSaveBtn { background: var(--danger); }
#closeNoSaveBtn:hover { background: var(--danger-hover); }
.close-dialog-x { position: absolute; top: 8px; right: 10px; background: transparent; border: none; font-size: 1rem; cursor: pointer; color: var(--text-muted); }
.close-dialog-status { text-align: center; font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; }

/* ── Host key row (session form) ─────────────────────────────────────────── */
.host-key-row { display: flex; gap: 8px; }
.host-key-row input { flex: 1; }
.host-key-row .btn { flex: 0 0 auto; white-space: nowrap; }

/* ── Sidebar call rail ───────────────────────────────────────────────────── */
.call-rail-actions { display: flex; flex-direction: column; gap: 6px; }
.vc-participant-list { list-style: none; font-size: 0.85rem; color: var(--text); }
.vc-participant-list li {
  display: flex; align-items: center; justify-content: space-between; padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.vc-kick-btn {
  background: transparent; border: 1px solid var(--danger); color: var(--danger); border-radius: 4px;
  padding: 1px 8px; font-size: 0.72rem; cursor: pointer; font-family: inherit;
}
.vc-kick-btn:hover { background: var(--danger); color: white; }

/* ── Call view / video grid ──────────────────────────────────────────────── */
.call-view { height: 100%; }
.video-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px;
  height: 100%; align-content: start;
}
.video-tile {
  position: relative; background: #10151c; border-radius: 8px; overflow: hidden;
  aspect-ratio: 4 / 3; box-shadow: var(--shadow);
}
.video-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-tile-label {
  position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,0.55); color: white;
  font-size: 0.78rem; padding: 2px 8px; border-radius: 4px;
}

/* ── Knock (Admit/Deny) cards — anchored top-right, stacked ─────────────────── */
#knockStack {
  position: fixed; top: 56px; right: 12px; z-index: 1800;
  display: flex; flex-direction: column; gap: 8px;
}
.knock-card {
  width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 12px 14px;
}
.knock-title { font-size: 0.88rem; font-weight: 600; margin-bottom: 10px; }
.knock-actions { display: flex; gap: 8px; justify-content: flex-end; }
