/* Minimal dashboard styles for slice W1 (read-only). No build step.
   Replaced later with Pico/Tailwind once on a clean network. */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f2430;
  --border: #2a3140;
  --text: #e7ecf3;
  --muted: #9aa6b8;
  --accent: #4c8dff;
  --accent-2: #2ecc71;
  --warn: #f1c40f;
  --danger: #e74c3c;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fa;
    --panel: #ffffff;
    --panel-2: #f0f3f8;
    --border: #e2e8f0;
    --text: #1a2230;
    --muted: #5b6779;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1000px; margin: 0 auto; padding: 0 20px 60px; }

header.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky; top: 0; z-index: 10;
}
/* topbar is itself a single flex container; direct children are 3 semantic groups
   (left / center / right) spread via `justify-content: space-between`. No nested .container. */
header.topbar.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: nowrap;
  justify-content: space-between;
  max-width: 1000px; margin: 0 auto; padding: 14px 20px;
}

h2 { font-size: 20px; margin: 28px 0 12px; }
h3 { font-size: 16px; margin: 22px 0 8px; color: var(--text); }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* Cards */
.card, article.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 14px 0;
}
.card h3 { margin-top: 0; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  white-space: nowrap;
}
.badge.type-cta { background: rgba(255,90,31,.22); color: #ff9b5f; border-color: rgba(255,90,31,.45); }
.badge.type-pvp { background: rgba(231,76,60,.16); color: var(--danger); border-color: transparent; }
.badge.type-pve { background: rgba(46,204,113,.16); color: var(--accent-2); border-color: transparent; }
.badge.type-other { background: var(--panel-2); color: var(--muted); border-color: transparent; }
.badge.status-scheduled { color: var(--accent); }
.badge.status-active { color: var(--accent-2); }
.badge.status-completed { color: var(--muted); }
.badge.status-cancelled { color: var(--danger); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--panel-2); }

/* Composition */
.group { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; background: var(--panel); position: relative; }
.group-del { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; line-height: 1; }
.group-del:hover { color: var(--danger); }
.group-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; }
.group-head .label { font-weight: 600; font-size: 16px; }
.group-head .meta { color: var(--muted); font-size: 13px; }
.role-line { padding: 6px 0; border-top: 1px dashed var(--border); }
.role-line:first-of-type { border-top: 0; }
.role-num { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.participants { color: var(--muted); font-size: 13px; margin-top: 2px; }
.edit-signups { margin: 8px 0 14px; border: 1px dashed var(--border); border-radius: 8px; padding: 8px 10px; }
.edit-signup-role { padding: 6px 0; border-top: 1px dashed var(--border); }
.edit-signup-role:first-child { border-top: 0; }

.counters { display: flex; gap: 18px; flex-wrap: wrap; margin: 4px 0 6px; }
.counter { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.counter b { display: block; font-size: 18px; }
.counter span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.empty { color: var(--muted); font-style: italic; padding: 18px 0; }
.row-link { cursor: pointer; }
.ext { margin-left: 6px; opacity: .6; text-decoration: none; }
.ext:hover { opacity: 1; }

/* Forms */
form label { display: block; margin: 14px 0; font-weight: 600; }
form input, form select, form textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font: inherit;
}
form textarea { min-height: 72px; resize: vertical; }
form input:focus, form select:focus, form textarea:focus { outline: none; border-color: var(--accent); }
form button {
  margin-top: 18px; padding: 10px 20px; background: var(--accent); color: #fff;
  border: 0; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
}
form button:hover { filter: brightness(1.08); }
form button:disabled { opacity: .5; cursor: not-allowed; }
ul { margin: 6px 0; }
a.btn {
  display: inline-block; font-size: 13px; font-weight: 600; padding: 4px 12px;
  background: var(--accent); color: #fff; border-radius: 8px; text-decoration: none;
  vertical-align: middle;
}
a.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary {
  background: var(--panel-2);
  color: var(--text);
}
.btn.secondary:hover {
  filter: brightness(1.08);
}

/* Roster board */
.roster-add { display: flex; gap: 8px; align-items: center; margin: 14px 0; flex-wrap: wrap; }
.roster-add select { width: auto; margin: 0; }
.roster-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.roster-group { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.roster-group-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline; padding: 2px 4px 10px; border-bottom: 1px solid var(--border); }
.roster-group-cols { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; padding-top: 10px; }
.roster-col-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); min-width: 150px; flex: 1 1 150px; max-width: 240px; }
.roster-col-head { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
.roster-col { list-style: none; margin: 0; padding: 6px; min-height: 44px; }
.chip { display: flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; padding: 5px 8px; margin: 4px 0; font-size: 14px; cursor: grab; }
.chip-inline { display: inline-flex; margin: 4px 6px 0 0; cursor: default; }
.chip:active { cursor: grabbing; }
.chip-name { flex: 1; }
.chip-x, .chip-ok { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 2px; line-height: 1; }
.chip-x:hover { color: var(--danger); }
.chip-ok { color: var(--accent-2); }
.chip-pending { display: inline-flex; margin: 4px 6px 4px 0; cursor: default; }
.roster-pending { margin-top: 6px; }
.sortable-ghost { opacity: .4; }

/* Weekly calendar */
.calendar-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.calendar-head h2 { margin-right: auto; }
.calendar-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.calendar-day { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-width: 0; }
.calendar-day h3 { margin-top: 0; }
.calendar-event { border-top: 1px dashed var(--border); padding: 9px 0; }
.calendar-event:first-of-type { border-top: 0; }
.calendar-event.event-cta { background: rgba(255,90,31,.10); border: 1px solid rgba(255,90,31,.38); border-left: 4px solid #ff5a1f; border-radius: 8px; padding: 9px 10px; margin: 6px 0; }
.calendar-event-meta { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px; }
@media (max-width: 820px) {
  .calendar-grid { grid-template-columns: 1fr; }
}


/* ─── Header (feat/header-redesign) ─────────────────────────────────────────── */
/* Topbar layout lives above (header.topbar.topbar) — single flex container.
   Component classes for the children follow. */
.topbar-logo {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 1.1em; text-decoration: none; color: inherit;
}
.topbar-logo:hover { color: var(--accent); }
.topbar-logo .logo-icon { font-size: 1.2em; }
.topbar-clock {
  font-family: var(--mono); font-size: 0.95em; color: var(--muted);
  letter-spacing: 0.5px; min-width: 90px;
}
.tz-switch { display: inline-flex; gap: 2px; }
.tz-switch button {
  /* `margin: 0` resets the legacy `form button { margin-top: 18px }` rule, which applied to
     the language toggle (a <form>) and shifted its buttons 18px down vs. the UTC/Local span. */
  margin: 0;
  background: none; border: 1px solid var(--border); color: var(--muted);
  padding: 1px 6px; font-size: 0.75em; cursor: pointer; border-radius: 4px;
}
.tz-switch button.active { color: var(--text); border-color: var(--accent); font-weight: 600; }
.tz-switch button:hover { border-color: var(--accent); }

.bot-status {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); vertical-align: middle;
  transition: background 0.3s;
}
.bot-status.online { background: var(--accent-2); box-shadow: 0 0 4px var(--accent-2); }
.bot-status.offline { background: var(--danger); }

.user-menu { position: relative; display: inline-flex; align-items: center; }
.topbar-left,
.topbar-center,
.topbar-right {
  display: flex; align-items: center; gap: 12px;
}
/* form inside topbar resets (browsers add default margin to <form>) */
.topbar-center form,
.topbar-right form { margin: 0; }
.user-menu-trigger {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: none; border: none; color: inherit; padding: 4px 8px;
  border-radius: 6px;
}
.user-menu-trigger:hover { background: var(--panel-2); }
.user-menu-trigger img { width: 28px; height: 28px; border-radius: 50%; }
.user-menu-panel {
  position: absolute; top: 100%; right: 0; min-width: 200px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); z-index: 100; margin-top: 4px; overflow: hidden;
}
.user-menu-panel a, .user-menu-panel button {
  display: flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box;
  padding: 8px 12px; text-decoration: none; color: inherit; background: none;
  border: none; cursor: pointer; font-size: 0.95em; text-align: left;
}
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--panel-2); }
.user-menu-panel form { margin: 0; }
/* Reset the legacy `form button { margin-top:18px; padding:10px 20px; background:accent; }`
   so the logout button looks like a menu item, not a fat primary form button. */
.user-menu-panel form button {
  margin: 0; padding: 8px 12px; background: none; border: 0; border-radius: 0;
  font-weight: inherit; color: var(--danger);
}

/* ─── Guild sub-nav (Setup / Calendar / Alliance) ──────────────────────────── */
.guild-subnav {
  display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 0;
  border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.guild-subnav a {
  padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--muted);
  font-size: 0.92em;
}
.guild-subnav a:hover { color: var(--text); background: var(--panel-2); }
.guild-subnav a.active { color: var(--text); background: var(--panel-2); font-weight: 600; }

/* Global application-admin console (separate from per-guild navigation). */
.admin-subnav {
  display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 0;
  border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.admin-subnav a, .admin-subnav span {
  padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--muted);
  font-size: 0.92em;
}
.admin-subnav a:hover { color: var(--text); background: var(--panel-2); }
.admin-subnav a.active { color: var(--text); background: var(--panel-2); font-weight: 600; }
.admin-subnav .disabled { opacity: .55; cursor: default; }
.admin-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px;
  margin: 16px 0;
}
.admin-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px;
}
.admin-card h3 { margin: 0 0 8px; font-size: 1em; }
.admin-status { color: var(--muted); font-size: 0.92em; }
.admin-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); font-size: 0.8em;
}
.admin-card.state-healthy { border-left: 3px solid var(--accent-2); }
.admin-card.state-degraded, .admin-badge.state-degraded { border-color: #f39c12; }
.admin-card.state-down { border-left: 3px solid var(--danger); }
.admin-badge.state-healthy { color: var(--accent-2); }
.admin-badge.state-down { color: var(--danger); }
.admin-badge.state-unknown { opacity: .7; }
.admin-card.state-attention { border-left: 3px solid #f39c12; }
.admin-card.state-unavailable { border-left: 3px solid var(--danger); }
.admin-badge.state-attention { color: #f39c12; border: 1px solid rgba(243,156,18,.45); }
.admin-badge.state-unavailable { color: var(--danger); border: 1px solid rgba(231,76,60,.45); }
.admin-details { margin: 12px 0 0; font-size: 0.88em; }
.admin-details div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.admin-details dt { color: var(--muted); }
.admin-details dd { margin: 0; text-align: right; }
.admin-filter {
  display: flex; align-items: end; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; margin: 14px 0;
}
.admin-filter label { min-width: 130px; margin: 0; font-size: .84em; color: var(--muted); }
.admin-filter input, .admin-filter select { margin: 4px 0 0; min-width: 130px; }
.admin-filter button, .admin-inline-form button { margin: 0; }
.admin-filter a.secondary { background: var(--panel-2); color: var(--text); }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9em; }
.admin-table th, .admin-table td {
  padding: 9px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top;
}
.admin-table th { color: var(--muted); font-size: .82em; text-transform: uppercase; }
.admin-table details { margin-top: 6px; }
.admin-table pre, .admin-occurrence pre {
  white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto;
  background: var(--panel-2); padding: 10px; border-radius: 6px;
}
.nowrap { white-space: nowrap; }
.small { font-size: .82em; }
.admin-badge.level-warning { color: #f39c12; }
.admin-badge.level-error, .admin-badge.level-critical { color: var(--danger); }
.admin-badge.level-critical { font-weight: 700; border: 1px solid var(--danger); }
.admin-badge.status-open { color: var(--danger); }
.admin-badge.status-resolved { color: var(--accent-2); }
.admin-badge.status-ignored { opacity: .72; }
.admin-incident-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; }
.admin-incident-meta div, .admin-note, .admin-occurrence {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px;
}
.admin-incident-meta dt { color: var(--muted); font-size: .82em; }
.admin-incident-meta dd { margin: 4px 0 0; word-break: break-word; }
.admin-inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 16px; }
.admin-occurrence, .admin-note { margin: 8px 0; }
.admin-occurrence header { color: var(--muted); font-size: .84em; }
.admin-warning {
  background: rgba(243,156,18,.12); border-left: 3px solid #f39c12;
  border-radius: 6px; padding: 10px 12px;
}
.admin-guild-summary .admin-card { display: flex; flex-direction: column; gap: 3px; }
.admin-guild-summary strong { font-size: 1.65em; }
.admin-guild-name { display: flex; align-items: center; gap: 9px; min-width: 220px; }
.admin-guild-name img, .admin-guild-detail-header img {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
}
.admin-guild-icon {
  width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; background: var(--panel-2); color: var(--accent); font-weight: 700;
  flex: 0 0 auto;
}
.admin-guild-icon.large { width: 52px; height: 52px; font-size: 1.25em; }
.admin-guild-detail-header {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 20px 0 14px;
}
.admin-guild-detail-header img { width: 52px; height: 52px; }
.admin-guild-detail-header h1 { margin: 0; }
.admin-guild-detail-header p { margin: 2px 0 0; }
.admin-guild-detail-header > .admin-badge { margin-left: auto; }
.admin-detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px;
}
.admin-detail-grid .admin-card { margin: 0; }
.admin-module-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px;
}
.admin-module-grid article { border-left: 2px solid var(--border); padding-left: 12px; }
.admin-module-grid article h3 { margin-top: 0; }
.admin-pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 18px 0; }

/* ─── Breadcrumbs ─────────────────────────────────────────────────────────── */
.breadcrumbs {
  font-size: 0.85em; color: var(--muted); padding: 4px 0 12px;
}
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs .sep { margin: 0 6px; opacity: 0.6; }
.breadcrumbs .current { color: var(--text); }

/* Mobile: hide clock + UTC/Local toggle. Keep logo + language switch + profile. */
@media (max-width: 600px) {
  header.topbar.topbar { gap: 8px; font-size: 0.9em; padding: 10px 16px; }
  .topbar-clock,
  .topbar-center > .tz-switch:not(.lang-switch) { display: none; }
  .topbar-clock { min-width: 0; }
  .user-menu-trigger img { width: 24px; height: 24px; }
}

/* ─── Package A additions (2026-08-02) ─────────────────────────────────────── */
/* Wrap <table> for horizontal scroll on narrow viewports. Mirrors admin-table-wrap
   but uses a shorter name for general use outside /admin. */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Prevent border collapse from bleeding past the scroll container: */
  padding-bottom: 2px;
}

/* HTMX error toast — populated by app.js on htmx:responseError. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--danger);
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  font-size: 0.92em;
  max-width: 90vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Submit button while form is submitting (prevents double-submit). */
form.is-submitting button[type="submit"],
button.is-submitting {
  opacity: 0.6;
  cursor: progress;
}

/* ─── Package B additions (2026-08-02) ─────────────────────────────────────── */
/* Native <dialog> confirm modal. Native API handles focus trap, Esc, backdrop. */
dialog.confirm-dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  max-width: min(420px, 90vw);
  box-shadow: 0 16px 40px rgba(0,0,0,0.4);
}
dialog.confirm-dialog::backdrop {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
}
dialog.confirm-dialog .confirm-title {
  margin: 0 0 12px;
  font-size: 1.1em;
}
dialog.confirm-dialog .confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin: 0;
}
dialog.confirm-dialog .confirm-actions button {
  margin: 0;
}

/* Generic danger button (used as the confirm action for destructive confirms). */
.btn.btn-danger {
  background: var(--danger);
}
.btn.btn-danger:hover {
  filter: brightness(1.08);
}

/* Inline form field error (Package B B4). */
.field-error {
  color: var(--danger);
  font-size: 0.85em;
  margin: 4px 0 0;
}

/* ─── Package C C4: extracted utility classes (2026-08-02) ────────────────── */
/* Each class replaces a high-repeat (3+ uses) inline style pattern. */

/* Table cell with tight padding (alliance × 5, albion × 22). */
.cell-tight { padding: 4px 8px; }

/* Table cell with default padding (rights × 16). */
.cell { padding: 6px 8px; }

/* Table cell + nowrap (rights × 3). */
.cell-nowrap { padding: 6px 8px; white-space: nowrap; }

/* Bold header-like cell, no wrap (rights × 3). */
.cell-th-nowrap { padding: 6px 8px; font-weight: bold; white-space: nowrap; }

/* Table head row: left-aligned header with bottom separator (rights × 3). */
.thead-row { text-align: left; border-bottom: 1px solid var(--border, #444); }

/* Table body row: bottom separator + top vertical align (rights × 3). */
.tbody-row-top { border-bottom: 1px solid var(--border, #333); vertical-align: top; }

/* Full-width collapsed table (rights × 3). */
.table-collapse { width: 100%; border-collapse: collapse; }

/* Small font size (alliance × 3, rights × 3). */
.text-sm { font-size: 0.85em; }

/* Medium bottom margin (rights × 3). */
.mb-12 { margin-bottom: 12px; }

/* Small top margin (alliance × 3). */
.mt-8 { margin-top: 8px; }

/* Pointer-cursor hint for clickable non-button element (alliance × 5). */
.clickable { cursor: pointer; }

/* Full-width form input with border-box sizing (alliance × 5, whitespace-tolerant). */
.input-full { width: 100%; box-sizing: border-box; }

/* Inline-block display (alliance × 4). */
.inline-block { display: inline-block; }

/* Inline display (albion × 3). */
.inline { display: inline; }
