/**
 * Pflegedienst Mira — Wagtail admin brand skin.
 *
 * Critical: never paint light surfaces on bare :root. That fights
 * .w-theme-dark text tokens (light ink) and washes out the whole UI.
 * Tint hue only; keep Wagtail lightness so primary-based labels stay dark.
 */

:root,
.w-theme-light,
.w-theme-dark,
.w-theme-system {
  --w-color-primary-hue: 100;
  --w-color-secondary-hue: 100;
  --w-font-sans: "Poppins", "Segoe UI", system-ui, sans-serif;
}

/* ── Light theme only (not :root — that breaks dark mode contrast) ─ */
html.w-theme-light,
.w-theme-light {
  --w-color-surface-page: #f8faf6;
  --w-color-surface-field: #ffffff;
  --w-color-surface-field-inactive: #f1f4ee;
  --w-color-surface-header: #ffffff;
  --w-color-surface-menus: #2f5f1a;
  --w-color-surface-menu-item-active: #3d7a22;
  --w-color-surface-dashboard-panel: #ffffff;

  --w-color-text-context: #121812;
  --w-color-text-label: #121812;
  --w-color-text-meta: #2a3328;
  --w-color-text-placeholder: #4a5548;
  --w-color-text-link-default: #2f5f1a;
  --w-color-text-link-hover: #1e3d12;
  --w-color-text-label-menus-default: rgba(255, 255, 255, 0.95);
  --w-color-text-label-menus-active: #ffffff;

  --w-color-icon-primary: #121812;
  --w-color-icon-primary-hover: #1e3d12;
  --w-color-icon-secondary: #2a3328;
  --w-color-icon-secondary-hover: #121812;

  --w-color-border-field-default: #6b7568;
  --w-color-border-field-hover: #2f5f1a;
  --w-color-border-furniture: #c5cec0;
  --w-color-focus: #2f5f1a;
}

@media (prefers-color-scheme: light) {
  html.w-theme-system,
  .w-theme-system {
    --w-color-surface-page: #f8faf6;
    --w-color-surface-field: #ffffff;
    --w-color-surface-field-inactive: #f1f4ee;
    --w-color-surface-header: #ffffff;
    --w-color-surface-menus: #2f5f1a;
    --w-color-surface-menu-item-active: #3d7a22;
    --w-color-surface-dashboard-panel: #ffffff;

    --w-color-text-context: #121812;
    --w-color-text-label: #121812;
    --w-color-text-meta: #2a3328;
    --w-color-text-placeholder: #4a5548;
    --w-color-text-link-default: #2f5f1a;
    --w-color-text-link-hover: #1e3d12;
    --w-color-text-label-menus-default: rgba(255, 255, 255, 0.95);
    --w-color-text-label-menus-active: #ffffff;

    --w-color-icon-primary: #121812;
    --w-color-icon-primary-hover: #1e3d12;
    --w-color-icon-secondary: #2a3328;
    --w-color-icon-secondary-hover: #121812;

    --w-color-border-field-default: #6b7568;
    --w-color-border-field-hover: #2f5f1a;
    --w-color-border-furniture: #c5cec0;
    --w-color-focus: #2f5f1a;
  }
}

/* Element-level guarantees on light / system-light surfaces */
html.w-theme-light .w-field__label,
html.w-theme-light .w-panel__heading,
html.w-theme-light h1,
html.w-theme-light h2,
html.w-theme-light .title,
html.w-theme-light .w-header__title,
html.w-theme-light .w-page-header__title,
html.w-theme-light label {
  color: #121812 !important;
}

/* Sidebar sits on forest green — never inherit main-panel dark ink */
html.w-theme-light #wagtail-sidebar input,
html.w-theme-light #wagtail-sidebar textarea,
html.w-theme-light #wagtail-sidebar select,
html.w-theme-light [data-wagtail-sidebar] input,
html.w-theme-light [data-wagtail-sidebar] textarea,
html.w-theme-light .sidebar input,
html.w-theme-light .sidebar textarea,
html.w-theme-dark #wagtail-sidebar input,
html.w-theme-dark [data-wagtail-sidebar] input,
html.w-theme-system #wagtail-sidebar input,
html.w-theme-system [data-wagtail-sidebar] input,
html.w-theme-system .sidebar input {
  color: #ffffff !important;
  caret-color: #ffffff;
  -webkit-text-fill-color: #ffffff;
}

html.w-theme-light #wagtail-sidebar input::placeholder,
html.w-theme-light [data-wagtail-sidebar] input::placeholder,
html.w-theme-light .sidebar input::placeholder,
html.w-theme-dark #wagtail-sidebar input::placeholder,
html.w-theme-system #wagtail-sidebar input::placeholder,
html.w-theme-system [data-wagtail-sidebar] input::placeholder,
html.w-theme-system .sidebar input::placeholder {
  color: rgba(255, 255, 255, 0.72) !important;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.72);
  opacity: 1;
}

html.w-theme-light .w-field__help,
html.w-theme-light .help,
html.w-theme-light .w-human-readable-date,
html.w-theme-light .w-help-text {
  color: #2a3328 !important;
}

html.w-theme-light .content-wrapper input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
html.w-theme-light .content-wrapper textarea,
html.w-theme-light .content-wrapper select,
html.w-theme-light .content-wrapper .w-field__input,
html.w-theme-light .content-wrapper .w-field__input input,
html.w-theme-light .content-wrapper .w-field__input textarea,
html.w-theme-light .content-wrapper .w-field__input select,
html.w-theme-light .content-wrapper .listing td,
html.w-theme-light .content-wrapper .listing th,
html.w-theme-light .content-wrapper table td,
html.w-theme-light .content-wrapper table th,
html.w-theme-light .content-wrapper .w-field__input .w-field__text-input {
  color: #121812 !important;
}

html.w-theme-light .content-wrapper input::placeholder,
html.w-theme-light .content-wrapper textarea::placeholder {
  color: #4a5548 !important;
  opacity: 1;
}

@media (prefers-color-scheme: light) {
  html.w-theme-system .w-field__label,
  html.w-theme-system .w-panel__heading,
  html.w-theme-system h1,
  html.w-theme-system h2,
  html.w-theme-system .title,
  html.w-theme-system .w-header__title,
  html.w-theme-system .w-page-header__title,
  html.w-theme-system label {
    color: #121812 !important;
  }

  html.w-theme-system .w-field__help,
  html.w-theme-system .help,
  html.w-theme-system .w-human-readable-date,
  html.w-theme-system .w-help-text {
    color: #2a3328 !important;
  }

  html.w-theme-system .content-wrapper input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
  html.w-theme-system .content-wrapper textarea,
  html.w-theme-system .content-wrapper select,
  html.w-theme-system .content-wrapper .w-field__input,
  html.w-theme-system .content-wrapper .w-field__input input,
  html.w-theme-system .content-wrapper .w-field__input textarea,
  html.w-theme-system .content-wrapper .w-field__input select,
  html.w-theme-system .content-wrapper .listing td,
  html.w-theme-system .content-wrapper .listing th,
  html.w-theme-system .content-wrapper table td,
  html.w-theme-system .content-wrapper table th {
    color: #121812 !important;
  }

  html.w-theme-system .content-wrapper input::placeholder,
  html.w-theme-system .content-wrapper textarea::placeholder {
    color: #4a5548 !important;
    opacity: 1;
  }
}

/* ── Dark: green sidebar / links only; keep Wagtail dark ink ───── */
html.w-theme-dark,
.w-theme-dark {
  --w-color-surface-menus: #1e3d12;
  --w-color-surface-menu-item-active: #2f5f1a;
  --w-color-text-link-default: #9ae06a;
  --w-color-text-link-hover: #c0f09a;
  --w-color-focus: #9ae06a;
}

@media (prefers-color-scheme: dark) {
  html.w-theme-system,
  .w-theme-system {
    --w-color-surface-menus: #1e3d12;
    --w-color-surface-menu-item-active: #2f5f1a;
    --w-color-text-link-default: #9ae06a;
    --w-color-text-link-hover: #c0f09a;
    --w-color-focus: #9ae06a;
  }
}

/* ── Sidebar brand: mark + wordmark (same as public site) ─────── */
.sidebar-custom-branding .mira-admin-brand,
.mira-admin-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 0.45rem 0.4rem;
  text-decoration: none;
}

.mira-admin-brand__logo {
  display: block;
  width: 2.75rem;
  height: auto;
  object-fit: contain;
}

.mira-admin-brand__wordmark {
  display: block;
  width: 5.5rem;
  max-width: 90%;
  height: auto;
  object-fit: contain;
}

.mira-admin-brand__logo--userbar {
  width: 2.25rem;
  max-width: none;
}

/* Account-menu theme items (open Svetozar ▾) */
#wagtail-sidebar .mira-theme-menu-item.is-active,
#wagtail-sidebar .mira-theme-menu-item.is-active .sidebar-menu-item__link {
  font-weight: 700;
  color: #ffffff !important;
}

/* Sidebar labels/icons must stay light on forest green */
#wagtail-sidebar .sidebar-menu-item__link,
#wagtail-sidebar .sidebar-footer__account-label,
#wagtail-sidebar .sidebar-footer__account,
#wagtail-sidebar .w-label-3 {
  color: rgba(255, 255, 255, 0.95) !important;
}

/* Field rows: top-align so short labels don’t float above neighbors */
.w-field-row {
  align-items: flex-start;
}

.mira-admin-logo--login {
  display: block;
  width: 160px;
  max-width: 70%;
  height: auto;
  margin: 1.5rem auto 0;
  background: #f8faf6;
  border-radius: 16px;
  padding: 0.75rem 1rem;
  box-shadow: 0 8px 24px rgba(20, 40, 10, 0.1);
}

body.login {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(84, 169, 43, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(68, 138, 34, 0.14), transparent 50%),
    #f8faf6 !important;
}

body.login .content-wrapper {
  background: #fff;
  border: 1px solid #c5cec0;
  border-radius: 16px;
  box-shadow: 0 14px 36px rgba(20, 40, 10, 0.1);
}

body.login h1,
body.login label,
body.login .w-field__label,
body.login input,
body.login .help {
  color: #121812 !important;
}

.button.button-primary,
a.button.button-primary,
button.button-primary {
  background-color: #2f5f1a;
  border-color: #2f5f1a;
  color: #fff !important;
}

.button.button-primary:hover,
a.button.button-primary:hover,
button.button-primary:hover {
  background-color: #1e3d12;
  border-color: #1e3d12;
  color: #fff !important;
}
