/* ==========================================================
   Announceboard — shared stylesheet
   One file for both the announcer console and the admin panel,
   so controls can never drift apart between pages.
   ========================================================== */

:root {
  /* Palette */
  --ink:          #16181d;
  --muted:        #6a7280;
  --faint:        #949bab;
  --paper:        #ffffff;
  --canvas:       #f5f6f8;
  --line:         #dfe2e8;
  --line-strong:  #c7ccd6;
  --accent:       #1f5fbf;
  --accent-hover: #1a4f9f;
  --accent-soft:  #eaf1fb;
  --green:        #16794a;
  --green-hover:  #12613b;
  --red:          #b3261e;
  --red-hover:    #931d17;
  --amber-bg:     #fdf6e3;
  --amber-line:   #e8d9a8;
  --amber-ink:    #6b5312;

  /* Metrics — every control inherits these, so heights always match */
  --control-h:    38px;
  --control-h-sm: 30px;
  --radius:       6px;
  --radius-lg:    10px;
  --field-gap:    0.85rem;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
  padding: 1.5rem 1rem 3rem;
  background: var(--canvas);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  min-height: 100vh;
}

.wrap { width: 100%; max-width: 980px; }

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  max-width: 980px;
  padding-bottom: 0.25rem;
}
.app-title {
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
}
.app-subtitle {
  font-size: 0.8125rem;
  color: var(--muted);
  margin: 0.1rem 0 0;
}
.header-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ── Panels ─────────────────────────────────────────────── */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem 1.25rem;
  width: 100%;
  max-width: 980px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.65rem;
  margin-bottom: 1rem;
}
.panel h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.005em;
}
.panel-hint { font-size: 0.8125rem; color: var(--faint); }

/* ── Labels and fields ──────────────────────────────────── */
label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

input[type=text],
input[type=number],
input[type=password],
input[type=file],
select {
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  height: var(--control-h);
  padding: 0 0.65rem;
  width: 100%;
  margin: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

/* Native select arrow removed and redrawn so selects sit flush
   at exactly the same height as text inputs. */
select {
  padding-right: 2rem;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236a7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  cursor: pointer;
}

input[type=file] {
  padding: 0.35rem 0.5rem;
  line-height: 1.6;
  cursor: pointer;
}
input[type=file]::file-selector-button {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 550;
  height: var(--control-h-sm);
  padding: 0 0.65rem;
  margin-right: 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--ink);
  cursor: pointer;
}

textarea {
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.6rem 0.65rem;
  width: 100%;
  margin: 0;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--faint); }

.field { margin-bottom: var(--field-gap); }
.field:last-child { margin-bottom: 0; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--field-gap) 1rem;
}
.field-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--field-gap) 1rem; }
.field-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--field-gap) 1rem; }

.input-mono {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  text-align: center;
}
.w-time, input.w-time { width: 118px; }
.w-num,  input.w-num  { width: 76px; }

/* ── Buttons ────────────────────────────────────────────── */
button, .btn {
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 550;
  line-height: 1;
  height: var(--control-h);
  padding: 0 0.95rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
button:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
  border-color: var(--accent);
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-hover); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-hover); }

.btn-outline {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-outline:hover { background: var(--canvas); border-color: var(--muted); }

.btn-destructive {
  background: var(--paper);
  color: var(--muted);
  border-color: var(--line-strong);
}
.btn-destructive:hover { background: #fdf3f2; color: var(--red); border-color: var(--red); }

.btn-quiet {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding: 0 0.5rem;
}
.btn-quiet:hover { background: var(--canvas); color: var(--ink); }

.btn-sm { height: var(--control-h-sm); font-size: 0.8125rem; padding: 0 0.6rem; }
.btn-full { width: 100%; }

.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn-row-even > button, .btn-row-even > .btn { flex: 1; }

/* Controls sitting on one line with fields, bottom-aligned */
.row-end { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }

/* ── Segmented toggle ───────────────────────────────────── */
.segmented {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  height: var(--control-h);
  background: var(--paper);
}
.segmented.full { display: flex; width: 100%; }
.segmented button {
  flex: 1;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 550;
  padding: 0 0.9rem;
}
.segmented button + button { border-left: 1px solid var(--line-strong); }
.segmented button:hover { background: var(--canvas); color: var(--ink); }
.segmented button.active { background: var(--accent); color: #fff; }
.segmented button.active:hover { background: var(--accent-hover); }
.segmented button:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-soft); }

/* ── Tables ─────────────────────────────────────────────── */
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--canvas);
  white-space: nowrap;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--ink); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover td { background: #fafbfc; }
table.data td.actions { white-space: nowrap; width: 1%; }
table.data input { height: var(--control-h-sm); font-size: 0.875rem; padding: 0 0.45rem; }

.table-scroll { overflow-x: auto; margin: 0 -0.25rem; padding: 0 0.25rem; }

.tag-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--canvas);
  color: var(--muted);
  border: 1px solid var(--line);
}

.empty {
  text-align: center;
  color: var(--faint);
  font-size: 0.9rem;
  padding: 1.25rem 0.5rem;
}

/* ── Toast ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9999;
}
.toast {
  background: var(--ink);
  color: #fff;
  font-size: 0.875rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  border-left: 3px solid var(--faint);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toastIn 0.18s ease, toastOut 0.3s ease 2.2s forwards;
}
.toast.success { border-left-color: #3ecf8e; }
.toast.error   { border-left-color: #ff6b61; }
.toast.info    { border-left-color: #6ea8fe; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(8px); } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(6px); } }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 24, 29, 0.5);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 4vh 1rem;
  overflow-y: auto;
}
.modal {
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 16px 48px rgba(22, 24, 29, 0.22);
}
.modal h2 { margin: 0 0 1rem; font-size: 1.1rem; font-weight: 650; padding-right: 2rem; }
.modal h3 { margin: 0 0 1rem; font-size: 1rem; font-weight: 650; padding-right: 2rem; }
.modal-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  height: var(--control-h-sm);
  width: var(--control-h-sm);
  padding: 0;
  font-size: 1.1rem;
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  border-radius: var(--radius);
}
.modal-close:hover { background: var(--canvas); color: var(--ink); }

/* ── Section blocks (opening script, tag help) ──────────── */
.subsection {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.85rem;
  background: var(--paper);
}
.subsection:last-child { margin-bottom: 0; }
.subsection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}
.subsection-title { font-size: 0.8125rem; font-weight: 650; color: var(--muted); }
.subsection-body { white-space: pre-wrap; line-height: 1.65; margin: 0; }

/* Cards laid out side by side keep their footer actions aligned. */
.stretch-panel { display: flex; flex-direction: column; }
.stretch-panel .grow { flex: 1 1 auto; }

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

@media (max-width: 700px) {
  .field-grid-2, .field-grid-3 { grid-template-columns: 1fr; }
  .app-header { flex-direction: column; align-items: stretch; }
  .header-actions { justify-content: space-between; }
}
