/* Morpheus Admin – Go/templ reference implementation
   Replaces Vuetify 1.5 (EOL) with lean CSS of our own. */

*,
*::before,
*::after { box-sizing: border-box; }

:root {
  --primary: #1976d2;
  --sidebar-w: 260px;
  --border: #e2e8f0;
  --muted: #64748b;
}

html, body { height: 100%; margin: 0; }

body {
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  background: #f1f5f9;
  color: #1e293b;
}

[x-cloak] { display: none !important; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */

.app { display: flex; min-height: 100vh; }
.app__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app__content { padding: 24px; flex: 1; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: margin-left .18s ease;
}
.sidebar--collapsed { margin-left: calc(var(--sidebar-w) * -1); }

.sidebar__logo {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; font-weight: 600; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar__logo img { width: 28px; height: 28px; }
.sidebar__nav { padding: 8px 0; }

.nav-link {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 9px 20px;
  color: #cbd5e1; font-size: 14px;
  background: none; border: 0; cursor: pointer;
  text-align: left; text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link--active { background: rgba(255,255,255,.10); color: #fff; box-shadow: inset 3px 0 0 var(--primary); }
.nav-link--todo { opacity: .45; cursor: not-allowed; }
.nav-link .material-icons { font-size: 20px; }

.nav-group__children .nav-link { padding-left: 46px; font-size: 13px; }
.nav-group__chevron { margin-left: auto; font-size: 18px !important; transition: transform .15s; }
.nav-group__chevron.is-open { transform: rotate(180deg); }

.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.toolbar__title { font-size: 18px; font-weight: 500; margin: 0; }
.toolbar__spacer, .spacer { flex: 1; }

.account { position: relative; }
.account__btn {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 0; cursor: pointer; font-size: 14px; color: inherit;
}
.account__menu {
  position: absolute; right: 0; top: 110%;
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(15,23,42,.12);
  min-width: 210px; padding: 6px; z-index: 30;
}
.account__menu a, .account__menu button {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; background: none; cursor: pointer;
  font-size: 14px; color: inherit; border-radius: 4px;
}
.account__menu a:hover, .account__menu button:hover { background: #f1f5f9; text-decoration: none; }

/* Language choice in the account menu: a section of its own between the
   account and signing out - the heading on the left, the list box next to it. */
.account__section { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.account__label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #78909c;
}
.account__language { display: flex; align-items: center; gap: 8px; padding: 4px 10px; }
/* min-width: 0 lets the list box become narrower than its longest entry -
   without it the flex item keeps that width and pushes the menu apart. */
.account__language .select { width: auto; flex: 1; min-width: 0; padding: 4px 6px; font-size: 13px; }

/* ---------- Page ---------- */

.page { display: flex; flex-direction: column; gap: 16px; }
.page__heading { margin: 0; font-size: 20px; font-weight: 500; }
.page__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.card {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; box-shadow: 0 1px 2px rgba(15,23,42,.04);
  /* Some tables stand in a card and not in a table-wrap - the items of a
     product, the master data of a pool. Whatever is too wide is reachable by
     scrolling instead of ending at the edge. */
  overflow-x: auto;
}
.card--muted { background: #f8fafc; color: var(--muted); }
.card h3 { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

.panel { margin-top: 8px; }
.panel__title { font-size: 16px; font-weight: 500; margin: 0 0 8px; }

.skeleton {
  height: 80px; border-radius: 6px;
  background: linear-gradient(90deg,#f1f5f9,#e2e8f0,#f1f5f9);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 4px; border: 1px solid transparent;
  font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .3px;
  cursor: pointer; background: #e2e8f0; color: #1e293b; text-decoration: none;
}
.btn:hover { filter: brightness(.96); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--secondary { background: #475569; color: #fff; }
.btn--outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn--flat { background: transparent; color: var(--primary); }
.btn--danger { background: #dc2626; color: #fff; }
.btn--success { background: #16a34a; color: #fff; }
.btn--block { width: 100%; justify-content: center; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: none; cursor: pointer; color: #475569;
}
.icon-btn:hover { background: #e2e8f0; text-decoration: none; }
.icon-btn--danger:hover { background: #fee2e2; color: #b91c1c; }

/* ---------- Form ---------- */

.field { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.field__label { font-size: 12px; color: var(--muted); }
.field input, .input, .select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 14px; background: #fff; width: 100%;
}
.field input:focus, .input:focus, .select:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent);
  border-color: var(--primary);
}

.searchbar {
  display: flex; align-items: flex-end; gap: 10px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 12px;
}
.searchbar .field { max-width: 420px; }

.bulkbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 12px;
}
.bulkbar__count { font-weight: 600; color: #1d4ed8; }
.bulkbar .select, .bulkbar .input { width: auto; min-width: 200px; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form h1 { margin: 0 0 4px; font-size: 20px; text-align: center; }
.minimal-card {
  background: #fff; padding: 32px; border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15,23,42,.12); width: 360px;
}

/* ---------- Table ---------- */

.table-wrap {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  /* auto and not hidden: a table wider than the window was cut off before,
     and the columns behind the edge could not be reached at all - neither by
     scrolling the page, which does not scroll sideways either. The rounded
     corners keep clipping. */
  overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top;
}
.data-table th {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px; white-space: nowrap;
}
.data-table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.data-table th.active a { color: var(--primary); }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr.is-selected { background: #eff6ff; }
.sort-icon { font-size: 15px !important; }
.sort-icon--idle { opacity: .3; }
.col-select { width: 44px; }
/* text-left is not decoration: <td> is left of its own accord, <th> is not -
   the browser centres it. Without the rule the heading stood in the middle
   over its column while the values below it stood left. view.Column.AlignClass
   returns "text-left" as its default, so it applies to every table. */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.empty-row td { text-align: center; padding: 32px; color: var(--muted); }

.kv-table { width: 100%; border-collapse: collapse; }
/* the info marker beside a value: it explains, it does not shout */
.kv-table__info {
  font-size: 16px; vertical-align: text-bottom;
  color: var(--muted); cursor: help;
}
.kv-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.kv-table__key { width: 150px; font-weight: 600; color: var(--muted); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.sub { font-size: 11.5px; color: var(--muted); }
.stat { font-size: 15px; }
.ban-list { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.badge--danger { background: #fee2e2; color: #b91c1c; }

/* ---------- Pager ---------- */

.pager {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 12px; border-top: 1px solid var(--border); background: #f8fafc;
}
.pager__info { color: var(--muted); font-size: 13px; }
.pager__perpage { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.pager__links { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.pager__chip {
  min-width: 30px; height: 30px; padding: 0 8px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: 4px;
  background: #fff; color: #334155; font-size: 13px; text-decoration: none;
}
.pager__chip:hover { background: #e2e8f0; text-decoration: none; }
.pager__chip.is-current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager__chip.is-disabled { opacity: .4; pointer-events: none; }
.pager__gap { color: var(--muted); padding: 0 2px; }

/* ---------- Flash / Dialog / Indicator ---------- */

.flash-container { display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 10px 14px; border-radius: 6px; font-size: 13.5px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.flash button { background: none; border: 0; cursor: pointer; font-size: 18px; line-height: 1; color: inherit; }
.flash--success { background: #dcfce7; color: #166534; }
.flash--error { background: #fee2e2; color: #b91c1c; }
.flash--info { background: #dbeafe; color: #1e40af; }
.flash--warning { background: #fff3e0; color: #e65100; }

.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: grid; place-items: center; z-index: 60;
  /* On a low window a tall dialog reached past the edge and its buttons were
     out of reach. Now the backdrop scrolls, and the padding keeps the dialog
     off the edge while doing so. */
  overflow: auto; padding: 24px;
}
.dialog {
  background: #fff; border-radius: 8px; padding: 24px;
  box-shadow: 0 20px 50px rgba(15,23,42,.25);
  /* On a narrow window a fixed 360px would push out over the edge. */
  min-width: min(360px, 100%); max-width: min(520px, 100%);
}
/* a dialog that carries a table: 520px leaves too little beside the key
   column, and a long name breaks off */
.dialog--wide { max-width: 720px; width: min(720px, calc(100vw - 48px)); }
/* a long value wraps instead of running out of the dialog */
.dialog .kv-table td { overflow-wrap: anywhere; }
.dialog__message { margin: 0 0 20px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }

.htmx-indicator-bar {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--primary); transition: width .2s ease; z-index: 100;
}
.htmx-indicator-bar.htmx-request { width: 90%; }

.htmx-request.data-table, .htmx-request .data-table { opacity: .55; transition: opacity .1s; }
.minimal-body { display: grid; place-items: center; min-height: 100vh; }

/* ---------- generic CRUD views (registry modules) ---------- */
.muted { color: var(--text-muted, #90a4ae); }
.link { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.badge--muted { background: #eceff1; color: #546e7a; }
.badge--success { background: #e8f5e9; color: #2e7d32; }

.cell-text { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-inline {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; background: #f5f7f9; padding: 2px 6px; border-radius: 3px;
  display: inline-block; max-width: 340px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
}
.code-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; background: #263238; color: #eceff1;
  padding: 12px 14px; border-radius: 4px; overflow-x: auto; margin: 0;
}
.prose { margin: 0; white-space: pre-wrap; }

.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; }
.kv dt { color: #78909c; }
.kv dd { margin: 0; }

.detail-grid {
  margin: 0; display: grid; grid-template-columns: 220px 1fr;
  gap: 10px 20px; align-items: start;
}
.detail-grid dt { color: #607d8b; font-size: 13px; padding-top: 2px; }
.detail-grid dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.form { display: flex; flex-direction: column; gap: 16px; max-width: 720px; }
.form__actions { display: flex; gap: 10px; padding-top: 6px; }
/* a form whose groups stand in cards of their own */
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.field--error .input, .field--error .select { border-color: #e53935; }
.field__error { color: #e53935; font-size: 12px; margin: 4px 0 0; }
.field__hint { color: #90a4ae; font-size: 12px; margin: 4px 0 0; }
.required { color: #e53935; margin-left: 2px; }
.input--area, .input--code { width: 100%; resize: vertical; }
.input--code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.switch { display: inline-flex; align-items: center; gap: 8px; }

/* checkbox grid: behaviors of the entitlement and grant forms */
.checkbox-grid {
  display: grid; gap: 6px 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }

/* compact table inside forms (permissions, endpoints) */
.data-table--compact td, .data-table--compact th { padding: 6px 8px; font-size: 13px; }
.data-table--compact .input, .data-table--compact .select { margin: 0; }
.level-legend { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.level-legend li { margin: 2px 0; }

/* filter bar (code states) */
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip {
  display: inline-flex; align-items: center; padding: 4px 12px;
  border-radius: 14px; background: #eceff1; color: #37474f;
  font-size: 13px; text-decoration: none;
}
.chip:hover { background: #cfd8dc; }
.chip--active { background: var(--primary); color: #fff; }

/* the three actions on the pool page side by side */
.pool-actions {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: start;
}
.pool-actions .form { max-width: none; }

/* input field together with a button inside a table cell */
.inline-form { display: flex; align-items: center; gap: 4px; }
.inline-form__label { font-size: 13px; color: var(--muted); }

/* filter panel of the system messages (LogsFilterForm.vue) */
.filter-panel { display: flex; flex-direction: column; gap: 12px; }
.filter-panel__row { display: flex; flex-wrap: wrap; gap: 16px; }
.filter-panel__row .field { flex: 1 1 200px; }
.filter-panel__actions { display: flex; align-items: center; gap: 8px; }
.input--small { max-width: 90px; }
.badge--warning { background: #fff3e0; color: #e65100; }

/* expanded detail of a ban: side by side instead of one below the other */
.detail-grid--inline {
  grid-template-columns: auto 1fr auto 1fr; gap: 4px 12px;
  margin: 0; padding: 8px 4px; font-size: 13px;
}
.dialog__subtitle { margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.hidden-form { display: none; }

/* the four number fields of a version side by side */
.version-fields { display: flex; gap: 8px; }
.version-fields__item { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.checkbox input { margin: 0; }

/* values a form only shows and does not change */
.input--readonly { background: #eceff1; color: #546e7a; }
.icon-btn--active { color: var(--primary); }
.icon-btn[disabled] { opacity: .4; cursor: not-allowed; }

/* ---------- tool views (script editor) ---------- */
.script-layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; }
.script-versions__list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.script-versions__item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: 4px; text-decoration: none;
  color: inherit; font-size: 13px;
}
.script-versions__item:hover { background: #eceff1; }
.script-versions__item.is-current { background: var(--primary); color: #fff; }
.script-editor { max-width: none; }
.minimal-card__title { margin: 0 0 18px; font-size: 20px; font-weight: 500; }
@media (max-width: 860px) { .script-layout { grid-template-columns: 1fr; } }

/* the two arrows for reordering a listing */
.listing-order { white-space: nowrap; width: 1%; }

/* script and squad editor: the Vue admin hooked an Ace editor in here,
   here stands a text field that works without JavaScript as well. */
.code-editor {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.5; background: #263238; color: #eceff1;
  white-space: pre; overflow-wrap: normal; overflow-x: auto; tab-size: 2;
}
.script-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.script-head .field { min-width: 260px; margin: 0; }
.script-head__meta {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  font-size: 13px; padding-bottom: 6px;
}

/* expired pools: in the old tool the row carried the class "pool-expired".
   The period is over, no more codes can be reserved - that belongs visibly
   on the row, not only in the detail view. */
.data-table tbody tr.pool-expired { background: #fef2f2; color: #7f1d1d; }
.data-table tbody tr.pool-expired:hover { background: #fee2e2; }

/* counters of a pool, one below the other with a label. */
.stat-list { margin: 0; font-size: 12.5px; }
.stat-list__row { display: flex; gap: 6px; }
.stat-list dt { color: var(--muted); min-width: 92px; }
.stat-list dd { margin: 0; font-variant-numeric: tabular-nums; }

/* master data and generator side by side, like the two halves of the old
   pool page. On narrow windows one below the other. */
.pool-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; align-items: start; }
@media (max-width: 900px) { .pool-columns { grid-template-columns: 1fr; } }

