/* Shared surfaces and controls for light, dark and system theme modes. */
:root {
    color-scheme: light;
    --site-background: #ffffff;
    --site-surface: #ffffff;
    --site-surface-muted: #f9fafb;
    --site-surface-hover: #f0f4ff;
    --site-border: #d1d5db;
    --site-text: #111827;
    --site-text-muted: #4b5563;
    --site-link: #2c5aa0;
    --site-outline-link: #1e40af;
    --site-outline-link-hover: #1e40af;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --site-background: #111827;
    --site-surface: #1f2937;
    --site-surface-muted: #172030;
    --site-surface-hover: #293b54;
    --site-border: #475569;
    --site-text: #f3f4f6;
    --site-text-muted: #cbd5e1;
    --site-link: #93c5fd;
    --site-outline-link: #93c5fd;
    --site-outline-link-hover: #2c5aa0;
}

.header-controls { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.header .header-content { gap: 1rem; }
.header-desktop-nav { display: none; }
.header .burger-menu { display: block; margin-left: 0; }

.preference-dropdown { position: relative; color: var(--site-text); flex-shrink: 0; }
.preference-dropdown[hidden] { display: none; }
.preference-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-width: 56px;
    min-height: 44px;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--site-border);
    border-radius: 9999px;
    background: var(--site-surface);
    color: var(--site-text);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.preference-trigger::-webkit-details-marker { display: none; }
.preference-trigger::marker { content: ''; }
.preference-dropdown[open] .preference-trigger,
.preference-trigger:hover { background: var(--site-surface-hover); border-color: var(--site-link); }
.preference-chevron { transition: transform 0.15s ease; }
.preference-dropdown[open] .preference-chevron { transform: rotate(180deg); }

.preference-options {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 60;
    min-width: 180px;
    width: max-content;
    max-width: calc(100vw - 2rem);
    padding: 0.35rem;
    border: 1px solid var(--site-border);
    border-radius: 0.8rem;
    background: var(--site-surface);
    box-shadow: 0 12px 32px rgb(0 0 0 / 18%);
}

.preference-option {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    min-height: 44px;
    padding: 0.6rem 0.65rem;
    border: 0;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--site-text);
    text-align: left;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.preference-option::after { display: none; }
.preference-option:hover,
.preference-option[aria-current="true"],
.preference-option[aria-pressed="true"] { background: var(--site-surface-hover); color: var(--site-link); }
.preference-check { margin-left: auto; visibility: hidden; }
.preference-option[aria-current="true"] .preference-check,
.preference-option[aria-pressed="true"] .preference-check { visibility: visible; }
.preference-language-code { min-width: 1.5rem; font-size: 0.75rem; font-weight: 700; }
.theme-current-icon { display: none; }
:root[data-theme-mode="light"] [data-theme-icon="light"],
:root[data-theme-mode="dark"] [data-theme-icon="dark"],
:root[data-theme-mode="system"] [data-theme-icon="system"] { display: inline-flex; }

.preference-trigger:focus-visible,
.preference-option:focus-visible { outline: 2px solid var(--site-link); outline-offset: 3px; }
.preference-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.mobile-menu-content { overflow-y: auto; justify-content: flex-start; padding-top: 4.5rem; gap: 1.5rem; }
.mobile-menu .mobile-nav { gap: 0.5rem; }
.mobile-menu .mobile-nav a { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.mobile-menu .language-switcher .preference-options { right: auto; left: 0; }

@media (min-width: 1280px) {
    .header-desktop-nav { display: flex; }
    .header .burger-menu { display: none; }
    .mobile-menu { display: none !important; }
}

@media (max-width: 479px) {
    .header .header-content { gap: 0.5rem; }
    .header-controls { margin-left: auto; gap: 0.35rem; }
    .header-brand { font-size: 1.25rem; }
    .preference-trigger { min-width: 52px; padding-inline: 0.55rem; }
}

/* Existing utility colours and page-specific components share the dark palette. */
:root[data-theme="dark"] body.bg-white { background: var(--site-background); color: var(--site-text); }
:root[data-theme="dark"] :is(.bg-white, .card, .result-item, .autocomplete-container, .page-btn, .property-map-card, .gallery-description-section, .faq-section, .faq-answer, .re-section, .re-card, .re-link-inline, .form-popup-content) { background: var(--site-surface); }
:root[data-theme="dark"] :is(.bg-gray-50, .bg-gray-100, .faq-item, .re-summary-item, .property-map-size-control, .property-map-layer-toggle-wrap, .property-map-cadastral, .property-map-iframe) { background: var(--site-surface-muted); }
:root[data-theme="dark"] .bg-gray-200 { background: #334155; }
:root[data-theme="dark"] :is(.bg-white\/90, .bg-white\/95) { background: rgb(31 41 55 / 95%); }
:root[data-theme="dark"] :is(.text-gray-900, .text-gray-800, .text-black, .product-subtitle, .gallery-description-title, .property-map-title, .faq-question, .re-summary-value, .re-card-title, .re-details-row dd) { color: var(--site-text); }
:root[data-theme="dark"] :is(.text-gray-700, .text-gray-600, .text-gray-500, .faq-answer, .autocomplete-item .name, .page-btn, .property-map-size-label, .property-map-layer-toggle-text, .property-map-cadastral, .re-details-row, .re-details-row dt, .re-utilities-list) { color: var(--site-text-muted); }
:root[data-theme="dark"] :is(.text-gray-400, .autocomplete-item .type, .re-summary-label) { color: #a7b3c4; }
:root[data-theme="dark"] :is(.border-gray-100, .border-gray-200, .border-gray-300, .card, .result-item, .autocomplete-container, .autocomplete-item, .page-btn, .gallery-description-title, .faq-item, .faq-question, .property-map-size-control, .property-map-layer-toggle-wrap, .property-map-cadastral, .re-section, .re-card, .re-summary-item) { border-color: var(--site-border); }
:root[data-theme="dark"] :is(.bg-primary-100, .bg-blue-50, .property-map-link, .re-location-card, .re-badge-type, .property-map-card.is-satellite-layer .property-map-layer-toggle-wrap) { background: #243b58; }
:root[data-theme="dark"] :is(.text-primary-500, .text-primary-600, .text-primary-700, .text-primary-800, .text-blue-800, .price-section-label, .it-asset-title-link, .gallery-description-content a, .product-context-link, .property-map-size-value, .property-map-size-label::after, .property-map-link, .re-location-title, .re-location-text, .re-link-inline, .re-badge-type, .property-map-card.is-satellite-layer .property-map-layer-toggle-text) { color: var(--site-link); }
:root[data-theme="dark"] :is(.it-asset-title-link, .gallery-description-content a) { text-decoration-color: currentColor; }
:root[data-theme="dark"] :is(.border-primary-100, .border-primary-200, .border-blue-200, .price-section-label, .property-map-link, .re-location-card, .re-link-inline) { border-color: #3b587a; }
:root[data-theme="dark"] :is(.hover\:bg-gray-50, .hover\:bg-primary-50, .hover\:bg-white):hover,
:root[data-theme="dark"] :is(.autocomplete-item, .page-btn, .property-map-link, .re-link-inline):hover { background: var(--site-surface-hover); }
:root[data-theme="dark"] .hover\:bg-gray-300:hover { background: #475569; }
:root[data-theme="dark"] :is(.hover\:text-primary-500, .hover\:text-primary-600, .hover\:text-primary-700, .hover\:text-primary-900, .it-asset-title-link, .gallery-description-content a, .product-context-link):hover { color: #bfdbfe; }

:root[data-theme="dark"] .from-blue-50 { --tw-gradient-from: #172030; }
:root[data-theme="dark"] .from-primary-50 { --tw-gradient-from: #243b58; }
:root[data-theme="dark"] .via-white { --tw-gradient-via: #1f2937; }
:root[data-theme="dark"] .to-blue-50 { --tw-gradient-to: #243b58; }
:root[data-theme="dark"] .from-blue-600 { --tw-gradient-from: #163b72; }
:root[data-theme="dark"] .to-purple-700 { --tw-gradient-to: #4c1d75; }

:root[data-theme="dark"] :is(input:not([type="range"]):not([type="checkbox"]):not([type="radio"]), textarea, select) { background-color: var(--site-surface); color: var(--site-text); }
:root[data-theme="dark"] :is(input, textarea)::placeholder { color: #a7b3c4; opacity: 1; }
:root[data-theme="dark"] :is(input, textarea, select):focus-visible { outline: 2px solid var(--site-link); outline-offset: 2px; }
:root[data-theme="dark"] :is(.filter-btn.active, .page-btn.active) { background: #2563eb; border-color: #60a5fa; color: #fff; }
:root[data-theme="dark"] :is(.bg-primary-500, .bg-primary-600, .bg-accent-500, .bg-green-500, .bg-red-500, .btn-primary, .btn-telegram) { color: #fff; }
:root[data-theme="dark"] .bg-gray-700 { background: #cbd5e1; }
:root[data-theme="dark"] .floating-button .icon { background: var(--site-surface); color: var(--site-link); }
:root[data-theme="dark"] .floating-button .progress-circle .progress { stroke: var(--site-link); }

:root[data-theme="dark"] .faq-question::after,
:root[data-theme="dark"] .faq-item[open] .faq-question::after,
:root[data-theme="dark"] .property-map-load-btn { background: #243b58; color: var(--site-link); border-color: #3b587a; }
:root[data-theme="dark"] .property-map-size-label::after { color: var(--site-link); }
:root[data-theme="dark"] .re-nearby-grid { color: var(--site-text-muted); }
:root[data-theme="dark"] .sc-38090a7a-0 { background: var(--site-surface-muted); border-color: var(--site-border); }
:root[data-theme="dark"] .cad-codes-box { background: var(--site-surface); border-color: var(--site-border); }
:root[data-theme="dark"] .cad-codes span { color: var(--site-link); }
:root[data-theme="dark"] .property-map-load-btn:hover { background: #293b54; }
:root[data-theme="dark"] :is(.bg-green-50, .property-map-link-gov, .re-badge-sale, .form-popup.popup-success .form-popup-content) { background: #153b30; color: #a7f3d0; border-color: #287354; }
:root[data-theme="dark"] :is(.bg-yellow-50, .bg-yellow-200, .re-badge-condition, .form-popup.popup-warning .form-popup-content) { background: #42341c; color: #fde68a; border-color: #80632a; }
:root[data-theme="dark"] :is(.bg-red-50, .form-popup.popup-error .form-popup-content) { background: #431f28; color: #fecaca; border-color: #8a3d4f; }
:root[data-theme="dark"] .text-green-800 { color: #a7f3d0; }
:root[data-theme="dark"] :is(.text-yellow-700, .text-yellow-800) { color: #fde68a; }
:root[data-theme="dark"] :is(.text-red-500, .text-red-800) { color: #fca5a5; }
:root[data-theme="dark"] .border-green-200 { border-color: #287354; }
:root[data-theme="dark"] .border-yellow-200 { border-color: #80632a; }
:root[data-theme="dark"] .border-red-200 { border-color: #8a3d4f; }
:root[data-theme="dark"] .form-popup-close { color: #cbd5e1; }

@media (prefers-reduced-motion: reduce) {
    .preference-chevron { transition: none; }
}
