/* =============================================
   Тёмная тема: исправления контраста и поверхностей
   Подключать ПОСЛЕДНИМ после page CSS
   ============================================= */

html[data-theme="dark"] {
    --shadow-elevation-sm: 0 2px 12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(155, 109, 255, 0.12);
    --shadow-elevation-md: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(155, 109, 255, 0.15);
    --shadow-elevation-lg: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(155, 109, 255, 0.18);
}

/* Базовый цвет текста в контенте (перебивает разрозненные #333 / #555) */
html[data-theme="dark"] body,
html[data-theme="dark"] .main-content,
html[data-theme="dark"] .account-layout,
html[data-theme="dark"] .content-area,
html[data-theme="dark"] .content-body,
html[data-theme="dark"] .page-section,
html[data-theme="dark"] .checkout-layout,
html[data-theme="dark"] .checkout-main,
html[data-theme="dark"] .collect-page-content {
    color: var(--color-text);
}

html[data-theme="dark"] .main-content :where(
    h1, h2, h3, h4, h5, h6,
    p, li, dt, dd, label, span, small, strong, em,
    td, th, figcaption, .form-hint, .form-label, .section-title
):not(.nav-link):not(.btn-primary):not(.btn-warning):not(.btn-success):not(.btn-danger):not([class*="hero-"]) {
    color: inherit;
}

html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .form-hint,
html[data-theme="dark"] .subtitle-muted {
    color: var(--color-text-muted) !important;
}

html[data-theme="dark"] .text-secondary {
    color: var(--color-text-secondary) !important;
}

/* Карточки и панели */
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .content-area,
html[data-theme="dark"] .content-card,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .checkout-card,
html[data-theme="dark"] .checkout-section,
html[data-theme="dark"] .order-summary,
html[data-theme="dark"] .summary-card,
html[data-theme="dark"] .payment-card,
html[data-theme="dark"] .survey-card,
html[data-theme="dark"] .collect-card,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .cdek-widget-picker__panel {
    background-color: var(--color-surface) !important;
    background-image: none !important;
    color: var(--color-text);
    border-color: var(--color-border);
    box-shadow: var(--shadow-elevation-md) !important;
}

html[data-theme="dark"] .profile-info,
html[data-theme="dark"] .sidebar-footer {
    border-color: var(--color-border-subtle) !important;
}

/* Поля ввода */
html[data-theme="dark"] .form-input,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .form-textarea,
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]),
html[data-theme="dark"] textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] .form-control {
    background-color: var(--color-surface-raised) !important;
    color: var(--color-text) !important;
    border-color: var(--color-border) !important;
}

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

/* Светлые подложки статусов / алертов */
html[data-theme="dark"] .status-badge,
html[data-theme="dark"] .order-status,
html[data-theme="dark"] .alert,
html[data-theme="dark"] .notice,
html[data-theme="dark"] .info-banner,
html[data-theme="dark"] .checkout-hint,
html[data-theme="dark"] .validation-message,
html[data-theme="dark"] .tier-hint,
html[data-theme="dark"] .product-row--highlight,
html[data-theme="dark"] .address-suggestion,
html[data-theme="dark"] .cdek-suggestion-item:hover {
    border-color: var(--color-border);
}

/* Таблицы */
html[data-theme="dark"] table,
html[data-theme="dark"] .table {
    color: var(--color-text);
}

html[data-theme="dark"] .table thead th,
html[data-theme="dark"] table thead th {
    background-color: var(--color-surface-sunken) !important;
    color: var(--color-text) !important;
    border-color: var(--color-border) !important;
}

html[data-theme="dark"] .table tbody tr,
html[data-theme="dark"] table tbody tr {
    background-color: var(--color-surface) !important;
    border-color: var(--color-border-subtle) !important;
}

html[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd),
html[data-theme="dark"] table tbody tr:nth-child(even) {
    background-color: var(--color-surface-raised) !important;
}

/* Калькулятор / retail */
html[data-theme="dark"] .calculator-page .form-card,
html[data-theme="dark"] .calculator-page .cart-section,
html[data-theme="dark"] .calculator-page .preview-panel,
html[data-theme="dark"] .retail-price-page .form-card,
html[data-theme="dark"] .retail-price-page .results-card {
    background-color: var(--color-surface) !important;
    color: var(--color-text);
    box-shadow: var(--shadow-elevation-md) !important;
}

/* Прайс: вернуть читаемые тени блокам (глобальный reset box-shadow: none на price-page) */
html[data-theme="dark"].price-page .price-card,
html[data-theme="dark"].price-page .category-block,
html[data-theme="dark"].price-page .price-table-wrapper,
html[data-theme="dark"].price-page .faq-item,
html[data-theme="dark"].price-page .contact-block {
    box-shadow: var(--shadow-elevation-sm) !important;
}

/* Жёлтые CTA и акцентные поверхности — тёмный текст */
html[data-theme="dark"] .btn-warning,
html[data-theme="dark"] .btn-create-product,
html[data-theme="dark"] .option-button.active,
html[data-theme="dark"] .option-button.selected,
html[data-theme="dark"] .badge-layout-action-btn--confirm,
html[data-theme="dark"] .auth-card .btn-primary,
html[data-theme="dark"] .auth-page .btn-primary,
html[data-theme="dark"] .hero-actions .btn-primary.btn-lg,
html[data-theme="dark"] .collect-header-link-btn-warning:hover {
    color: var(--color-on-accent, #1a0f33) !important;
}

html[data-theme="dark"] .hero-tagline,
html[data-theme="dark"] .hero-min-tier,
html[data-theme="dark"] .page-hero .main-title,
html[data-theme="dark"] .page-hero .subtitle,
html[data-theme="dark"] .preview-chrome-page .header .back-link,
html[data-theme="dark"] .preview-chrome-page .main-title,
html[data-theme="dark"] .preview-chrome-page .subtitle {
    color: #fff !important;
}

/* Ссылки в контенте */
html[data-theme="dark"] .main-content a:not(.btn-primary):not(.btn-secondary):not(.btn-link):not(.nav-link) {
    color: var(--color-primary);
}

html[data-theme="dark"] .sidebar-link {
    color: var(--color-text-secondary);
}

html[data-theme="dark"] .sidebar-link:hover,
html[data-theme="dark"] .sidebar-link.active {
    color: var(--color-primary);
    background-color: var(--color-surface-raised);
}

/* Чекаут / корзина */
html[data-theme="dark"] body.checkout-page .form-section,
html[data-theme="dark"] body.checkout-page .cart-section,
html[data-theme="dark"] body.checkout-page .checkout-form-card,
html[data-theme="dark"] .cart-card,
html[data-theme="dark"] .cart-item,
html[data-theme="dark"] .delivery-option,
html[data-theme="dark"] .payment-method-card {
    background-color: var(--color-surface) !important;
    color: var(--color-text);
    box-shadow: var(--shadow-elevation-md) !important;
    border-color: var(--color-border) !important;
}

html[data-theme="dark"] .option-button.active,
html[data-theme="dark"] .calculator-page .option-button.active {
    color: #1a0f33 !important;
}

html[data-theme="dark"] .option-button {
    border-color: var(--color-border) !important;
    background-color: var(--color-surface-raised) !important;
    color: var(--color-text) !important;
}

html[data-theme="dark"] .option-grid.missing-field .option-button,
html[data-theme="dark"] input.missing-field,
html[data-theme="dark"] .file-upload-area.missing-field {
    background: var(--color-danger-bg) !important;
    border-color: var(--color-danger) !important;
}

/* Светлые блоки с наследованием color: inherit */
html[data-theme="dark"] [class*="card"] [style*="background"],
html[data-theme="dark"] .account-product-card,
html[data-theme="dark"] .order-card,
html[data-theme="dark"] .design-card,
html[data-theme="dark"] .collect-product-card {
    background-color: var(--color-surface) !important;
    color: var(--color-text);
}

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .content-area {
    box-shadow: var(--shadow-elevation-lg) !important;
}

/* === Фон страницы (О нас, Контакты, Jinja chrome) === */
html[data-theme="dark"].preview-chrome-page.preview-sandbox {
    background-color: var(--color-page-bg) !important;
}

html[data-theme="dark"].preview-chrome-page.preview-sandbox body {
    background-color: var(--color-page-bg) !important;
}

html[data-theme="dark"] .contacts-section,
html[data-theme="dark"] .page-section,
html[data-theme="dark"] .contacts-grid {
    color: var(--color-text);
}

html[data-theme="dark"] .content-card,
html[data-theme="dark"] .contact-card {
    box-shadow: var(--shadow-elevation-md) !important;
}

html[data-theme="dark"] .content-card p[style*="color"],
html[data-theme="dark"] .content-card .page-copy {
    color: var(--color-text-secondary) !important;
}

html[data-theme="dark"] .contact-value[href] {
    color: var(--color-primary) !important;
}

/* === Прайс === */
html[data-theme="dark"].price-page {
    --color-text-white: var(--color-surface);
}

html[data-theme="dark"].price-page main,
html[data-theme="dark"].price-page .container {
    color: var(--color-text);
}

html[data-theme="dark"].price-page .bg-white,
html[data-theme="dark"].price-page [class*="bg-white"] {
    background-color: var(--color-surface) !important;
}

html[data-theme="dark"].price-page .solid-cloud-white {
    background-color: var(--color-surface) !important;
    color: var(--color-text) !important;
}

html[data-theme="dark"].price-page .solid-cloud-all,
html[data-theme="dark"].price-page .inner-table,
html[data-theme="dark"].price-page .info-table-container .solid-cloud-all,
html[data-theme="dark"].price-page .info-table-container .inner-table {
    background-color: var(--color-surface-raised) !important;
    color: var(--color-text) !important;
}

html[data-theme="dark"].price-page #content-5 .info-table-container .solid-cloud-white,
html[data-theme="dark"].price-page #content-5 .info-table-container .solid-cloud {
    background-color: var(--color-surface) !important;
    color: var(--color-text) !important;
}

html[data-theme="dark"].price-page .c-c-yellow,
html[data-theme="dark"].price-page .c-c-yellow :where(p, span, li, strong),
html[data-theme="dark"].price-page .yellow-title,
html[data-theme="dark"].price-page .yellow-title :where(p, span, strong),
html[data-theme="dark"].price-page .text-another-services,
html[data-theme="dark"].price-page .tab-nav > input[type="radio"]:checked + label,
html[data-theme="dark"].price-page .stands-tabs-nav label.stands-tab-active {
    color: var(--color-on-accent, #1a0f33) !important;
}

html[data-theme="dark"].price-page .c-c-yellow .text-white,
html[data-theme="dark"].price-page .yellow-title .text-white {
    color: var(--color-on-accent, #1a0f33) !important;
}

html[data-theme="dark"].price-page .solid-cloud .text-white,
html[data-theme="dark"].price-page .solid-cloud-all .text-white {
    color: var(--color-text) !important;
}

html[data-theme="dark"].price-page .solid-cloud .text-big-yellow {
    color: var(--color-accent) !important;
}

html[data-theme="dark"].price-page .border-cloud,
html[data-theme="dark"].price-page .border-cloud-color {
    color: var(--color-text) !important;
}

/* === Шапка / подвал / drawer === */
html[data-theme="dark"] .main-nav {
    background: var(--chrome-glass-bg) !important;
    border-color: var(--chrome-bar-border) !important;
    box-shadow: var(--chrome-shadow) !important;
}

html[data-theme="dark"].preview-chrome-page .main-nav {
    background: var(--chrome-bar-bg) !important;
}

html[data-theme="dark"] .nav-link,
html[data-theme="dark"] .nav-cart,
html[data-theme="dark"] .nav-theme-toggle {
    color: var(--chrome-nav-text) !important;
}

html[data-theme="dark"] .nav-link:hover,
html[data-theme="dark"] .nav-link.active,
html[data-theme="dark"] .nav-cart:hover,
html[data-theme="dark"] .nav-theme-toggle:hover {
    color: var(--chrome-nav-text-hover, #fff) !important;
}

html[data-theme="dark"] .footer {
    background: var(--chrome-glass-footer-bg) !important;
    border-color: var(--chrome-bar-border) !important;
    box-shadow: var(--chrome-footer-shadow) !important;
    color: var(--chrome-nav-text);
}

html[data-theme="dark"].preview-chrome-page .footer {
    background: var(--chrome-bar-bg) !important;
}

html[data-theme="dark"] .footer-tagline {
    color: var(--chrome-nav-text-hover, #fff) !important;
}

html[data-theme="dark"] .footer-links a,
html[data-theme="dark"] .footer-legal a {
    color: var(--chrome-nav-text) !important;
}

html[data-theme="dark"] .footer-links a:hover,
html[data-theme="dark"] .footer-legal a:hover {
    color: var(--chrome-nav-text-hover, #fff) !important;
}

html[data-theme="dark"] .footer-copyright,
html[data-theme="dark"] .footer-legal-sep {
    color: var(--chrome-nav-text-muted) !important;
}

html[data-theme="dark"] .social-link {
    background: var(--chrome-nav-hover-bg) !important;
    border-color: var(--chrome-nav-border-hover) !important;
    color: var(--chrome-nav-text) !important;
    box-shadow: none;
}

html[data-theme="dark"] .social-link:hover {
    background: var(--chrome-nav-active-bg) !important;
    color: var(--chrome-nav-text-hover, #fff) !important;
}

html[data-theme="dark"] .nav-drawer__panel {
    background: var(--chrome-bar-bg) !important;
    border-color: var(--chrome-bar-border) !important;
}

html[data-theme="dark"] .nav-drawer__backdrop {
    background: var(--chrome-drawer-backdrop) !important;
}

html[data-theme="dark"] .nav-drawer__menu .nav-link,
html[data-theme="dark"] .nav-links--drawer .nav-link {
    color: var(--chrome-nav-text) !important;
}

html[data-theme="dark"] .nav-drawer__profile-name {
    color: var(--chrome-nav-text-hover, #fff) !important;
}

html[data-theme="dark"] body {
    background-color: var(--color-page-bg);
}

html[data-theme="dark"]:not(.preview-chrome-page) body {
    background-image:
        linear-gradient(rgba(22, 12, 46, 0.55), rgba(22, 12, 46, 0.55)),
        url('/static/img/sparkles-background.svg'),
        url('/static/img/Vector.svg');
}

html[data-theme="dark"] .nav-burger__bar {
    background: var(--chrome-nav-text-hover, #fff) !important;
}

html[data-theme="dark"] {
    scrollbar-color: rgba(155, 109, 255, 0.45) transparent;
}

html[data-theme="dark"]::-webkit-scrollbar-thumb {
    background: rgba(155, 109, 255, 0.45);
}
