
/*
 * RICH HOUSE ERP
 * Premium Emerald & Gold Theme
 * Исправленная версия с контрастным боковым меню
 */

:root,
html[data-theme="light"],
html[data-theme="dark"] {
    color-scheme: light;

    --primary: var(--rh-primary, #174c38);
    --secondary: var(--rh-primary, #245c45);
    --accent: var(--rh-gold, #c7a263);
    --primary-fg: var(--rh-surface, #ffffff);

    --body-bg: var(--rh-background, #f8f7f3);
    --body-fg: var(--rh-text, #273c32);
    --body-quiet-color: var(--rh-text-muted, #6b7b70);
    --body-medium-color: var(--rh-text-muted, #456052);

    --header-bg: var(--rh-primary-hover, #12392b);
    --header-color: var(--rh-gold-soft, #f6e6c4);
    --header-branding-color: var(--rh-gold-soft, #e8cc8d);
    --header-link-color: var(--rh-cream, #fff9e9);

    --breadcrumbs-bg: var(--rh-primary, #215641);
    --breadcrumbs-fg: var(--rh-surface, #ffffff);
    --breadcrumbs-link-fg: var(--rh-gold-soft, #f1d8a5);

    --link-fg: var(--rh-primary, #20583f);
    --link-hover-color: var(--rh-gold, #a57b39);
    --link-selected-fg: var(--rh-primary-hover, #123d2d);

    --button-bg: var(--rh-primary, #245c45);
    --button-hover-bg: var(--rh-primary-hover, #153d2e);
    --default-button-bg: var(--rh-primary, #174c38);
    --default-button-hover-bg: var(--rh-primary, #286c4e);

    --hairline-color: var(--rh-border, #e3e8e0);
    --border-color: var(--rh-border, #dce4db);
    --selected-bg: var(--rh-surface-muted, #edf3e9);
    --selected-row: var(--rh-surface-muted, #f0f5ed);
    --darkened-bg: var(--rh-surface-muted, #edf1e9);

    --object-tools-bg: var(--rh-primary, #245c45);
    --object-tools-hover-bg: var(--rh-primary-hover, #153d2e);
    --rh-shadow: 0 5px 20px rgba(20, 55, 40, 0.07);
}

/* Палитра берётся из static/design/themes/emerald.css.
   Файл темы подключается раньше этого файла; резервные цвета оставлены для надёжности. */

/* Основная типографика */

body,
input,
select,
textarea,
button {
    font-family: "Segoe UI", "Trebuchet MS", Arial, sans-serif;
}

body {
    background: var(--rh-background, #f8f7f3);
    color: var(--rh-text, #273c32);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    letter-spacing: 0.1px;
}

#content h1 {
    color: var(--rh-primary, #244b39);
    font-weight: 600;
}

/* Верхняя панель */

#header {
    background: linear-gradient(
        115deg,
        var(--rh-primary-hover, #102e25) 0%,
        var(--rh-primary, #174735) 48%,
        var(--rh-primary, #28644a) 100%
    );
    border-bottom: 2px solid var(--rh-gold);
    box-shadow: 0 4px 16px rgba(14, 43, 31, 0.12);
    padding-top: 17px;
    padding-bottom: 17px;
}

#site-name,
#site-name a {
    font-family: Georgia, "Palatino Linotype", serif;
    font-size: 23px;
    font-weight: 700;
    letter-spacing: 1.3px;
    color: var(--rh-gold-soft, var(--rh-gold-soft, #efd9a4)) !important;
    text-decoration: none;
}

#site-name a:hover {
    color: var(--rh-surface, #ffffff) !important;
}

#user-tools,
#user-tools a {
    color: var(--rh-cream, #f8f1dd);
}

/* Навигационная строка */

div.breadcrumbs {
    background: linear-gradient(
        90deg,
        var(--rh-primary-hover, #1a4936),
        var(--rh-primary, #2a644a)
    );
    color: var(--rh-surface, #ffffff);
    border-bottom: 1px solid var(--rh-gold, #d5b678);
}

div.breadcrumbs a {
    color: var(--rh-gold-soft, #f6e5b9);
}

/* Карточки и блоки */

.module {
    background: var(--rh-surface, #ffffff);
    border: 1px solid var(--rh-border, #e0e7de);
    border-radius: 13px;
    overflow: hidden;
    box-shadow: var(--rh-shadow);
}

.module h2,
.module caption,
.inline-group h2 {
    background: linear-gradient(
        105deg,
        var(--rh-primary-hover, #164532) 0%,
        var(--rh-primary, #245f46) 72%,
        var(--rh-primary, #347657) 100%
    );
    color: var(--rh-cream, #fff7e8);
    font-weight: 600;
    padding-top: 11px;
    padding-bottom: 11px;
}

.dashboard .module {
    margin-bottom: 25px;
}

.dashboard #content-related .module {
    background: var(--rh-surface-muted, #f1f4ec);
}

/* Таблицы */

table {
    border-collapse: separate;
    border-spacing: 0;
}

thead th {
    background: var(--rh-surface-muted, #edf2e9);
    color: var(--rh-primary, #244a38);
}

tbody tr {
    transition: background-color 0.15s ease;
}

tbody tr:hover {
    background: var(--rh-surface-muted, #f1f6ee);
}

#changelist table thead th {
    background: linear-gradient(
        180deg,
        var(--rh-surface-muted, #f0f4ec),
        var(--rh-surface-muted, #e7eee5)
    );
    color: var(--rh-primary, #244a38);
}

#changelist table tbody tr:hover {
    background: var(--rh-surface-muted, #f1f6ed);
}

/*
 * БОКОВОЕ МЕНЮ
 * Контрастные цвета для всех пунктов
 */

#nav-sidebar {
    background: var(--rh-surface-muted, #f3f5ef);
    border-right: 1px solid var(--rh-border, #e0e6dc);
}

#nav-sidebar .module {
    background: var(--rh-surface, #ffffff);
    border: 1px solid var(--rh-border, #dfe7dc);
    border-radius: 10px;
    box-shadow: none;
    overflow: hidden;
}

/* Заголовки групп */

#nav-sidebar .module caption {
    background: linear-gradient(
        100deg,
        var(--rh-primary-hover, #164532),
        var(--rh-primary, #28664a)
    );
    color: var(--rh-cream, #fff4d8);
    font-weight: 700;
}

/* Ссылки в заголовках */

#nav-sidebar .module caption a,
#nav-sidebar .module caption a:link,
#nav-sidebar .module caption a:visited,
#nav-sidebar .module caption a:hover {
    color: var(--rh-cream, #fff4d8) !important;
    font-weight: 700;
    text-decoration: none;
}

/* Строки моделей */

#nav-sidebar .module tbody tr,
#nav-sidebar .module tbody th,
#nav-sidebar .module tbody td {
    background: var(--rh-surface, #ffffff) !important;
    color: var(--rh-primary, #244b38) !important;
}

/* Чередование строк */

#nav-sidebar .module tbody tr:nth-child(even) th,
#nav-sidebar .module tbody tr:nth-child(even) td {
    background: var(--rh-surface-muted, #f0f4ed) !important;
}

/* Названия моделей и ссылки */

#nav-sidebar .module tbody a,
#nav-sidebar .module tbody a:link,
#nav-sidebar .module tbody a:visited,
#nav-sidebar .module tbody th a,
#nav-sidebar .module tbody td a {
    color: var(--rh-primary, #20543c) !important;
    font-weight: 600;
    opacity: 1 !important;
}

/* Наведение мыши */

#nav-sidebar .module tbody tr:hover th,
#nav-sidebar .module tbody tr:hover td {
    background: var(--rh-surface-muted, #e8f0e6) !important;
}

#nav-sidebar .module tbody a:hover {
    color: var(--rh-gold, #92672b) !important;
}

/* Текущий раздел */

#nav-sidebar .module tbody tr.current-model th,
#nav-sidebar .module tbody tr.current-model td {
    background: var(--rh-active-background, #f3e9d1) !important;
}

#nav-sidebar .module tbody tr.current-model a {
    color: #153d2d !important;
    font-weight: 700;
}

/* Поле поиска по боковому меню */

#nav-filter {
    border-radius: 9px;
    background: var(--rh-surface, #ffffff);
    color: var(--rh-primary, #244b38);
    border: 1px solid var(--rh-border, #d9e3d7);
}

/* Кнопки */

.button,
input[type="submit"],
input[type="button"],
button,
a.button {
    border-radius: 9px;
    transition:
        background-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
}

.button:hover,
input[type="submit"]:hover,
a.button:hover {
    box-shadow: 0 3px 10px rgba(23, 76, 56, 0.15);
}

input.default,
.submit-row input.default {
    background: linear-gradient(
        110deg,
        var(--rh-primary-hover, #164532),
        var(--rh-primary, #28684c)
    );
    color: var(--rh-surface, #ffffff);
}

.object-tools a {
    border-radius: 9px;
    background: linear-gradient(
        110deg,
        var(--rh-primary, #174735),
        var(--rh-primary, #2a684d)
    );
}

.object-tools a:hover {
    background: var(--rh-primary-hover, #103d2b);
}

/* Поля ввода */

input[type="text"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
select,
textarea {
    border: 1px solid var(--rh-border, #d5dfd4);
    border-radius: 9px;
    background: var(--rh-surface, #ffffff);
    padding: 8px 10px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--rh-gold, #b99759);
    box-shadow: 0 0 0 3px rgba(199, 162, 99, 0.12);
}

/* Панели редактирования */

fieldset.module {
    border-radius: 13px;
    margin-bottom: 20px;
}

.submit-row {
    background: var(--rh-surface-muted, #f0f3ed);
    border: 1px solid var(--rh-border, #e0e6db);
    border-radius: 11px;
}

/* Уведомления */

.messagelist li {
    border-radius: 9px;
    margin-bottom: 10px;
}

/* Доступность */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--rh-gold, #c7a263);
    outline-offset: 2px;
}

/* Телефоны */

@media (max-width: 767px) {
    #header {
        padding-top: 12px;
        padding-bottom: 12px;
    }

    #site-name,
    #site-name a {
        font-size: 19px;
        letter-spacing: 0.5px;
    }

    .module {
        border-radius: 10px;
    }
}

/* Отключение анимации по системной настройке */

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