/* Project Easy — base styling with light/dark themes (build plan Phase 1). */

:root,
[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --fg: #1c2430;
  --muted: #5c6b7f;
  --border: #d7dee7;
  --accent: #1f6feb;
  --accent-fg: #ffffff;
  --error: #c62828;
  --topbar-bg: #ffffff;
  --pending: #e8890c; /* 17 Nov 2026: bookings waiting for portfolio approval */
}

[data-theme="dark"] {
  --bg: #14181f;
  --surface: #1d232d;
  --fg: #e6ebf2;
  --muted: #93a1b3;
  --border: #323b48;
  --accent: #4c8dff;
  --accent-fg: #0b1220;
  --error: #ef5350;
  --topbar-bg: #1d232d;
  --pending: #f0a040;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--fg);
  white-space: nowrap;
}

.topbar-nav {
  display: flex;
  gap: 0.25rem;
}

.topbar-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.topbar-nav a:hover {
  color: var(--fg);
}

/* Top-bar tabs (16 Nov 2026): the current view's tab is highlighted. */
.topbar-nav .nav-tab {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  height: var(--btn-h, 30px);
  padding: 0 0.8rem;
  border-radius: 6px;
  color: var(--muted);
}

.topbar-nav .nav-tab:hover {
  color: var(--fg);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.topbar-nav .nav-tab.active {
  color: var(--fg);
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* 17 Nov 2026: count of bookings waiting for your approval. */
.nav-badge {
  display: inline-block;
  min-width: 1.2rem;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--pending);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2rem;
  text-align: center;
}

/* "Data import" drop-down in the top bar (16 Nov 2026). */
.topbar-nav {
  align-items: center;
}

.nav-menu {
  position: relative;
}

.nav-menu > summary {
  list-style: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}

.nav-menu > summary::-webkit-details-marker {
  display: none;
}

.nav-menu > summary::after {
  content: " ▾";
  font-size: 0.75rem;
}

.nav-menu > summary:hover,
.nav-menu[open] > summary {
  color: var(--fg);
}

.nav-menu-list {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: -0.6rem;
  z-index: 90;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  padding: 0.3rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.topbar-nav .nav-menu-list a {
  padding: 0.45rem 0.9rem;
  color: var(--fg);
}

.topbar-nav .nav-menu-list a:hover {
  background: var(--hover, rgba(37, 99, 235, 0.1));
}

.switcher select {
  min-width: 260px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.who {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

/* --- buttons: one shape app-wide (16 Nov 2026) --------------------------------
   Every button is the same height, padding, font size and 6px corners;
   buttons inside table rows (Edit, Replace…, CSV, Actions ▾) use the compact
   size. Page stylesheets may set colours and margins, never the size. */
:root {
  --btn-h: 30px;
  --btn-h-sm: 24px;
}

.button,
.icon-button,
.zoom-btn,
.res-zoom-btn,
.res-small-btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  height: var(--btn-h);
  padding: 0 0.8rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  text-decoration: none;
}

.res-small-btn,
.button.small {
  height: var(--btn-h-sm);
  padding: 0 0.6rem;
  font-size: 0.78rem;
}

/* A dialog's close "×" — the same square on every page. */
.pe-dialog-close,
.res-dialog-close {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  font-size: 1.25rem;
  line-height: 1;
}

.pe-dialog-close:hover,
.res-dialog-close:hover {
  background: var(--hover, rgba(37, 99, 235, 0.1));
  color: var(--fg);
}

.icon-button {
  width: var(--btn-h);
  padding: 0;
  font-size: 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
}

.button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
}

.inline-form {
  display: inline;
}

.content {
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.card.narrow {
  max-width: 420px;
}

h1 {
  font-size: 1.4rem;
  margin-top: 0;
}

label {
  display: block;
  margin: 0.6rem 0 0.2rem;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
}

a {
  color: var(--accent);
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.messages {
  list-style: none;
  padding: 0;
}

.message {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
}

.message.error {
  border-color: var(--error);
  color: var(--error);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Bug list 31 Oct #18: page instructions are a collapsed "How this page
   works" hint instead of paragraphs under the controls. */
details.page-tips { margin: 8px 0; font-size: 0.82rem; color: var(--muted); }
details.page-tips summary { cursor: pointer; width: max-content; }
details.page-tips p { margin: 6px 0 0; max-width: 90ch; }

/* A [hidden] element stays hidden even when its class sets a display. */
[hidden] { display: none !important; }

/* Spec v0.2 dialogs (static/js/dialog.js). */
.res-dialog.v02-wide { width: min(760px, 94vw); }
.res-dialog-body { max-height: 70vh; overflow: auto; }
.v02-hint { margin-top: 0.2rem; }
.v02-error { color: var(--error); font-weight: 600; }
.v02-error-inline { color: var(--error); font-size: 0.8rem; }
.v02-select-add select { width: 100%; }
.v02-add-row { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.v02-add-row input { flex: 1; }
.v02-tag { display: inline-block; padding: 0 6px; border-radius: 3px; font-size: 0.7rem; font-weight: 700; line-height: 16px; margin-right: 6px; vertical-align: middle; }
.v02-tag.opportunity { background: #8250df; color: #fff; }
.v02-tag.closed { background: var(--muted); color: var(--surface); }
.v02-tag.on_hold { background: #bf8700; color: #fff; }
.v02-tag.generic { border: 1px dashed var(--muted); color: var(--muted); font-weight: 600; }
.v02-generic-name { font-style: italic; }
.v02-radio-row { display: flex; gap: 18px; }
.v02-radio, .v02-check { display: inline-flex; align-items: center; gap: 4px; font-size: 0.88rem; font-weight: 400; color: var(--fg); }
.res-field .v02-radio input, .res-field .v02-check input { width: auto; }
.v02-check { margin-top: 4px; font-size: 0.8rem; color: var(--muted); }
.v02-more { margin-top: 10px; }
.v02-more summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
.v02-option { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 12px; margin: 10px 0; }
.v02-option h4 { margin: 4px 0 8px; font-size: 0.92rem; }
.v02-option textarea { width: 100%; font-family: ui-monospace, monospace; font-size: 0.82rem; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 6px; padding: 6px; }
.v02-option .button { margin-top: 8px; }
.v02-option-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.v02-link { font-size: 0.85rem; }
.v02-preview { max-height: 240px; overflow: auto; margin-top: 8px; }
.v02-plan tr.v02-sub td:nth-child(3) { padding-left: 18px; }
.v02-plan tr.v02-skip td { color: var(--muted); }
.v02-plan tr.v02-err td { color: var(--error); }

/* --- help chat popup (17 Nov 2026) ------------------------------------------- */

.pe-chat {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
  pointer-events: none;
}

.pe-chat > * {
  pointer-events: auto;
}

.pe-chat-launch {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 1.35rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.pe-chat-launch:hover,
.pe-chat-launch.open {
  filter: brightness(1.1);
}

.pe-chat-panel {
  width: min(420px, calc(100vw - 2rem));
  height: min(640px, calc(100vh - 7rem));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.pe-chat-panel[hidden] {
  display: none;
}

.pe-chat-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem 0.5rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.pe-chat-spacer {
  flex: 1;
}

.pe-chat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.pe-chat-icon:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--fg);
}

.pe-chat-body {
  position: relative;
  flex: 1;
}

.pe-chat-body iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.pe-chat-wait {
  margin: 1.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* 17 Nov 2026: a disabled button looks disabled (it looked clickable). */
.button:disabled,
.button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  filter: saturate(0.6);
}

/* 17 Nov 2026: person picker in booking dialogs (static/js/personpicker.js). */
.pp-filter { display: flex; align-items: center; gap: 0.5rem; margin: 0.2rem 0; font-size: 0.85rem; }
.pp-filter[hidden] { display: none; }
.pp-check { white-space: nowrap; display: inline-flex; align-items: center; gap: 0.25rem; }
.pp-text { flex: 1; min-width: 8rem; }
.pp-info { font-size: 0.78rem; color: var(--muted); margin: 0.15rem 0 0.4rem; min-height: 1em; }
.pp-info.pp-loading { opacity: 0.6; }
.pp-info .pp-busy { color: var(--error); }
.pp-info .pp-free { color: #2da44e; }
.pp-info .pp-approval { color: var(--pending); font-weight: 600; margin-top: 0.15rem; }
.pp-level { flex: none; }

/* 18 Nov 2026: type-to-filter list for long drop-downs (static/js/selectfilter.js). */
.sf-pop {
  position: fixed; z-index: 1000; display: flex; flex-direction: column;
  background: var(--surface); color: var(--fg); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); overflow: hidden; font-size: 0.88rem;
}
.sf-input { margin: 6px; padding: 5px 8px; border: 1px solid var(--accent); border-radius: 6px; background: var(--bg); color: var(--fg); font: inherit; }
.sf-list { overflow: auto; padding-bottom: 4px; }
.sf-item { padding: 4px 10px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sf-item.current { font-weight: 600; }
.sf-item.active { background: var(--accent); color: var(--accent-fg); }
.sf-item.disabled { color: var(--muted); cursor: default; }
.sf-group { padding: 6px 10px 2px; font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.sf-none { padding: 6px 10px; color: var(--muted); }
.v02-radio-col { display: grid; gap: 6px; margin: 4px 0 8px; }
.v02-radio-col select { margin-left: 22px; max-width: calc(100% - 22px); }
