/* ORM Admin Portal - editor styles
   Deliberately plain and roomy. The person using this is not a designer or a
   developer; large targets, obvious buttons and generous spacing matter more
   than density. */

:root {
  --brand: #8c5f63;
  --brand-dark: #6d484c;
  --brand-light: #f6eeee;
  --ink: #24211f;
  --ink-soft: #5f5854;
  --line: #e2dcd8;
  --bg: #faf8f7;
  --panel: #ffffff;
  --ok: #2f7d55;
  --ok-bg: #e8f5ee;
  --warn: #9a6a12;
  --warn-bg: #fdf3e0;
  --danger: #a3372f;
  --danger-bg: #fbeceb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 18px rgba(0, 0, 0, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }
a { color: var(--brand-dark); }

/* --- login ---------------------------------------------------------------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.login-card h1 { margin-bottom: .25rem; }
.login-card .sub { color: var(--ink-soft); margin-bottom: 1.5rem; }

/* --- app shell ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar__title { font-weight: 700; margin-right: auto; }
.topbar__title small { display: block; font-weight: 400; color: var(--ink-soft); font-size: .8rem; }

.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 1.5rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}

.sidebar {
  position: sticky;
  top: 76px;
  align-self: start;
}
.navlist { list-style: none; margin: 0; padding: 0; }
.navlist li + li { margin-top: 2px; }
.navlist button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: .6rem .75rem;
  border-radius: 8px;
  font: inherit;
  color: var(--ink-soft);
  cursor: pointer;
}
.navlist button:hover { background: var(--brand-light); color: var(--brand-dark); }
.navlist button[aria-current="true"] {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
.navlist .navgroup {
  margin: 1.25rem 0 .35rem;
  padding: 0 .75rem;
  font-size: .72rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #9a918c;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 1.25rem; }
.panel__intro { color: var(--ink-soft); margin-bottom: 1.5rem; }

/* --- forms ---------------------------------------------------------------- */

.field { margin-bottom: 1.25rem; }
.field > label,
.field > .label {
  display: block;
  font-weight: 600;
  margin-bottom: .3rem;
  font-size: .93rem;
}
.field .hint { color: var(--ink-soft); font-size: .85rem; margin: -.15rem 0 .4rem; }

input[type="text"],
input[type="url"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: .6rem .7rem;
  border: 1px solid #cfc7c2;
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}
textarea { resize: vertical; min-height: 92px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* --- buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: #efe9e6;
  color: var(--ink);
  text-decoration: none;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--publish { background: var(--ok); color: #fff; }
.btn--ghost { background: transparent; border-color: #cfc7c2; }
.btn--danger { background: transparent; border-color: #d9b4b0; color: var(--danger); }
.btn--sm { padding: .3rem .6rem; font-size: .85rem; }

.btnrow { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

/* --- status --------------------------------------------------------------- */

.banner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .8rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  border: 1px solid;
}
.banner--warn { background: var(--warn-bg); border-color: #eccf98; color: var(--warn); }
.banner--ok { background: var(--ok-bg); border-color: #a8d6bd; color: var(--ok); }
.banner--danger { background: var(--danger-bg); border-color: #e5b3ae; color: var(--danger); }
.banner p { margin: 0; }
.banner .btn { margin-left: auto; flex-shrink: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1px solid;
}
/* Never colour alone: each badge carries a symbol so the state survives
   greyscale printing and colour-blindness. */
.badge--live { background: var(--ok-bg); border-color: #a8d6bd; color: var(--ok); }
.badge--hidden { background: #eeebe9; border-color: #cfc7c2; color: #6b6360; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: .7rem 1.1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 60;
  max-width: 90vw;
}
.toast--error { background: var(--danger); }

/* --- lists (books, questions) --------------------------------------------- */

.item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: .75rem;
  background: #fff;
  overflow: hidden;
}
.item__head {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .75rem;
}
.item__thumb {
  width: 46px;
  height: 62px;
  object-fit: cover;
  border-radius: 5px;
  background: #eee;
  flex-shrink: 0;
}
.item__meta { min-width: 0; flex: 1; }
.item__meta strong { display: block; }
.item__meta span { color: var(--ink-soft); font-size: .87rem; }
.item__actions { display: flex; gap: .35rem; flex-shrink: 0; }
.item__body { padding: 0 .75rem 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }

.iconbtn {
  border: 1px solid #cfc7c2;
  background: #fff;
  border-radius: 7px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--ink-soft);
}
.iconbtn:hover:not(:disabled) { background: var(--brand-light); border-color: var(--brand); color: var(--brand-dark); }
.iconbtn:disabled { opacity: .35; cursor: not-allowed; }

/* --- images --------------------------------------------------------------- */

.imagefield { display: flex; gap: 1rem; align-items: flex-start; }
.imagefield__preview {
  width: 120px;
  min-height: 90px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #f3efed;
  flex-shrink: 0;
}
.imagefield__controls { flex: 1; min-width: 0; }

/* --- theme swatches ------------------------------------------------------- */

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.swatch {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: .7rem;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.swatch[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.swatch__colors { display: flex; gap: 4px; margin-bottom: .5rem; }
.swatch__colors span { width: 26px; height: 26px; border-radius: 5px; border: 1px solid rgba(0,0,0,.12); }
.swatch__name { font-weight: 600; font-size: .9rem; }

/* --- section toggles ------------------------------------------------------ */

.toggle-row {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .8rem .9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: .6rem;
  background: #fff;
}
.toggle-row--off { background: #f7f5f4; }
.toggle-row__label { flex: 1; min-width: 0; }
.toggle-row__label strong { display: block; }
.toggle-row__label span { color: var(--ink-soft); font-size: .86rem; }

.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track {
  position: absolute; inset: 0; cursor: pointer;
  background: #c3bbb6; border-radius: 999px; transition: background .15s;
}
.switch__track::before {
  content: ""; position: absolute; height: 22px; width: 22px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .15s;
}
.switch input:checked + .switch__track { background: var(--ok); }
.switch input:checked + .switch__track::before { transform: translateX(22px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch input:disabled + .switch__track { opacity: .45; cursor: not-allowed; }

/* --- history -------------------------------------------------------------- */

.version {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .7rem .9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: .5rem;
  background: #fff;
}
.version__meta { flex: 1; min-width: 0; }
.version__meta strong { display: block; font-weight: 600; }
.version__meta span { color: var(--ink-soft); font-size: .85rem; }

/* --- misc ----------------------------------------------------------------- */

.muted { color: var(--ink-soft); }
.small { font-size: .87rem; }
.stack > * + * { margin-top: 1rem; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.problem-list { margin: .5rem 0 0; padding-left: 1.2rem; }
.problem-list li { margin-bottom: .25rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
