/*
 * The Iron Prophet — admin panel. Same dark iron tokens as the public app
 * (tokens.css), but a wider, denser, sidebar-driven layout: this is an
 * operator tool, not the ember chamber.
 */

body.admin {
  display: block;
}

.admin-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.admin-nav {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-2);
  background: var(--iron-900);
  border-right: 1px solid var(--edge);
}

.admin-nav__wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--steel);
}

.admin-nav__label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ember-glow);
  margin-top: -0.75rem;
}

.admin-nav__list {
  list-style: none;
  margin: var(--s-2) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-nav__link {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: var(--r-sm);
  color: var(--ash);
  text-decoration: none;
  font-size: 0.9rem;
}

.admin-nav__link:hover {
  color: var(--steel);
  background: var(--iron-800);
}

.admin-nav__link.is-current {
  color: var(--ember-glow);
  background: rgba(255, 106, 0, 0.1);
}

/* The shared language switcher is positioned absolute for the public
   topbar; the sidebar needs it back in normal flow. */
.admin-nav .locale-switcher {
  position: static;
  margin-top: auto;
  font-size: 0.7rem;
}

.admin-nav__back {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--ash);
  text-decoration: none;
}

.admin-nav__back:hover {
  color: var(--steel);
}

.admin-main {
  flex: 1;
  min-width: 0;
  padding: var(--s-3) var(--s-4);
  max-width: 1080px;
}

.admin-flash {
  padding: 0.75rem 1rem;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  margin-bottom: var(--s-2);
}

.admin-flash--notice {
  background: rgba(255, 106, 0, 0.1);
  color: var(--ember-glow);
  border: 1px solid var(--ember-deep);
}

.admin-flash--alert {
  background: rgba(220, 60, 40, 0.12);
  color: #ff8f7a;
  border: 1px solid #7a2c1e;
}

.admin-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
  flex-wrap: wrap;
}

.admin-header h1 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 1.3rem;
  color: var(--steel);
  margin: 0;
}

.admin-header p {
  color: var(--ash);
  font-size: 0.85rem;
  margin: 0.25rem 0 0;
}

.admin-panel {
  background: var(--metal);
  border-radius: var(--r-lg);
  box-shadow: var(--ring), var(--elev-flat);
  padding: var(--s-3);
  margin-bottom: var(--s-3);
}

.admin-panel__title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--steel);
  margin: 0 0 var(--s-2);
}

/* Stat tiles for the dashboard. */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.admin-stat {
  background: var(--metal);
  border-radius: var(--r-md);
  box-shadow: var(--ring), var(--elev-flat);
  padding: var(--s-2);
}

.admin-stat__label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ash);
}

.admin-stat__value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--ember-glow);
  margin-top: 0.25rem;
}

/* CSS-only bar chart — no chart library per the CSP. */
.admin-bars {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.admin-bar {
  display: grid;
  grid-template-columns: 120px 1fr 48px;
  align-items: center;
  gap: var(--s-1);
  font-size: 0.85rem;
}

.admin-bar__label {
  color: var(--ash);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-bar__track {
  background: var(--iron-900);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  box-shadow: var(--well);
}

.admin-bar__fill {
  height: 100%;
  background: var(--ember-grad);
  border-radius: 999px;
}

/* Width buckets in 5% steps — the CSP forbids inline `style="width:..."`,
   so Admin::bars_helper#width_bucket_class picks the nearest of these. */
.admin-bar__fill--w0 { width: 1%; }
.admin-bar__fill--w5 { width: 5%; }
.admin-bar__fill--w10 { width: 10%; }
.admin-bar__fill--w15 { width: 15%; }
.admin-bar__fill--w20 { width: 20%; }
.admin-bar__fill--w25 { width: 25%; }
.admin-bar__fill--w30 { width: 30%; }
.admin-bar__fill--w35 { width: 35%; }
.admin-bar__fill--w40 { width: 40%; }
.admin-bar__fill--w45 { width: 45%; }
.admin-bar__fill--w50 { width: 50%; }
.admin-bar__fill--w55 { width: 55%; }
.admin-bar__fill--w60 { width: 60%; }
.admin-bar__fill--w65 { width: 65%; }
.admin-bar__fill--w70 { width: 70%; }
.admin-bar__fill--w75 { width: 75%; }
.admin-bar__fill--w80 { width: 80%; }
.admin-bar__fill--w85 { width: 85%; }
.admin-bar__fill--w90 { width: 90%; }
.admin-bar__fill--w95 { width: 95%; }
.admin-bar__fill--w100 { width: 100%; }

.admin-bar__value {
  text-align: right;
  color: var(--steel);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* Tables — the CRUD workhorse. */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.admin-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ash);
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--edge);
}

.admin-table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid rgba(51, 54, 61, 0.5);
  color: var(--parchment);
  vertical-align: top;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-table a {
  color: var(--ember-glow);
  text-decoration: none;
}

.admin-table a:hover {
  text-decoration: underline;
}

.admin-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--edge);
  color: var(--ash);
}

.admin-badge--ok {
  color: var(--ember-glow);
  border-color: var(--ember-deep);
  background: rgba(255, 106, 0, 0.08);
}

.admin-badge--warn {
  color: #ff8f7a;
  border-color: #7a2c1e;
  background: rgba(220, 60, 40, 0.1);
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
  flex-wrap: wrap;
}

.admin-toolbar__filters {
  display: flex;
  gap: var(--s-1);
  align-items: center;
}

/* Forms — model-backed, plain server round-trips. */
.admin-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  max-width: 640px;
}

.admin-form--wide {
  max-width: 100%;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-field label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ash);
}

.admin-field__hint {
  font-size: 0.78rem;
  color: var(--ash);
}

.admin-field input[type="text"],
.admin-field input[type="email"],
.admin-field input[type="number"],
.admin-field input[type="datetime-local"],
.admin-field select,
.admin-field textarea {
  background: var(--iron-900);
  border: 1px solid var(--edge);
  border-radius: var(--r-sm);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.6rem 0.7rem;
  box-shadow: var(--well);
}

.admin-field textarea {
  font-family: var(--font-mono);
  min-height: 8rem;
  resize: vertical;
}

.admin-field input:focus-visible,
.admin-field select:focus-visible,
.admin-field textarea:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 1px;
}

.admin-field-errors {
  color: #ff8f7a;
  font-size: 0.8rem;
}

.admin-actions {
  display: flex;
  gap: var(--s-1);
  align-items: center;
}

.admin-error-summary {
  background: rgba(220, 60, 40, 0.1);
  border: 1px solid #7a2c1e;
  border-radius: var(--r-sm);
  padding: 0.75rem 1rem;
  color: #ff8f7a;
  font-size: 0.85rem;
}

.admin-empty {
  color: var(--ash);
  font-style: italic;
  padding: var(--s-2) 0;
}

.admin-steps {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.admin-step {
  border: 1px solid var(--edge);
  border-radius: var(--r-md);
  padding: var(--s-2);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Field-by-field explanations on the Help page. */
.admin-defs {
  margin: var(--s-2) 0 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: var(--s-2);
  row-gap: 0.4rem;
}

.admin-defs dt {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--steel);
  white-space: nowrap;
}

.admin-defs dd {
  margin: 0;
  color: var(--ash);
  font-size: 0.88rem;
}
