/* Shul Board admin styles — utilitarian, light theme */
:root {
  --bg:        #f6f1e7;
  --surface:   #ffffff;
  --ink:       #1f2a44;
  --ink-soft:  #4a5572;
  --muted:     #8a90a0;
  --accent:    #b4893a;
  --accent-2:  #3e6b8a;
  --rust:      #a84a2f;
  --sage:      #6b8a6e;
  --line:      #e3dccd;
  --line-soft: #efe9dc;
  --danger:    #b3301c;
  --ok:        #3a6b46;
  --radius:    8px;
  --shadow:    0 1px 2px rgba(31, 42, 68, .06), 0 4px 14px rgba(31, 42, 68, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.admin {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--accent-2); }
.muted { color: var(--muted); }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-family: "Frank Ruhl Libre", Georgia, serif; font-size: 20px; font-weight: 600; }
.brand-sub { font-family: Inter, sans-serif; font-size: 12px; color: var(--muted); margin-left: 6px; text-transform: uppercase; letter-spacing: .08em; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav-link {
  padding: 6px 12px; border-radius: 6px; color: var(--ink-soft);
  text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--line-soft); color: var(--ink); }
.nav-link.active { background: var(--ink); color: #fff; }
.user { display: flex; align-items: center; gap: 12px; color: var(--ink-soft); }
.btn-link { color: var(--accent-2); text-decoration: none; }
.btn-link:hover { text-decoration: underline; }

.content { max-width: 1100px; margin: 0 auto; padding: 28px; }
h1 { margin: 0 0 16px; font-family: "Frank Ruhl Libre", Georgia, serif; font-weight: 600; }
h2 { margin: 28px 0 12px; font-family: "Frank Ruhl Libre", Georgia, serif; font-weight: 500; font-size: 22px; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid var(--line); background: var(--surface); }
.flash-ok  { border-color: #b9d8c2; background: #ecf6ee; color: #284d33; }
.flash-err { border-color: #e8b9b1; background: #faecea; color: #6b1d10; }
.flash-info{ border-color: #c8d4df; background: #eef3f7; color: #243949; }

/* Dashboard cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card {
  display: block; padding: 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
}
.card:hover:not(.card-static) { border-color: var(--accent); }
.card-num   { font-size: 32px; font-weight: 600; color: var(--accent-2); }
.card-label { font-size: 14px; color: var(--ink-soft); margin-top: 4px; }
.card-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }

.status { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-top: 20px; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.list th { background: var(--line-soft); font-weight: 600; font-size: 13px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
table.list tr:last-child td { border-bottom: none; }
table.list tr.inactive { opacity: 0.55; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--line-soft); color: var(--ink-soft); }
.tag-mazal_tov   { background: #f7eed8; color: #6b4f15; }
.tag-condolences { background: #f7e0d8; color: #6b2615; }
.tag-event       { background: #e0ecdf; color: #2c4a30; }
.tag-kiddush     { background: #e0ecdf; color: #2c4a30; }
.tag-notice      { background: #dde7ef; color: #244257; }

/* Buttons */
.btn {
  display: inline-block; padding: 8px 14px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(1.05); }
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* Inside table cells, keep action buttons inline regardless of cell width. */
table.list td.btn-row,
table.list td .btn-row { flex-wrap: nowrap; white-space: nowrap; justify-content: flex-end; }
/* Sortable column headers */
table.list th a.sort-link { color: inherit; text-decoration: none; display: inline-flex; align-items: baseline; gap: 4px; cursor: pointer; }
table.list th a.sort-link:hover { color: var(--accent); }
table.list th a.sort-link .arrow { font-size: 10px; opacity: .85; }

/* Forms */
form.stacked { display: grid; gap: 14px; max-width: 720px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
form.stacked label { display: grid; gap: 6px; font-size: 14px; color: var(--ink-soft); }
form.stacked input[type=text],
form.stacked input[type=date],
form.stacked input[type=number],
form.stacked input[type=time],
form.stacked input[type=password],
form.stacked select,
form.stacked textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink);
}
form.stacked textarea { min-height: 100px; resize: vertical; }
form.stacked .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
form.stacked .row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
form.stacked .row[lang=he] input, form.stacked label[lang=he] input,
form.stacked label[lang=he] textarea, .rtl input, .rtl textarea { direction: rtl; text-align: right; }
form.stacked .help { font-size: 12px; color: var(--muted); }
form.stacked .actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 10px; border-top: 1px solid var(--line-soft); }
form.stacked input:focus, form.stacked select:focus, form.stacked textarea:focus { outline: 2px solid var(--accent-2); outline-offset: -1px; border-color: var(--accent-2); }

/* Inline forms (delete button in lists) */
form.inline { display: inline; }

/* Page header (title + action button) */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }

/* Filter bar */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar input[type=search], .filter-bar select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font: inherit; }
.filter-bar input[type=search] { flex: 1; min-width: 220px; }
.filter-bar input:focus, .filter-bar select:focus { outline: 2px solid var(--accent-2); outline-offset: -1px; border-color: var(--accent-2); }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; width: min(360px, 92vw); box-shadow: var(--shadow); }
.login-card h1 { font-size: 22px; margin-bottom: 18px; }
.login-card form { display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.login-card input { padding: 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.login-card button { width: 100%; padding: 10px; }

.footbar { padding: 14px 28px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); margin-top: 40px; text-align: center; }

/* Service Rules read-only reference card */
.rules-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.rules-card h2 { margin: 0 0 14px; font-family: "Frank Ruhl Libre", Georgia, serif; font-weight: 500; font-size: 22px; color: var(--ink); }
.rules-table { width: 100%; border-collapse: collapse; }
.rules-table th, .rules-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.rules-table tr:last-child td { border-bottom: none; }
.rules-table th { background: var(--line-soft); font-size: 13px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.rules-list { margin: 0; padding-left: 20px; line-height: 1.55; color: var(--ink-soft); }
.rules-list li { margin-bottom: 8px; }
.rules-list li:last-child { margin-bottom: 0; }
.rules-list strong { color: var(--ink); }

/* Theme picker on Settings */
.theme-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 4px; }
.theme-card {
  display: grid; grid-template-rows: auto 1fr auto; gap: 10px;
  padding: 14px; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: border-color .15s;
}
.theme-card input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.theme-card.selected, .theme-card:has(input:checked) { border-color: var(--accent-2); }
.theme-card .theme-label { font-weight: 500; }
.theme-preview { display: grid; gap: 6px; padding: 14px; border-radius: 6px; min-height: 100px; }
.theme-preview-light { background: #f6f1e7; border: 1px solid #e3dccd; }
.theme-preview-dark  { background: #131b30; border: 1px solid #2a3449; }
.theme-preview .theme-preview-bar  { height: 8px; border-radius: 3px; background: #b4893a; width: 40%; }
.theme-preview .theme-preview-line { height: 6px; border-radius: 3px; }
.theme-preview-light .theme-preview-line { background: #1f2a44; }
.theme-preview-dark  .theme-preview-line { background: #f6f1e7; }
.theme-preview-light .theme-preview-line.short, .theme-preview-dark .theme-preview-line.short { width: 65%; opacity: .6; }

/* Modal */
dialog.modal {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  background: var(--surface); color: var(--ink); box-shadow: 0 14px 40px rgba(31,42,68,.25);
  max-width: 460px; width: min(92vw, 460px);
}
dialog.modal::backdrop { background: rgba(31, 42, 68, .35); }
dialog.modal label { display: grid; gap: 6px; font-size: 14px; color: var(--ink-soft); margin-top: 8px; }
dialog.modal input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
dialog.modal code { background: var(--line-soft); padding: 1px 5px; border-radius: 3px; }

/* ── Speakers (drasha sign-up) ─────────────────────────────────────────── */
.signup-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.signup-form input[type="text"] {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; min-width: 160px;
}
.speaker-name { font-weight: 600; }
.pill {
  display: inline-block; font-size: 11px; line-height: 1; padding: 4px 8px;
  border-radius: 999px; margin-left: 6px; vertical-align: middle;
  text-transform: uppercase; letter-spacing: .04em; border: 1px solid var(--line);
}
.pill-member { background: #eef3f7; color: var(--accent-2); border-color: #c8d4df; }
.pill-guest  { background: #f3efe6; color: var(--accent);   border-color: #e3dccd; }
.pill-ok     { background: #ecf6ee; color: var(--ok);       border-color: #b9d8c2; }
.pill-tent   { background: #faf4ea; color: var(--accent);   border-color: #e6d8bf; }
.confirm-box {
  background: #faf4ea; border: 1px solid #e6d8bf; border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
}
.confirm-box p { margin: 0; }
.btn-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* ── Dropdown top nav (Board / Site / Speakers / Members) ──────────────── */
.nav { align-items: center; }
.nav-item { position: relative; }
button.nav-link, .nav-top { background: none; border: 0; font: inherit; cursor: pointer; }
.nav-top { display: inline-flex; align-items: center; gap: 4px; }
.caret { font-size: .7em; opacity: .65; }
.menu-panel {
  position: absolute; top: 100%; left: 0; min-width: 210px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); padding: 6px; display: none; z-index: 50;
}
.nav-item:hover > .menu-panel,
.nav-item:focus-within > .menu-panel { display: block; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border-radius: 6px; color: var(--ink-soft); text-decoration: none;
  white-space: nowrap; background: none; border: 0; width: 100%; text-align: left;
  font: inherit; cursor: pointer;
}
.menu-item:hover { background: var(--line-soft); color: var(--ink); }
.menu-item.active { background: var(--ink); color: #fff; }
.has-sub > .menu-panel-sub { top: -6px; left: 100%; }
.user-name { font-weight: 600; }
.btn-link.active { text-decoration: underline; }

/* ── Members directory (sort + filter) ─────────────────────────────────── */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type="search"] { padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; font: inherit; min-width: 240px; }
th.sortable a { color: inherit; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
th.sortable a:hover { color: var(--accent-2); }
.sort-ind { font-size: .8em; opacity: .7; }

/* Announcement display-window status flags */
.win-flag { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.win-expired   { background: #f3d6cf; color: #8a2f1b; }
.win-scheduled { background: #d9e6f2; color: #1f4a6b; }

/* ---------------------------------------------------------------------------
   Mobile / narrow-screen admin (phones). The list tables are wide, so on a
   phone the far-right Edit/Delete column was hidden inside the .table-wrap
   horizontal scroll and easy to miss ("can't edit on my phone"). Below 640px
   each row becomes a stacked card with its actions visible and tap-sized.
   Desktop layout is unchanged.
--------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .content { padding: 14px; }

  /* Don't trap rows in a horizontal scroll box on phones. */
  .table-wrap { overflow-x: visible; border: none; box-shadow: none; background: transparent; }

  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list thead { display: none; }
  table.list tr {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 12px; padding: 8px 12px;
  }
  table.list td { border-bottom: none; padding: 5px 0; }

  /* Actions: left-aligned, wrapping, comfortable tap targets. */
  table.list td.btn-row,
  table.list td .btn-row {
    display: flex; flex-wrap: wrap; white-space: normal;
    justify-content: flex-start; gap: 8px; padding-top: 8px;
  }
  table.list .btn { padding: 10px 16px; }

  /* Stacked forms + toolbars fit the viewport. */
  form.stacked { padding: 16px; }
  form.stacked .actions { justify-content: flex-start; }
  /* Multi-column field rows would overflow a phone (date/time inputs have a
     min width); stack them so the whole form fits. */
  form.stacked .row, form.stacked .row3 { grid-template-columns: 1fr; }
  .toolbar, .filter-bar { flex-wrap: wrap; }
  .toolbar input[type="search"], .filter-bar input[type=search] { min-width: 0; width: 100%; }
}
