/* =====================================================================
   Lydbogsforlaget – fælles designsystem (app, admin, forlag)
   Farver: "Natblå" (ro, troværdighed) + "Lampelys" (varm accent).
   Fonte: Fraunces (overskrifter, bog-følelse) + Inter (alt andet).
   Lys og mørk tilstand følger systemet; kan låses med data-theme.
   ===================================================================== */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, serif;

  /* Grundfarver */
  --c-bg: #F7F5F1;          /* papir */
  --c-surface: #FFFFFF;
  --c-surface-2: #F0EDE7;
  --c-border: #DDD8CF;
  --c-text: #1B2230;
  --c-muted: #5E6675;
  --c-primary: #1E3A5F;     /* natblå */
  --c-primary-hover: #284C78;
  --c-on-primary: #FFFFFF;
  --c-accent: #D9922E;      /* lampelys */
  --c-accent-soft: #FBEBD3;
  --c-record: #D23C3C;      /* kun optageknappen */
  --c-success: #2F7D4F;
  --c-success-soft: #E1F2E7;
  --c-warning: #A86A00;
  --c-warning-soft: #FCEFD6;
  --c-danger: #B83232;
  --c-danger-soft: #F8E1E1;
  --c-focus: #3B82C4;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgb(20 30 50 / 6%), 0 4px 16px rgb(20 30 50 / 6%);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --c-bg: #0F1520;
    --c-surface: #172030;
    --c-surface-2: #1E2A3D;
    --c-border: #2C3A50;
    --c-text: #E7EAF0;
    --c-muted: #9AA4B4;
    --c-primary: #8DB4E8;
    --c-primary-hover: #A6C6F0;
    --c-on-primary: #0F1520;
    --c-accent: #F2B45A;
    --c-accent-soft: #3A2C17;
    --c-record: #F06060;
    --c-success: #6CC490;
    --c-success-soft: #173325;
    --c-warning: #E8B04A;
    --c-warning-soft: #3A2C10;
    --c-danger: #F07A7A;
    --c-danger-soft: #3A1A1A;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --c-bg: #0F1520; --c-surface: #172030; --c-surface-2: #1E2A3D; --c-border: #2C3A50;
  --c-text: #E7EAF0; --c-muted: #9AA4B4; --c-primary: #8DB4E8; --c-primary-hover: #A6C6F0;
  --c-on-primary: #0F1520; --c-accent: #F2B45A; --c-accent-soft: #3A2C17; --c-record: #F06060;
  --c-success: #6CC490; --c-success-soft: #173325; --c-warning: #E8B04A; --c-warning-soft: #3A2C10;
  --c-danger: #F07A7A; --c-danger-soft: #3A1A1A;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
}

/* ------------------------------------------------------------ Grund */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font: 400 16px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--c-primary); text-underline-offset: 2px; }
a:hover { color: var(--c-primary-hover); }
:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--c-muted); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ Logo */
.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--c-text); }
.brand img { width: 36px; height: 36px; border-radius: 8px; box-shadow: 0 0 0 1px var(--c-border); }
.brand span { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; letter-spacing: -.01em; }
.brand small { display: block; font-family: var(--font-ui); font-size: .75rem; font-weight: 500; color: var(--c-muted); letter-spacing: .04em; text-transform: uppercase; }

/* ------------------------------------------------------------ Knapper */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .6rem 1.1rem;
  border: 1px solid var(--c-border); border-radius: var(--radius);
  background: var(--c-surface); color: var(--c-text);
  font: 600 1rem/1.2 var(--font-ui); text-decoration: none; cursor: pointer;
  transition: background-color .15s var(--ease), transform .1s var(--ease), border-color .15s;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn:active { transform: scale(.98); }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: default; pointer-events: none; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-on-primary); }
.btn-primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); color: var(--c-on-primary); }
.btn-danger { color: var(--c-danger); }
.btn-small { min-height: 34px; padding: .35rem .75rem; font-size: .875rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--c-primary); font: inherit; font-weight: 500; text-decoration: underline; cursor: pointer; }
.btn-link:hover { background: none; }

/* ------------------------------------------------------------ Formularer */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field label { font-weight: 600; font-size: .9rem; }
.field .hint { font-size: .8rem; color: var(--c-muted); }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: .55rem .8rem;
  border: 1px solid var(--c-border); border-radius: var(--radius);
  background: var(--c-surface); color: var(--c-text);
  font: 400 1rem/1.4 var(--font-ui);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none; border-color: var(--c-focus); box-shadow: 0 0 0 3px rgb(59 130 196 / 25%);
}
.field .error, .field-error { color: var(--c-danger); font-size: .85rem; }
.form-row { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ------------------------------------------------------------ Beskeder */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--c-success-soft); color: var(--c-success); border-color: color-mix(in srgb, var(--c-success) 25%, transparent); }
.alert-error   { background: var(--c-danger-soft);  color: var(--c-danger);  border-color: color-mix(in srgb, var(--c-danger) 25%, transparent); }
.alert-info    { background: var(--c-accent-soft);  color: var(--c-text);    border-color: color-mix(in srgb, var(--c-accent) 35%, transparent); }
.alert code { word-break: break-all; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--c-surface-2); color: var(--c-muted); }
.badge-success { background: var(--c-success-soft); color: var(--c-success); }
.badge-warning { background: var(--c-warning-soft); color: var(--c-warning); }
.badge-danger  { background: var(--c-danger-soft);  color: var(--c-danger); }

/* ------------------------------------------------------------ Kort */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.5rem; }

/* ------------------------------------------------------------ Login-sider */
.auth {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(1.5rem, env(safe-area-inset-top)) 1rem max(1.5rem, env(safe-area-inset-bottom));
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--c-accent) 14%, transparent), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--c-primary) 14%, transparent), transparent 60%),
    var(--c-bg);
}
.auth-card { width: 100%; max-width: 400px; animation: rise .35s var(--ease); }
.auth-head { display: flex; justify-content: center; margin-bottom: 1.5rem; }
.auth-card h1 { font-size: 1.5rem; margin-bottom: .25rem; }
.auth-card .lead { color: var(--c-muted); margin-bottom: 1.25rem; }
.auth-links { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; font-size: .9rem; }
.auth-foot { margin-top: 1.25rem; font-size: .85rem; color: var(--c-muted); display: flex; gap: 1rem; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ Admin/forlag-skal */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 1.5rem;
  padding: 1.25rem 1rem; background: var(--c-surface); border-right: 1px solid var(--c-border);
}
.nav { display: flex; flex-direction: column; gap: .15rem; }
.nav a {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; border-radius: var(--radius);
  color: var(--c-text); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--c-surface-2); }
.nav a[aria-current="page"] { background: var(--c-accent-soft); color: var(--c-text); font-weight: 600; }
.sidebar-foot { margin-top: auto; font-size: .875rem; }
.sidebar-foot .who { font-weight: 600; }
.main { padding: 2rem clamp(1rem, 3vw, 2.5rem); max-width: 1200px; width: 100%; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .75rem; border-right: 0; border-bottom: 1px solid var(--c-border); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin: 0 0 0 auto; }
}

/* ------------------------------------------------------------ Tabeller */
.table-wrap { overflow-x: auto; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); }
table.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--c-muted); font-weight: 600; background: var(--c-surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--c-surface-2) 60%, transparent); }
.table .actions { display: flex; gap: .4rem; justify-content: flex-end; flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: 1rem; }
.toolbar .input { max-width: 320px; }

/* Dialog (bekræftelser) */
dialog { border: 1px solid var(--c-border); border-radius: var(--radius-lg); background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow); padding: 1.5rem; max-width: 480px; width: calc(100% - 2rem); }
dialog::backdrop { background: rgb(10 15 25 / 45%); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
