/* Тёмная тема сайта: общее для всех страниц (элементы форм, разделители, таблицы).
   Палитра — css/theme.css; страничные правила — css/dark/<имя таблицы>.css.
   Исключения типов полей стоят в :where(), чтобы общее правило оставалось слабее страничных. */

/* Светлые цвета, заданные прямо в атрибуте style (в PHP-разметке): без !important их не перебить */
html[data-theme="dark"] [style*="background-color: #f8f9fa"],
html[data-theme="dark"] [style*="background-color:#f8f9fa"],
html[data-theme="dark"] [style*="background: #f8f9fa"],
html[data-theme="dark"] [style*="background:#f8f9fa"],
html[data-theme="dark"] [style*="background: #f5f5f5"],
html[data-theme="dark"] [style*="background:#f5f5f5"],
html[data-theme="dark"] [style*="background: #f9f9f9"],
html[data-theme="dark"] [style*="background:#f9f9f9"],
html[data-theme="dark"] [style*="background: #e3f2fd"],
html[data-theme="dark"] [style*="background:#e3f2fd"] {
    background-color: var(--c-surface-2) !important;
    color: var(--c-text);
}

html[data-theme="dark"] [style*="color: #666"],
html[data-theme="dark"] [style*="color:#666"],
html[data-theme="dark"] [style*="color: #888"],
html[data-theme="dark"] [style*="color:#888"],
html[data-theme="dark"] [style*="color: #999"],
html[data-theme="dark"] [style*="color:#999"],
html[data-theme="dark"] [style*="color: #555"],
html[data-theme="dark"] [style*="color:#555"],
html[data-theme="dark"] [style*="color: #6c757d"],
html[data-theme="dark"] [style*="color:#6c757d"],
html[data-theme="dark"] [style*="color: #94a3b8"],
html[data-theme="dark"] [style*="color:#94a3b8"],
html[data-theme="dark"] [style*="color: #64748b"],
html[data-theme="dark"] [style*="color:#64748b"],
html[data-theme="dark"] [style*="color: #aaa"],
html[data-theme="dark"] [style*="color:#aaa"] {
    color: var(--c-muted) !important;
}

html[data-theme="dark"] [style*="color: #334155"],
html[data-theme="dark"] [style*="color:#334155"],
html[data-theme="dark"] [style*="color: #1e293b"],
html[data-theme="dark"] [style*="color:#1e293b"] {
    color: var(--c-text) !important;
}

/* Окна, которые строит JS (стили вставляются скриптом): блокировка второй вкладки комнаты,
   подтверждения на странице профиля */
html[data-theme="dark"] .tab-lock-dialog {
    background: var(--c-surface);
    color: var(--c-text);
    border: 1px solid var(--c-border);
}

html[data-theme="dark"] .tab-lock-dialog p {
    color: var(--c-muted);
}

html[data-theme="dark"] .tab-lock-buttons button {
    background: var(--c-surface-2);
    border-color: var(--c-border);
    color: var(--c-text);
}

html[data-theme="dark"] .tab-lock-buttons .tab-lock-btn-takeover {
    background: #c0392b;
    border-color: #c0392b;
    color: #fff;
}

html[data-theme="dark"] [style*="background:#fff;border-radius:10px;padding:24px"] {
    background: var(--c-surface) !important;
    color: var(--c-text);
}

/* Страницы без nicepage-обёртки (без .u-body): фон и текст из палитры */
html[data-theme="dark"] body:not(.u-body) {
    background: var(--c-bg);
    color: var(--c-text);
}

html[data-theme="dark"] input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="button"], [type="submit"], [type="file"], [type="hidden"], [type="image"])),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background-color: var(--c-surface-2);
    color: var(--c-text);
    border-color: var(--c-border);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: var(--c-muted);
    opacity: 1;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
    border-color: var(--c-accent-text);
    outline-color: var(--c-accent-text);
}

html[data-theme="dark"] option {
    background-color: var(--c-surface);
    color: var(--c-text);
}

/* Автозаполнение браузера красит поле светлым: возвращаем цвет палитры */
html[data-theme="dark"] input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px var(--c-surface-2) inset;
    -webkit-text-fill-color: var(--c-text);
}

html[data-theme="dark"] hr {
    border-color: var(--c-border);
}

/* Секции nicepage с палитрой «светло-серый» (#ccd3db): в светлой теме совпадают с фоном страницы,
   в тёмной получают фон страницы. Кнопки с этой палитрой — вторичная поверхность. */
html[data-theme="dark"] body.u-body .u-palette-5-light-1:not(.u-button-style):not(.u-input):not(.u-field-input),
html[data-theme="dark"] body.u-body section.u-palette-5-light-1:before,
html[data-theme="dark"] body.u-body .u-palette-5-light-1 > .u-container-layout:before,
html[data-theme="dark"] body.u-body .u-palette-5-light-1 > .u-inner-container-layout:before {
    background-color: var(--c-bg);
    color: var(--c-text);
}

html[data-theme="dark"] body.u-body .u-button-style.u-palette-5-light-1 {
    background-color: var(--c-surface-2) !important;
    color: var(--c-text) !important;
}

/* Кнопки из nicepage: светло-голубая заливка с белым текстом в тёмной теме слабо читается */
html[data-theme="dark"] body.u-body .u-btn-submit,
html[data-theme="dark"] body.u-body .u-button-style.u-palette-1-base {
    background-color: var(--c-accent) !important;
    color: var(--c-on-accent) !important;
}

html[data-theme="dark"] body.u-body .u-btn-submit:hover,
html[data-theme="dark"] body.u-body .u-button-style.u-palette-1-base:hover {
    background-color: var(--c-accent-hover) !important;
}
