/* JJ's Setlist - browser edition */

:root {
  --fs: 15px;                 /* list text size (View > Larger / Smaller Text) */
  /* Songlist & Setlist colours (View > Colours) - same defaults as the desktop app */
  --lib-bg: #003d4b;
  --lib-fg: #ffffff;
  --lib-used: #9e9e9e;
  --lib-select: #3d8bfd;
  --lib-frame: #afafaf;
  --set-frame: #67c6c5;
  --set-active-bg: #eef5ff;

  --page: #eceff3;
  --panel: #ffffff;
  --line: #c9d0d8;
  --text: #1d232a;
  --muted: #5f6b77;
  --blue: #0a64c8;
  --missing: #d35400;
  --button: #f7f8fa;
  --button-hover: #e7ebf0;
  --primary: #0a64c8;
  --primary-hover: #0852a5;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 14px;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); }

#app {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100dvh;
}

button, select, input { font: inherit; color: inherit; }
button {
  background: var(--button);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: var(--button-hover); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-hover); }
select, input[type=text], input[type=search] {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  background: #fff;
  min-width: 0;
}
.muted { color: var(--muted); }
.spacer { flex: 1; }
kbd:empty { display: none; }

/* ---------- menu bar */
.menubar {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 6px;
}
.menu { position: relative; }
.menu-title {
  border: 0; background: none; border-radius: 0; padding: 6px 10px;
}
.menu.open .menu-title, .menu-title:hover { background: var(--button-hover); }
.menu-items {
  display: none;
  position: absolute; top: 100%; left: 0; z-index: 50;
  min-width: 290px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .15);
  padding: 4px 0;
}
.menu.open .menu-items { display: block; }
.menu-items button {
  display: flex; justify-content: space-between; gap: 24px;
  width: 100%; text-align: left; border: 0; border-radius: 0; background: none; padding: 6px 14px;
}
.menu-items button:hover { background: var(--button-hover); }
.menu-items kbd { font-family: inherit; color: var(--muted); }
.menu-items hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ---------- toolbar */
.toolbar { padding: 8px 10px 0; display: grid; gap: 6px; }
.toolbar .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* Bold top area: the toolbar rows, the band list and the account button (the menu names are bold already). */
.toolbar .row, #spacePicker, #account { font-weight: 700; }
#setName { width: 300px; max-width: 100%; }
#saved { width: 260px; max-width: 100%; }

/* ---------- main area */
.main {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(0, 2fr);
  gap: 10px;
  padding: 10px;
  min-height: 0;
}
.panel {
  background: var(--panel);
  border: 3px solid transparent;
  border-radius: 10px;
  padding: 6px 10px 8px;
  display: flex; flex-direction: column;
  min-height: 0;
  box-shadow: 0 1px 2px rgb(0 0 0 / .08);
}
.panel h2 {
  margin: 0 0 6px; font-size: 1.05rem; font-weight: 600; color: var(--blue);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.panel-buttons { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }

.library { border-color: var(--lib-frame); }
.search { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.search input { flex: 1; }
/* Library search: our own ✕ inside the box (the browser's built-in one only
   shows on hover in Chrome/Edge, and never in Firefox). Hidden while empty. */
.search-box { position: relative; flex: 1; display: flex; min-width: 0; }
.search-box input { padding-right: 30px; }
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; border-radius: 50%;
  padding: 0; width: 22px; height: 22px; line-height: 22px;
  color: var(--muted); font-size: .9rem;
}
.search-clear:hover { background: var(--button-hover); color: inherit; }
.search-box input:placeholder-shown + .search-clear { display: none; }
.lib-frame { position: relative; flex: 1; min-height: 0; display: flex; }

/* ---------- song lists */
.songs {
  list-style: none; margin: 0; padding: 4px 0;
  overflow-y: auto; flex: 1; min-height: 0;
  font-size: var(--fs);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}
.songs:focus-visible { box-shadow: 0 0 0 2px var(--blue); }
.songs li {
  display: flex; align-items: baseline; gap: .35em;
  padding: .12em .5em;
  white-space: nowrap; overflow: hidden;
  cursor: grab;
  user-select: none; -webkit-user-select: none;
}
.songs li > .label { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.songs .num { min-width: 1.6em; text-align: right; flex: none; }
.songs .sheet { flex: none; width: 1.2em; text-align: center; cursor: pointer; }
.songs .sheet.none { cursor: inherit; }

.lib-list { background: var(--lib-bg); color: var(--lib-fg); border-color: transparent; }
.lib-list li.used { color: var(--lib-used); }
.lib-list li.selected { background: var(--lib-select); color: #fff; }

.set-list { background: #fff; }
.set-list li.selected { background: var(--lib-select); color: #fff; }
.set-list li.missing { color: var(--missing); }
.set-list li.selected.missing { color: #fff; }
.set-list:empty::after {
  content: "Double-click songs in the library, or drag them here.";
  display: block; padding: 1em; color: var(--muted); font-size: .9em; font-style: italic;
}

.sortable-ghost { opacity: .45; }
.sortable-drag { opacity: .9; }

/* ---------- sets */
.sets {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
}
.set { border-color: transparent; }
.set h2 { color: var(--text); }
.set.active { border-color: var(--set-frame); }
.set.active h2 { color: var(--blue); }
.set.active .set-list { background: var(--set-active-bg); }

/* ---------- get started */
.get-started {
  position: absolute; inset: 0;
  overflow: auto;
  background: var(--lib-bg); color: var(--lib-fg);
  border-radius: 6px;
  padding: 24px; text-align: center;
}
.get-started[hidden] { display: none; }
.get-started img { border-radius: 12px; background: #fff; padding: 6px; }
.get-started code { background: rgb(255 255 255 / .15); padding: 0 4px; border-radius: 3px; }
.get-started .small { font-size: .85em; opacity: .85; margin-top: 18px; }

/* ---------- status bar */
.status {
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 4px 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--muted);
}

/* ---------- dialogs */
dialog {
  border: 0; border-radius: 12px; padding: 0;
  max-width: min(560px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgb(0 0 0 / .3);
}
dialog::backdrop { background: rgb(0 0 0 / .35); }
dialog form { padding: 18px 22px; }
dialog h3 { margin: 0 0 12px; font-size: 1.15rem; }
#dialogBody { white-space: pre-line; line-height: 1.45; max-height: 60vh; overflow: auto; }
#dialogBody.html { white-space: normal; }
#dialogBody table { border-collapse: collapse; width: 100%; }
#dialogBody td { padding: 3px 8px 3px 0; vertical-align: top; }
#dialogBody td:first-child { white-space: nowrap; color: var(--muted); }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

.colour-grid { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 10px; align-items: center; }
.colour-grid input[type=color] { width: 46px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
.colour-grid code { font-size: .9em; color: var(--muted); width: 5.5em; }
.contrast { margin-top: 12px; font-size: .9em; }
.contrast .warn { color: var(--missing); }

/* ---------- smaller laptop screens */
@media (max-width: 1100px) {
  .main { grid-template-columns: minmax(260px, 1fr) minmax(0, 1.6fr); }
}
/* ---------- printing */
#printArea { display: none; }

@page {
  size: A4 landscape;
  margin: 12mm 14mm 14mm;
  @bottom-center { content: "Page " counter(page) " of " counter(pages); font: 9pt "Segoe UI", sans-serif; color: #555; }
}
@media print {
  #app, dialog { display: none !important; }
  #printArea { display: block; font: 10pt "Segoe UI", system-ui, sans-serif; color: #000; }
  .print-head h1 { font-size: 15pt; margin: 0; }
  .print-head p { margin: 2pt 0 8pt; color: #333; }
  .print-set { break-inside: avoid; margin-bottom: 9pt; }
  .print-set h2 { font-size: 11pt; margin: 0 0 2pt; }
  .print-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .print-table th { text-align: left; font-size: 8.5pt; border-bottom: 1px solid #000; padding: 1pt 4pt; }
  .print-table td { padding: .6pt 4pt; border-bottom: .5pt solid #ddd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .print-table tr { break-inside: avoid; }
  .print-table .n { width: 30pt; text-align: right; text-overflow: clip; }
  .print-table .t { width: 40%; }
  .print-table .a { width: 25%; }
}

/* ---------- song database: online copy (Google Drive / Dropbox) */
#dbLabel.backup { color: var(--missing); font-weight: 600; }
body.busy, body.busy * { cursor: progress !important; }
.drive-row { display: flex; gap: 8px; margin: 6px 0 4px; }
.drive-row input { flex: 1; min-width: 0; }
.drive-result { min-height: 1.4em; font-size: .92em; color: var(--muted); }
.drive-result.ok { color: #1e7d32; }
.drive-result.bad { color: var(--missing); }
dialog .choice { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; }
dialog .choice input { margin-top: 4px; }
dialog .small { font-size: .88em; }
#dialog:has(#driveUrl) { width: min(640px, calc(100vw - 32px)); max-width: none; }

#storageLabel { margin-right: 14px; cursor: help; }

/* ---------- templates */
.template-done { color: #1e7d32; font-weight: 600; font-size: 1.1em; margin: 0 0 4px; }
ol.steps { margin: 6px 0 8px; padding-left: 1.6em; }
ol.steps li { margin: 5px 0; }
#dialogBody code { word-break: break-all; }
.link-button { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; font-weight: 600; }
.link-button:hover { background: none; opacity: .85; }

/* ---------- right-click menu */
.context-menu {
  position: fixed; z-index: 70;
  min-width: 210px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .18);
  padding: 4px 0;
  font-size: 14px;
}
.context-menu[hidden] { display: none; }
.context-menu button {
  display: block; width: 100%; text-align: left;
  border: 0; border-radius: 0; background: none; padding: 6px 14px;
}
.context-menu button:hover:not(:disabled), .context-menu button:focus-visible { background: var(--button-hover); outline: none; }
.context-menu button:disabled { color: #a0a7ae; cursor: default; }
.context-menu .note { padding: 6px 14px; color: var(--missing); font-weight: 600; }
.context-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ---------- replace with… */
#dialog:has(#replList) { width: min(640px, calc(100vw - 32px)); max-width: none; }
#dialogBody:has(#replList) { max-height: none; overflow: visible; }
.replace-what { margin: 0 0 4px; line-height: 1.5; }
.replace-list { height: min(340px, 45vh); flex: none; margin-top: 4px; }
.replace-list li.none { cursor: default; opacity: .8; font-style: italic; }

/* ---------- online accounts */
#account[hidden] { display: none; }
#account button { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.context-menu .note.plain { color: var(--muted); font-weight: normal; font-size: .92em; }
.account-form { display: grid; gap: 4px; min-width: min(380px, 80vw); }
.account-form label { font-weight: 600; margin-top: 8px; }
.account-form input { padding: 7px 9px; }
.account-form p { margin: 6px 0 0; }
.google-btn { padding: 8px 12px; font-weight: 600; background: #fff; }
.google-btn b { color: #4285f4; font-size: 1.1em; }
.account-form .or { display: flex; align-items: center; gap: 10px; margin: 10px 0 2px; color: var(--muted); font-size: .9em; }
.account-form .or::before, .account-form .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.menubar { align-items: center; }
#account { margin-left: auto; padding: 3px 4px; }
#account button { padding: 3px 12px; }
/* The song database's name and details, in a narrow font so it fits (fonts already on Windows / Mac),
   and wrapping onto a second line rather than being cut short if it still doesn't. */
#dbLabel {
  font-family: "Arial Narrow", "Bahnschrift SemiCondensed", "Bahnschrift", "Roboto Condensed", sans-serif;
  font-stretch: condensed;
  flex: 1 1 160px; min-width: 0; line-height: 1.3;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}

/* ---------- help guides */
#dialog:has(.guide) { width: min(780px, calc(100vw - 32px)); max-width: none; }
#dialogBody:has(.guide) { max-height: 68vh; padding-right: 6px; }
.guide { line-height: 1.5; }
.guide h4 { margin: 18px 0 6px; font-size: 1.02rem; color: var(--blue); }
.guide h4:first-child { margin-top: 0; }
.guide h5 { margin: 12px 0 4px; font-size: .95rem; }
.guide p { margin: 6px 0; }
.guide ul, .guide ol { margin: 4px 0 8px; padding-left: 1.5em; }
.guide li { margin: 3px 0; }
.guide pre { background: #f3f5f8; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin: 6px 0; white-space: pre-wrap; font-size: .9em; }
.guide-tip, .guide-warn { border-radius: 6px; padding: 8px 12px; margin: 8px 0; }
.guide-tip { background: #eef6ff; border: 1px solid #c9def7; }
.guide-warn { background: #fff4e5; border: 1px solid #f5d29c; color: #7a3f00; }

/* ---------- bands & invitations */
#spacePicker { margin-left: auto; margin-right: 6px; padding: 3px 8px; max-width: 260px; }
#spacePicker[hidden] { display: none; }
#spacePicker:not([hidden]) + #account { margin-left: 0; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--missing); color: #fff; font-size: .8em; text-align: center; }
.account-form .ac-head { margin: 4px 0 0; font-size: 1rem; }
.account-form .ac-band { font-size: 1.05rem; background: #eef6ff; border: 1px solid #c9def7; border-radius: 6px; padding: 8px 12px; margin: 0 0 6px; }
/* "Changed by Gary - reload?" bar, under the toolbar. */
.change-notice {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 6px; padding: 6px 10px;
  background: #fff4d6; border: 1px solid #f0c36d; border-radius: 6px;
}
.change-notice[hidden] { display: none; }

/* Signed out on the website: a plain white page with just the sign-in window. */
body.gate { background: #fff; }
body.gate #app { display: none; }
body.gate dialog::backdrop { background: #fff; }
body.gate dialog { box-shadow: 0 4px 24px rgb(0 0 0 / .12); border: 1px solid var(--line); }
body.gate #dialogBody { max-height: none; }   /* nothing behind it: use the page's height */
.account-form .ac-logo { display: block; width: 90px; margin: 0 auto 10px; }
.account-form textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
#dialog:has(.admin) { width: min(760px, calc(100vw - 32px)); max-width: none; }
.admin .band-row { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 8px; }
.admin .band-name { font-weight: 600; margin-bottom: 6px; }
.admin .band-code { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.admin .band-code code { font-size: 1.05em; background: #f3f5f8; padding: 2px 6px; border-radius: 4px; letter-spacing: .04em; }
.admin .member-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.admin .request-msg { white-space: pre-wrap; background: #f7f8fa; border-radius: 4px; padding: 4px 8px; margin: 4px 0; }
.admin .request-note { background: #fff4d6; border: 1px solid #f0c36d; border-radius: 4px; padding: 4px 8px; margin: 4px 0; }
.admin .request-note button { padding: 2px 8px; margin: 0 4px; }
.copy-box { white-space: pre-wrap; background: #f3f5f8; padding: 10px; border-radius: 6px; user-select: all; }

/* ---------- menu bar: orange with bold names, so it stands out */
.menubar { background: #ffc874; border-bottom-color: #e8a94a; }
.menu-title { font-weight: 700; color: #1d232a; }
.menu.open .menu-title, .menu-title:hover { background: #f5b04a; }

/* sign-in window: the main button sits right under the password box */
.account-form .ac-signin { margin-top: 10px; padding: 9px 12px; font-weight: 700; }
