/* ────────────────────────────────────────────────────────────
   Django admin в дизайн-системе Medicine.
   Та же палитра и типографика, что в пациентском приложении и
   Coordinator CRM (styles.css прототипа): тёплый sand-white фон,
   sage-акцент, Newsreader для бренда, Manrope для текста.
   Админка — часть экосистемы, а не служебный чужак.
   ──────────────────────────────────────────────────────────── */

@import url("../crm/fonts.css");

/* Палитра светлая всегда: тёмной темы у экосистемы нет. */
:root,
html[data-theme="light"],
html[data-theme="dark"],
html[data-theme="auto"] {
  color-scheme: light;

  --primary: #5e7459;                /* sage */
  --secondary: #45413a;              /* ink-2: шапки модулей */
  --accent: #b89465;                 /* sand */
  --primary-fg: #ffffff;

  --body-fg: #1f1d18;                /* ink */
  --body-bg: #f5f1e8;                /* warm sand-white */
  --body-quiet-color: #807a6e;       /* ink-muted */
  --body-medium-color: #45413a;
  --body-loud-color: #1f1d18;

  --header-color: #807a6e;
  --header-branding-color: #1f1d18;
  --header-bg: #fbf8f1;              /* surface, как топбар CRM */
  --header-link-color: #2e3a2c;

  --breadcrumbs-fg: #807a6e;
  --breadcrumbs-link-fg: #2e3a2c;
  --breadcrumbs-bg: transparent;

  --link-fg: #2e3a2c;                /* accent-ink */
  --link-hover-color: #5e7459;
  --link-selected-fg: #5e7459;

  --hairline-color: #e6dfcf;         /* divider */
  --border-color: #d8cfba;           /* divider-2 */

  --error-fg: #a85a4a;               /* safety-кирпич, не алый */

  --message-success-bg: #e3eadc;     /* st-calm-soft */
  --message-warning-bg: #f1e7d1;     /* st-attn-soft */
  --message-error-bg: #f1e2dc;       /* st-act-soft */

  --darkened-bg: #f1ede2;            /* мягче bg-alt: зебра, не полосы */
  --selected-bg: #e3eadc;
  --selected-row: #f1e7d1;

  /* Кнопки: обычные — sage; главная (Сохранить) — ink, как btn-primary CRM. */
  --button-fg: #ffffff;
  --button-bg: #5e7459;
  --button-hover-bg: #4c5f48;
  --default-button-bg: #1f1d18;
  --default-button-hover-bg: #45413a;
  --close-button-bg: #807a6e;
  --close-button-hover-bg: #45413a;
  --delete-button-bg: #a85a4a;
  --delete-button-hover-bg: #8c4436;

  --object-tools-fg: #ffffff;
  --object-tools-bg: #807a6e;
  --object-tools-hover-bg: #45413a;

  --font-family-primary: "Manrope", -apple-system, system-ui, "Segoe UI", sans-serif;
  --font-family-monospace: ui-monospace, "SF Mono", Menlo, monospace;
}

/* Переключатель темы прячем: тема одна. */
#header button.theme-toggle { display: none; }

/* ── Шапка: crest как в CRM ─────────────────────────────────── */
#header {
  border-bottom: 0.5px solid var(--border-color);
  padding: 12px 28px;
}
#site-name {
  font-family: "Newsreader", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 23px;
  letter-spacing: -0.02em;
}
#site-name a:link, #site-name a:visited { color: var(--header-branding-color); }
#branding .crest-sub {
  display: block;
  font-family: var(--font-family-primary);
  font-style: normal;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--body-quiet-color);
  font-weight: 600;
  margin-top: 3px;
}

/* ── Модули как карточки CRM ────────────────────────────────── */
.module {
  border: none;
  border-radius: 14px;
  overflow: hidden;
  background: #fbf8f1;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset,
              0 1px 2px rgba(31, 29, 24, 0.04),
              0 6px 16px rgba(31, 29, 24, 0.05);
  margin-bottom: 18px;
}
.module h2, .module caption, .inline-group h2 {
  background: transparent;
  color: var(--body-quiet-color);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;   /* eyebrow, как в CRM */
  padding: 12px 14px 6px;
}
.module caption a.section:link, .module caption a.section:visited {
  color: var(--body-quiet-color);
}

/* ── Таблицы: плотные строки DataTable ──────────────────────── */
thead th {
  background: transparent;
  color: #b3ac9f;                    /* ink-faint */
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-bottom: 0.5px solid var(--border-color);
}
thead th a:link, thead th a:visited { color: inherit; }
td, th { border-bottom: 0.5px solid var(--hairline-color); }
#changelist table tbody tr:hover { background: #fbf8f1; }
.row1 { background: transparent; }
.row2 { background: rgba(31, 29, 24, 0.015); }

/* ── Формы ──────────────────────────────────────────────────── */
input[type="text"], input[type="password"], input[type="email"],
input[type="url"], input[type="number"], input[type="tel"],
textarea, select, .vTextField {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #fbf8f1;
  padding: 7px 10px;
}
input:focus, textarea:focus, select:focus, .vTextField:focus {
  border-color: var(--primary);
  outline: 1px solid var(--primary);
}
.aligned label { color: var(--body-medium-color); font-weight: 600; }
.help, .help div { color: var(--body-quiet-color); }
fieldset.module { padding: 6px 14px 14px; }

/* ── Кнопки: радиусы и «tap» CRM ────────────────────────────── */
.button, input[type="submit"], input[type="button"],
.submit-row input, a.button {
  border-radius: 10px;
  font-weight: 600;
  padding: 9px 15px;
  transition: transform 0.12s ease, background 0.12s ease;
}
.button:active, input[type="submit"]:active { transform: scale(0.985); }
.submit-row {
  background: transparent;
  border: none;
  padding: 12px 0;
}
.submit-row a.deletelink {
  border-radius: 10px;
  background: var(--delete-button-bg);
}
.object-tools a { border-radius: 999px; font-weight: 600; }

/* ── Навигация и фильтры ────────────────────────────────────── */
#nav-sidebar {
  background: #ebe5d6;               /* bg-alt, как sidebar CRM */
  border-right: 0.5px solid var(--border-color);
}
#nav-sidebar .current-app .section:link, #nav-sidebar .current-app .section:visited,
.main > #nav-sidebar + .content { background: transparent; }
#nav-filter {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #fbf8f1;
}
#changelist-filter {
  background: #fbf8f1;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(31, 29, 24, 0.04);
}
#changelist-filter h2 {
  background: transparent;
  color: var(--body-quiet-color);
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.13em;
}
#changelist-filter li.selected a { color: var(--primary); }

#changelist #toolbar {
  background: transparent;
  border: none;
  padding: 8px 0;
}
#changelist #searchbar {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #fbf8f1;
  padding: 7px 10px;
}
.paginator { border: none; background: transparent; }
.paginator a:link, .paginator a:visited {
  border-radius: 8px;
  background: #fbf8f1;
  border: 0.5px solid var(--border-color);
  color: var(--link-fg);
}
.paginator .this-page {
  background: var(--secondary);
  color: #f5f1e8;
  border-radius: 8px;
  padding: 4px 8px;
}

/* ── Сообщения ──────────────────────────────────────────────── */
ul.messagelist li {
  border-radius: 12px;
  color: #2e3a2c;
  background: var(--message-success-bg);
  box-shadow: none;
  font-weight: 500;
}
ul.messagelist li.warning { background: var(--message-warning-bg); color: #5c4717; }
ul.messagelist li.error { background: var(--message-error-bg); color: #6e3024; }

/* ── Логин ──────────────────────────────────────────────────── */
.login #container {
  background: #fbf8f1;
  border: none;
  border-radius: 22px;
  box-shadow: 0 1px 2px rgba(31, 29, 24, 0.04), 0 14px 34px rgba(31, 29, 24, 0.08);
  padding: 28px;
}
.login #header { background: transparent; border: none; text-align: center; }
.login .submit-row input { width: 100%; }

/* Боковые модули («Последние действия») и фильтр: те же eyebrow-заголовки,
   что и у карточек — admin задаёт им свой крупный размер более специфичным
   селектором, возвращаем масштаб экосистемы. */
#content-related .module h2, #content-related .module h3,
#changelist-filter h2, #changelist-filter h3,
#changelist-filter details summary {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--body-quiet-color);
  background: transparent;
}
#content-related .module { background: #fbf8f1; }
#content-related .module h3 { padding: 10px 14px 4px; }
#changelist-filter details summary { padding: 8px 14px 4px; cursor: pointer; }
#changelist-filter li { line-height: 1.55; }
#recent-actions-module h2 { padding-top: 12px; }

/* Дашборд: карточки приложений в сетке чуть просторнее. */
.dashboard .module table th, .dashboard .module table td { padding: 9px 14px; }
.dashboard .module table a { font-weight: 600; }
