/**
 * Queen of Sheba admin — "Back of house".
 *
 * The public site is the dining room after dark; the admin is the pass under
 * working light. Parchment surfaces and espresso ink for long data-entry
 * sessions, with the same brand voice: berbere for the primary action, honey
 * for detail, an inscriptional serif for headings and the Ge'ez mark in the
 * header. One palette is forced for every theme mode — a staff tool should
 * look identical on every machine.
 *
 * No webfonts on purpose: the admin is used by staff in Germany and must not
 * call third-party font hosts. The serif stack leans on faces shipped with
 * every OS.
 */

:root,
html[data-theme='light'],
html[data-theme='dark'] {
  --qs-paper: #f6f0e4;
  --qs-card: #fffcf5;
  --qs-ink: #241809;
  --qs-quiet: #6d5b41;
  --qs-hairline: #e5d9c2;
  --qs-espresso: #16100a;
  --qs-espresso-2: #241a10;
  --qs-honey: #e0a94f;
  --qs-honey-deep: #8a5c14;
  --qs-berbere: #b8431d;
  --qs-berbere-deep: #963514;
  --qs-serif: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  --qs-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;

  /* --- Django admin variable overrides ----------------------------------- */
  --primary: var(--qs-espresso-2);
  --secondary: var(--qs-espresso);
  --accent: var(--qs-honey);
  --primary-fg: #f5ecdc;

  --body-fg: var(--qs-ink);
  --body-bg: var(--qs-paper);
  --body-quiet-color: var(--qs-quiet);
  --body-medium-color: #4c3d28;
  --body-loud-color: var(--qs-ink);

  --header-color: #cfba9c;
  --header-branding-color: var(--qs-honey);
  --header-bg: var(--qs-espresso);
  --header-link-color: #f5ecdc;

  --breadcrumbs-fg: var(--qs-quiet);
  --breadcrumbs-link-fg: var(--qs-honey-deep);
  --breadcrumbs-bg: transparent;

  --link-fg: #9c5617;
  --link-hover-color: #7a4110;
  --link-selected-fg: var(--qs-berbere);

  --hairline-color: var(--qs-hairline);
  --border-color: #d9cbb0;

  --error-fg: #a52f12;

  --message-success-bg: #eaf0d8;
  --message-warning-bg: #f8ecc9;
  --message-error-bg: #f6ddd3;

  --darkened-bg: #efe7d6;
  --selected-bg: #f2e6cc;
  --selected-row: #f5ead1;

  --button-fg: #fffcf5;
  --button-bg: var(--qs-espresso-2);
  --button-hover-bg: #3a2b1a;
  --default-button-bg: var(--qs-berbere);
  --default-button-hover-bg: var(--qs-berbere-deep);
  --close-button-bg: #6d5b41;
  --close-button-hover-bg: #4c3d28;
  --delete-button-bg: #8f2b10;
  --delete-button-hover-bg: #701f09;

  --object-tools-fg: #f5ecdc;
  --object-tools-bg: var(--qs-espresso-2);
  --object-tools-hover-bg: var(--qs-berbere);

  --font-family-primary: var(--qs-sans);

  color-scheme: light;
}

/* The OS may ask for dark — the answer is still the parchment ledger. */
@media (prefers-color-scheme: dark) {
  html[data-theme='auto'] {
    --primary: var(--qs-espresso-2);
    --primary-fg: #f5ecdc;
    --body-fg: var(--qs-ink);
    --body-bg: var(--qs-paper);
    --body-quiet-color: var(--qs-quiet);
    --body-loud-color: var(--qs-ink);
    --breadcrumbs-link-fg: var(--qs-honey-deep);
    --link-fg: #9c5617;
    --link-hover-color: #7a4110;
    --hairline-color: var(--qs-hairline);
    --border-color: #d9cbb0;
    --darkened-bg: #efe7d6;
    --selected-bg: #f2e6cc;
    --selected-row: #f5ead1;
    --button-fg: #fffcf5;
    --button-bg: var(--qs-espresso-2);
    --button-hover-bg: #3a2b1a;
    --default-button-bg: var(--qs-berbere);
    --default-button-hover-bg: var(--qs-berbere-deep);
    --close-button-bg: #6d5b41;
    --message-success-bg: #eaf0d8;
    --message-warning-bg: #f8ecc9;
    --message-error-bg: #f6ddd3;
    color-scheme: light;
  }
}

/* One palette means the toggle would be a lie — remove it. */
#header button.theme-toggle,
#nav-sidebar ~ * .theme-toggle {
  display: none !important;
}

/* --- Header ---------------------------------------------------------------- */

#header {
  padding: 18px 40px;
  border-bottom: 3px solid var(--qs-honey);
}

#site-name {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

#site-name a,
#site-name a:link,
#site-name a:visited {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--qs-serif);
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  color: #f5ecdc;
}

/* The medallion mark, cut from the supplied logo. */
.qs-logo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--qs-honey) 40%, transparent);
}

/* The Ge'ez mark — ንግሥተ ሳባ — set small beside the wordmark. */
#site-name .qs-geez {
  font-size: 0.8rem;
  color: var(--qs-honey);
  letter-spacing: 0.08em;
  opacity: 0.9;
}

#branding {
  align-items: baseline;
}

#user-tools {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

#user-tools a {
  border-bottom-color: color-mix(in srgb, var(--qs-honey) 40%, transparent);
}

#user-tools a:focus,
#user-tools a:hover {
  color: var(--qs-honey);
  border-bottom-color: var(--qs-honey);
}

/* --- Type ------------------------------------------------------------------ */

h1,
h2,
#content h1,
#content h2 {
  font-family: var(--qs-serif);
  font-weight: 400;
  letter-spacing: 0.01em;
}

#content h1 {
  font-size: 1.6rem;
  color: var(--qs-ink);
}

/* --- Modules / app cards --------------------------------------------------- */

.module {
  background: var(--qs-card);
  border: 1px solid var(--qs-hairline);
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(36, 24, 9, 0.05);
  overflow: hidden;
}

.module h2,
.module caption,
.inline-group h2 {
  background: var(--qs-card);
  color: var(--qs-ink);
  font-family: var(--qs-serif);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--qs-hairline);
  padding: 12px 14px;
}

.module caption a.section,
.module caption a.section:link,
.module caption a.section:visited {
  color: var(--qs-ink);
}

.module caption a.section:hover {
  color: var(--qs-berbere);
}

#content-related .module h2 {
  background: var(--qs-card);
}

/* --- Buttons --------------------------------------------------------------- */

.button,
input[type='submit'],
input[type='button'],
.submit-row input,
a.button {
  border-radius: 2px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 10px 16px;
}

.button.default,
input[type='submit'].default,
.submit-row input.default {
  background: var(--qs-berbere);
}

.button.default:hover,
input[type='submit'].default:hover {
  background: var(--qs-berbere-deep);
}

.object-tools a:link,
.object-tools a:visited {
  border-radius: 2px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}

/* --- Changelist ------------------------------------------------------------ */

#changelist-filter {
  background: var(--qs-card);
  border: 1px solid var(--qs-hairline);
  border-radius: 3px;
}

#changelist-filter h2 {
  background: var(--qs-espresso);
  color: #f5ecdc;
  letter-spacing: 0.08em;
}

#changelist-filter li.selected a {
  color: var(--qs-berbere);
  border-left: 3px solid var(--qs-berbere);
  margin-left: -8px;
  padding-left: 5px;
}

thead th {
  background: var(--qs-espresso);
  color: #e8dcc6;
}

thead th a:link,
thead th a:visited {
  color: #f5ecdc;
}

thead th.sorted {
  background: var(--qs-espresso-2);
}

tbody tr:nth-child(odd) {
  background: color-mix(in srgb, var(--qs-paper) 45%, var(--qs-card));
}

tbody tr:hover {
  background: var(--selected-row);
}

.paginator {
  border-top: 1px solid var(--qs-hairline);
}

.paginator a:link,
.paginator a:visited {
  background: var(--qs-espresso-2);
  border-radius: 2px;
}

.paginator a:hover {
  background: var(--qs-berbere);
}

.paginator .this-page {
  color: var(--qs-berbere);
}

/* --- Forms ----------------------------------------------------------------- */

input[type='text'],
input[type='password'],
input[type='email'],
input[type='url'],
input[type='number'],
input[type='tel'],
textarea,
select,
.vTextField {
  background: #fffef9;
  border: 1px solid #cfc0a4;
  border-radius: 2px;
  color: var(--qs-ink);
  padding: 8px 10px;
}

input[type='text']:focus,
input[type='password']:focus,
input[type='email']:focus,
input[type='url']:focus,
input[type='number']:focus,
input[type='tel']:focus,
textarea:focus,
select:focus,
.vTextField:focus {
  border-color: var(--qs-honey-deep);
  outline: 2px solid color-mix(in srgb, var(--qs-honey) 45%, transparent);
  outline-offset: 0;
}

.aligned label {
  color: var(--qs-quiet);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}

fieldset.module h2 {
  background: var(--qs-espresso);
  color: #f5ecdc;
}

.submit-row {
  background: var(--qs-card);
  border: 1px solid var(--qs-hairline);
  border-radius: 3px;
}

/* --- Messages / breadcrumbs ------------------------------------------------ */

.messagelist li {
  border-radius: 3px;
  border: 1px solid var(--qs-hairline);
}

div.breadcrumbs {
  padding: 14px 40px;
  border-bottom: 1px solid var(--qs-hairline);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* --- Dashboard ------------------------------------------------------------- */

.qs-welcome {
  margin: 4px 0 22px;
}

.qs-welcome h1 {
  font-family: var(--qs-serif);
  font-size: 1.7rem;
  margin: 0 0 4px;
}

.qs-welcome p {
  color: var(--qs-quiet);
  margin: 0;
  font-size: 0.85rem;
}

.qs-quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
}

.qs-quick-actions li {
  list-style: none;
}

.qs-quick-actions a {
  display: block;
  background: var(--qs-card);
  border: 1px solid var(--qs-hairline);
  border-top: 3px solid var(--qs-honey);
  border-radius: 3px;
  padding: 14px 16px;
  color: var(--qs-ink);
  transition:
    border-color 0.15s ease,
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.qs-quick-actions a:hover {
  border-top-color: var(--qs-berbere);
  box-shadow: 0 6px 16px -8px rgba(36, 24, 9, 0.35);
  transform: translateY(-1px);
  color: var(--qs-ink);
}

.qs-quick-actions .qs-action-title {
  display: block;
  font-family: var(--qs-serif);
  font-size: 1rem;
  margin-bottom: 2px;
}

.qs-quick-actions .qs-action-hint {
  display: block;
  color: var(--qs-quiet);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.dashboard #content {
  width: auto;
  max-width: 1100px;
}

.dashboard .module table th {
  width: 100%;
}

/* --- Login ----------------------------------------------------------------- */
/* The one place the admin borrows the dining room's darkness: an espresso
   backdrop with the concentric mesob rings, and the parchment card floating
   on it. */

body.login {
  background:
    repeating-radial-gradient(
      circle at 85% 20%,
      transparent 0,
      transparent 34px,
      rgba(224, 169, 79, 0.1) 34px,
      rgba(224, 169, 79, 0.1) 35px
    ),
    var(--qs-espresso);
}

body.login #header {
  background: transparent;
  border-bottom: 0;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding-top: 48px;
}

body.login #container {
  background: transparent;
  border: 0;
}

body.login #site-name {
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

body.login #site-name a {
  flex-direction: column;
  gap: 14px;
}

body.login .qs-logo {
  width: 84px;
  height: 84px;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--qs-honey) 45%, transparent),
    0 18px 44px -18px rgba(0, 0, 0, 0.8);
}

body.login #content-main {
  box-sizing: border-box;
  width: 100%;
  background: var(--qs-card);
  border: 1px solid rgba(224, 169, 79, 0.35);
  border-top: 3px solid var(--qs-honey);
  border-radius: 3px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.7);
  padding: 28px;
}

body.login #content-main form input[type='text'],
body.login #content-main form input[type='password'] {
  box-sizing: border-box;
  width: 100%;
}

body.login .submit-row {
  border: 0;
  background: transparent;
  padding: 0;
}

body.login .submit-row input {
  width: 100%;
  background: var(--qs-berbere);
}

body.login .submit-row input:hover {
  background: var(--qs-berbere-deep);
}

@media (prefers-reduced-motion: reduce) {
  .qs-quick-actions a,
  .qs-quick-actions a:hover {
    transition: none;
    transform: none;
  }
}
