/* ==========================================================================
   Well Works Enterprises — admin panel
   Layered on top of the tokens in site.css.
   ========================================================================== */

:root { --side-w: 250px; --topbar-h: 62px; }

body.admin { background: var(--ink-50); color: var(--ink-700); }

/* --- Shell --------------------------------------------------------------- */
.admin-shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

.admin-side {
  background: var(--ink-900); color: rgba(255,255,255,.7);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-side__brand {
  display: flex; align-items: center; gap: .65rem; padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.09); text-decoration: none;
}
.admin-side__brand svg,
.admin-side__brand img { width: 32px; height: 32px; flex: none; }
.admin-side__brand b { color: #fff; font-size: .9375rem; letter-spacing: -.01em; display: block; line-height: 1.2; }
.admin-side__brand span { font-size: .625rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.42); }

.admin-nav { padding: 1rem .75rem; flex: 1; }
.admin-nav h4 {
  font-size: .625rem; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(255,255,255,.35); margin: 1.35rem .5rem .5rem; font-weight: 600;
}
.admin-nav h4:first-child { margin-top: 0; }
.admin-nav a {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .75rem; border-radius: 8px;
  color: rgba(255,255,255,.7); text-decoration: none; font-size: .9rem; font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.admin-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.admin-nav a.is-active { background: var(--brand-600); color: #fff; }
.admin-nav a .count {
  margin-left: auto; font-size: .6875rem; font-weight: 700; background: rgba(255,255,255,.16);
  color: #fff; border-radius: 100px; padding: .1rem .45rem; min-width: 1.4rem; text-align: center;
}
.admin-nav a.is-active .count { background: rgba(0,0,0,.28); }
.admin-nav svg { width: 17px; height: 17px; flex: none; opacity: .85; }

.admin-side__foot { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.09); font-size: .8125rem; }
.admin-side__foot a { color: rgba(255,255,255,.6); text-decoration: none; }
.admin-side__foot a:hover { color: #fff; text-decoration: underline; }

/* --- Topbar -------------------------------------------------------------- */
.admin-main { min-width: 0; display: flex; flex-direction: column; }
.admin-top {
  position: sticky; top: 0; z-index: 40; background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--ink-200);
  min-height: var(--topbar-h); display: flex; align-items: center; gap: 1rem; padding: .6rem 1.75rem;
}
.admin-top__title { font-weight: 600; color: var(--ink-900); font-size: 1rem; letter-spacing: -.01em; }
.admin-top__spacer { margin-left: auto; }
.admin-user { display: flex; align-items: center; gap: .6rem; font-size: .8125rem; color: var(--ink-500); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-100); color: var(--brand-800); font-weight: 700; font-size: .8125rem; flex: none;
}
.admin-body { padding: 1.75rem; flex: 1; }
.admin-burger { display: none; }

/* The scrim is the first child of .admin-shell, so it must stay out of the
   grid on desktop — otherwise it takes the sidebar column and pushes every
   other item along one. It only becomes a real overlay in the mobile block. */
.admin-scrim { display: none; }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side {
    position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 90;
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .admin-side.is-open { transform: none; }
  .admin-burger {
    display: inline-grid; place-items: center; width: 38px; height: 38px;
    border: 1px solid var(--ink-200); background: #fff; border-radius: 8px; cursor: pointer;
  }
  .admin-body { padding: 1.25rem; }
  .admin-top { padding: .6rem 1.25rem; }
  .admin-scrim {
    position: fixed; inset: 0; background: rgba(11,10,18,.45); z-index: 80; display: none;
  }
  .admin-scrim.is-open { display: block; }
}

/* --- Page header --------------------------------------------------------- */
.page-head {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start;
  justify-content: space-between; margin-bottom: 1.5rem;
}
.page-head h1 { font-size: 1.5rem; margin: 0 0 .3rem; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--ink-500); font-size: .9375rem; max-width: 62ch; }

/* --- Panels & tables ----------------------------------------------------- */
.panel { background: #fff; border: 1px solid var(--ink-200); border-radius: 12px; }
.panel__head {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--ink-200);
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between;
}
.panel__head h2 { margin: 0; font-size: 1rem; }
.panel__body { padding: 1.25rem; }
.panel__foot { padding: .9rem 1.25rem; border-top: 1px solid var(--ink-200); background: var(--ink-50);
  border-radius: 0 0 12px 12px; display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: .8rem 1.25rem; border-bottom: 1px solid var(--ink-100); vertical-align: top; }
table.data thead th {
  font-size: .6875rem; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-400);
  background: var(--ink-50); font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--ink-200);
}
table.data thead th a { color: inherit; text-decoration: none; display: inline-flex; gap: .3rem; align-items: center; }
table.data thead th a:hover { color: var(--brand-700); }
table.data tbody tr:hover { background: var(--brand-50); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .strong { font-weight: 600; color: var(--ink-900); }
table.data a.title { color: var(--ink-900); font-weight: 600; text-decoration: none; }
table.data a.title:hover { color: var(--brand-700); text-decoration: underline; }
table.data .muted { color: var(--ink-400); font-size: .8125rem; }
table.data .nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; flex-wrap: wrap; }

.empty { padding: 3.5rem 1.5rem; text-align: center; color: var(--ink-500); }
.empty h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.empty p { max-width: 40ch; margin: 0 auto 1.25rem; font-size: .9375rem; }

/* --- Badges -------------------------------------------------------------- */
.badge {
  display: inline-block; padding: .18rem .55rem; border-radius: 100px; font-size: .6875rem;
  font-weight: 700; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap;
  border: 1px solid transparent;
}
.badge--green  { background: #e6f8f1; color: #0a7a58; border-color: #bfeadb; }
.badge--amber  { background: #fdf1e3; color: #a3560c; border-color: #f6ddc0; }
.badge--grey   { background: var(--ink-100); color: var(--ink-500); border-color: var(--ink-200); }
.badge--brand  { background: var(--brand-50); color: var(--brand-800); border-color: var(--brand-100); }
.badge--red    { background: #fdecec; color: #a12020; border-color: #f6cfcf; }

/* --- Stat tiles ---------------------------------------------------------- */
.tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 1.75rem; }
.tile { background: #fff; border: 1px solid var(--ink-200); border-radius: 12px; padding: 1.15rem 1.25rem; text-decoration: none; display: block; transition: border-color .15s ease, box-shadow .15s ease; }
a.tile:hover { border-color: var(--brand-300); box-shadow: var(--shadow-sm); }
.tile dt { font-size: .6875rem; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-400); font-weight: 600; margin-bottom: .35rem; }
.tile dd { margin: 0; font-size: 1.75rem; font-weight: 700; color: var(--ink-900); letter-spacing: -.03em; line-height: 1.1; }
.tile small { display: block; margin-top: .3rem; font-size: .75rem; color: var(--ink-400); }

/* --- Forms --------------------------------------------------------------- */
.form-grid { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
@media (max-width: 1000px) { .form-grid { grid-template-columns: 1fr; } }
.form-section + .form-section { margin-top: 1.25rem; }
fieldset { border: 0; padding: 0; margin: 0 0 1.5rem; }
fieldset legend {
  font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-400);
  font-weight: 600; padding: 0; margin-bottom: .9rem;
}
.field small.hint { color: var(--ink-400); font-size: .8125rem; }
.field .err { color: #c0392b; font-size: .8125rem; }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: #e07a7a; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.1rem; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.check-row { display: flex; align-items: flex-start; gap: .7rem; padding: .8rem; border: 1px solid var(--ink-200); border-radius: 10px; margin-bottom: .7rem; background: #fff; }
.check-row input { margin-top: .28rem; width: 17px; height: 17px; accent-color: var(--brand-600); flex: none; }
.check-row label { font-weight: 600; font-size: .9375rem; color: var(--ink-900); cursor: pointer; display: block; }
.check-row p { margin: .15rem 0 0; font-size: .8125rem; color: var(--ink-500); }
.check-row:has(input:checked) { border-color: var(--brand-300); background: var(--brand-50); }

/* --- Toolbar / filters --------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.toolbar input[type="search"], .toolbar input[type="text"], .toolbar select {
  font: inherit; font-size: .875rem; padding: .5rem .7rem; border: 1px solid var(--ink-200);
  border-radius: 8px; background: #fff; color: var(--ink-800);
}
.toolbar input[type="search"] { min-width: 220px; }
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }

/* --- Flash messages ------------------------------------------------------ */
.flash { display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1.1rem; border-radius: 10px;
  margin-bottom: 1.1rem; font-size: .9rem; border: 1px solid; }
.flash--success { background: #e9f9f3; border-color: #b6e6d4; color: #0a6b4d; }
.flash--error   { background: #fdeded; border-color: #f5c9c9; color: #93221f; }
.flash--info    { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-800); }
.flash strong { color: inherit; }

/* --- Pagination ---------------------------------------------------------- */
.pager { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.pager a, .pager span {
  display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 .55rem;
  border: 1px solid var(--ink-200); border-radius: 8px; font-size: .8125rem; font-weight: 600;
  text-decoration: none; color: var(--ink-600); background: #fff;
}
.pager a:hover { border-color: var(--brand-300); color: var(--brand-700); }
.pager .is-current { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.pager .is-disabled { opacity: .45; pointer-events: none; }

/* --- Editor -------------------------------------------------------------- */
.tox-tinymce { border-radius: 10px !important; border-color: var(--ink-200) !important; }
.editor-wrap { border-radius: 10px; }

.cover-preview {
  border: 1px solid var(--ink-200); border-radius: 10px; overflow: hidden; margin-bottom: .75rem;
  background: var(--ink-50);
}
.cover-preview img { width: 100%; display: block; }

/* --- Login --------------------------------------------------------------- */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 2rem 1.25rem;
  background: radial-gradient(120% 130% at 80% 0%, #3a0bb5 0%, #1d0459 45%, #0b0a12 100%);
}
.login-card { width: 100%; max-width: 27rem; background: #fff; border-radius: 16px; padding: 2.25rem; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 1.35rem; margin-bottom: .25rem; }
.login-card > p { color: var(--ink-500); font-size: .9375rem; margin-bottom: 1.75rem; }
.login-brand { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.5rem; text-decoration: none; }
.login-brand svg,
.login-brand img { width: 36px; height: 36px; }
.login-brand b { color: var(--ink-900); font-size: 1rem; display: block; line-height: 1.2; }
.login-brand span { font-size: .625rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-400); }
.login-foot { text-align: center; margin-top: 1.5rem; font-size: .8125rem; color: rgba(255,255,255,.6); }
.login-foot a { color: rgba(255,255,255,.85); }

/* --- Detail view --------------------------------------------------------- */
.detail-list { margin: 0; }
.detail-list > div { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 1rem;
  padding: .75rem 0; border-bottom: 1px solid var(--ink-100); }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { font-size: .8125rem; color: var(--ink-400); font-weight: 600; }
.detail-list dd { margin: 0; color: var(--ink-800); word-break: break-word; }
.detail-list a { color: var(--brand-700); }
@media (max-width: 560px) { .detail-list > div { grid-template-columns: 1fr; gap: .15rem; } }

.rating { color: var(--warn); letter-spacing: .1em; font-size: .8125rem; }
.rating .off { color: var(--ink-200); }
