/* Hawcus admin panel - built on the same tokens as the public site. */

.adm { background: var(--surface-2); min-height: 100vh; }

/* Views are toggled with the hidden attribute, but many of them set display from a
   class, which outranks the browser default of [hidden] { display: none }. Without
   this, hiding a view does nothing. */
[hidden] { display: none !important; }

/* ---------------- login ---------------- */
.adm-login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: linear-gradient(150deg, color-mix(in srgb, var(--brand) 12%, #fff), var(--surface-2)); }
.adm-login__card {
  width: min(420px, 100%);
  background: #fff; border: 2px solid var(--ink); border-radius: 1.25rem;
  padding: clamp(1.75rem, 4vw, 2.5rem);
  box-shadow: var(--shadow-lg);
  display: grid; gap: 0.85rem;
}
.adm-login__card img { justify-self: start; margin-bottom: 0.35rem; }
.adm-login__card h1 { font-size: 1.6rem; margin: 0; }
.adm-login__card > p { color: var(--muted-ink); font-weight: 600; font-size: 0.9rem; margin: 0 0 0.5rem; }
.adm-login__card label { display: grid; gap: 0.35rem; }
.adm-login__card label span { font-size: 0.82rem; font-weight: 800; color: var(--ink); }

.adm input, .adm textarea, .adm select {
  width: 100%; font-family: inherit; font-size: 0.92rem; font-weight: 600; color: var(--ink);
  background: #fff; border: 1.5px solid var(--ink); border-radius: 0.6rem;
  padding: 0.6rem 0.75rem;
}
.adm textarea { resize: vertical; line-height: 1.5; }
.adm input:focus, .adm textarea:focus, .adm select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
}

.adm-error { color: #b91c1c; font-size: 0.85rem; font-weight: 700; margin: 0; }
.adm-ok { color: #157347; font-size: 0.85rem; font-weight: 700; margin: 0; }

/* ---------------- shell ---------------- */
.adm-app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.adm-side {
  background: #111318; color: #fff;
  padding: 1.25rem 1rem;
  display: flex; flex-direction: column; gap: 1.5rem;
  position: sticky; top: 0; height: 100vh;
}
.adm-side__logo img { filter: brightness(0) invert(1); }
.adm-nav { display: grid; gap: 0.25rem; }
.adm-nav__item {
  display: flex; align-items: center; gap: 0.65rem;
  width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  color: #b9bec6; font-family: inherit; font-size: 0.92rem; font-weight: 700;
  padding: 0.65rem 0.75rem; border-radius: 0.6rem;
  transition: background 0.18s ease, color 0.18s ease;
}
.adm-nav__item svg { width: 18px; height: 18px; }
.adm-nav__item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.adm-nav__item.is-on { background: var(--brand); color: #fff; }

.adm-side__foot { margin-top: auto; display: grid; gap: 0.4rem; }
.adm-side__foot a, .adm-side__foot button {
  background: none; border: none; cursor: pointer; text-align: left;
  color: #8f959e; font-family: inherit; font-size: 0.85rem; font-weight: 700;
  text-decoration: none; padding: 0.4rem 0.75rem; border-radius: 0.5rem;
}
.adm-side__foot a:hover, .adm-side__foot button:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.adm-main { padding: clamp(1.25rem, 3vw, 2rem); min-width: 0; }

.adm-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.adm-top h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin: 0; }
.adm-top p { margin: 0.2rem 0 0; color: var(--muted-ink); font-weight: 600; font-size: 0.9rem; }
.adm-who { display: flex; align-items: center; gap: 0.6rem; }
.adm-who__av {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 800; border: 2px solid var(--ink);
}
.adm-who b { display: block; font-size: 0.88rem; font-weight: 800; }
.adm-who small { font-size: 0.76rem; color: var(--muted-ink); font-weight: 600; }

.adm-tab { display: none; }
.adm-tab.is-on { display: block; }

/* ---------------- cards / kpis ---------------- */
.adm-card {
  background: #fff; border: 2px solid var(--ink); border-radius: 1rem;
  padding: 1.15rem; margin-bottom: 1.25rem; box-shadow: var(--shadow-sm);
}
.adm-card__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.adm-card__head h2 { font-size: 1.05rem; margin: 0; }
.adm-card > h2 { font-size: 1.05rem; margin: 0 0 1rem; }

.adm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.85rem; margin-bottom: 1.25rem; }
.adm-kpi { background: #fff; border: 2px solid var(--ink); border-radius: 0.9rem; padding: 0.9rem 1rem; }
.adm-kpi small { display: block; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted-ink-2); }
.adm-kpi b { display: block; font-size: 1.7rem; font-weight: 800; color: var(--ink); line-height: 1.2; margin: 0.15rem 0; }
.adm-kpi span { font-size: 0.75rem; font-weight: 600; color: var(--muted-ink); }

/* ---------------- chart ---------------- */
.adm-chart { display: flex; align-items: flex-end; gap: 0.4rem; height: 160px; }
.adm-bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 0.35rem; }
.adm-bar i {
  width: 100%; border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--brand), var(--brand-dark));
  border: 1.5px solid var(--ink);
  transition: opacity 0.2s ease;
}
.adm-bar:hover i { opacity: 0.75; }
.adm-bar span { font-size: 0.62rem; font-weight: 700; color: var(--muted-ink-2); }

/* ---------------- tables ---------------- */
.adm-tablewrap { overflow-x: auto; }
.adm-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.adm-table th {
  text-align: left; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
  color: #fff; background: var(--ink); padding: 0.6rem 0.75rem;
}
.adm-table th:first-child { border-radius: 0.5rem 0 0 0.5rem; }
.adm-table th:last-child { border-radius: 0 0.5rem 0.5rem 0; }
.adm-table td { padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--hairline); font-size: 0.88rem; font-weight: 600; color: var(--ink); vertical-align: middle; }
.adm-table td b { display: block; font-weight: 800; }
.adm-table td small { display: block; font-size: 0.72rem; color: var(--muted-ink); font-weight: 600; }
.adm-table tr:last-child td { border-bottom: none; }
.adm-empty { text-align: center; color: var(--muted-ink); padding: 2rem 0 !important; }
.adm-rowact { display: flex; gap: 0.4rem; justify-content: flex-end; }

.adm-pill { display: inline-block; font-size: 0.68rem; font-weight: 800; border-radius: 999px; padding: 0.18rem 0.55rem; border: 1.5px solid var(--ink); }
.adm-pill--published { background: #e7f8ee; color: #157347; }
.adm-pill--draft { background: var(--surface-2); color: var(--muted-ink); }

/* ---------------- buttons ---------------- */
.adm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  font-family: inherit; font-size: 0.82rem; font-weight: 800; cursor: pointer;
  border: 1.5px solid var(--ink); border-radius: 0.55rem;
  padding: 0.42rem 0.75rem; background: #fff; color: var(--ink); text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease;
}
.adm-btn svg { width: 15px; height: 15px; }
.adm-btn:hover { background: var(--ink); color: #fff; }
.adm-btn--primary { background: var(--brand); color: #fff; }
.adm-btn--primary:hover { background: var(--brand-dark); color: #fff; }
.adm-btn--danger { background: #fff; color: #b91c1c; border-color: #b91c1c; }
.adm-btn--danger:hover { background: #b91c1c; color: #fff; }
.adm-btn--block { width: 100%; }
.adm-btn.is-on { background: var(--ink); color: #fff; }

/* ---------------- editor ---------------- */
.adm-editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; align-items: start; }
.adm-editor__side { position: sticky; top: 1.5rem; }

.adm-field { display: grid; gap: 0.3rem; margin-bottom: 0.9rem; }
.adm-field:last-child { margin-bottom: 0; }
.adm-field > span { font-size: 0.8rem; font-weight: 800; color: var(--ink); }
.adm-field i { font-style: normal; font-weight: 600; color: var(--muted-ink); font-size: 0.74rem; }

.adm-modes { display: flex; gap: 0.35rem; }

.adm-toolbar { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.6rem; }
.adm-toolbar button {
  font-family: inherit; font-size: 0.78rem; font-weight: 800; cursor: pointer;
  background: var(--surface-2); color: var(--ink);
  border: 1.5px solid var(--hairline); border-radius: 0.45rem;
  padding: 0.3rem 0.6rem; min-width: 34px;
}
.adm-toolbar button:hover { background: var(--ink); color: #fff; border-color: var(--ink); }

.adm-content {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem; line-height: 1.6;
}
.adm-preview {
  border: 1.5px dashed var(--hairline); border-radius: 0.6rem;
  padding: 1rem; max-height: 600px; overflow-y: auto; background: #fff;
}
.adm-hint { font-size: 0.76rem; font-weight: 600; color: var(--muted-ink); margin: 0.5rem 0 0; }

.adm-faqs { display: grid; gap: 0.6rem; }
.adm-faq {
  display: grid; grid-template-columns: 1fr auto; gap: 0.4rem;
  border: 1.5px solid var(--hairline); border-radius: 0.6rem; padding: 0.6rem;
  background: var(--surface-2);
}
.adm-faq input { grid-column: 1; }
.adm-faq textarea { grid-column: 1 / -1; }
.adm-faq__x {
  grid-column: 2; grid-row: 1;
  width: 32px; height: 32px; border-radius: 0.45rem; cursor: pointer;
  background: #fff; border: 1.5px solid var(--ink); color: var(--ink);
  font-size: 1.1rem; line-height: 1;
}
.adm-faq__x:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }

.adm-actions { display: grid; gap: 0.5rem; margin-top: 1rem; }

.adm-stats #post-stats-body { display: grid; gap: 0.5rem; }
.adm-stat { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; padding: 0.45rem 0; border-bottom: 1px solid var(--hairline); }
.adm-stat:last-child { border-bottom: none; }
.adm-stat small { font-size: 0.78rem; font-weight: 700; color: var(--muted-ink); }
.adm-stat b { font-size: 1.05rem; font-weight: 800; color: var(--ink); }

/* ---------------- toast ---------------- */
.adm-toast {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 50;
  background: var(--ink); color: #fff;
  border-radius: 0.7rem; padding: 0.75rem 1.1rem;
  font-size: 0.88rem; font-weight: 700;
  box-shadow: var(--shadow-lg);
}
.adm-toast.is-error { background: #b91c1c; }

@media (max-width: 1080px) {
  .adm-editor { grid-template-columns: 1fr; }
  .adm-editor__side { position: static; }
}
@media (max-width: 820px) {
  .adm-app { grid-template-columns: 1fr; }
  .adm-side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
  .adm-nav { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
  .adm-side__foot { margin-top: 0; grid-auto-flow: column; }
}

/* ---------------- author picture ---------------- */
.adm-avatar {
  display: flex; align-items: center; gap: 0.75rem;
  margin-top: 0.35rem;
}
.adm-avatar img {
  width: 56px; height: 56px; flex: none;
  border-radius: 50%; object-fit: cover;
  border: 2px solid var(--ink); background: var(--surface-2);
}
/* The initial fallback, drawn exactly as the article draws it. */
.adm-avatar__ph {
  width: 56px; height: 56px; flex: none;
  border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--ink);
  background: var(--brand); color: #fff;
  font-size: 1.35rem; font-weight: 800;
}
.adm-avatar__acts { display: flex; flex-direction: column; gap: 0.35rem; }

/* The file input is driven by its label, so hide it without display:none, which
   would stop some browsers from opening the picker. */
.adm-visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
label.adm-btn { cursor: pointer; }
.adm-visually-hidden:focus-visible + .adm-avatar label.adm-btn,
label.adm-btn:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
