/* Sitewide Color & Typography Parity + Automatic Light / Dark Mode.
   Loaded last in <head> across all storefront pages so legacy page stylesheets
   adapt seamlessly to theme-tokens.css without hardcoded light-only surfaces. */

/* ==================== 1. BASE & FORM DEFAULTS ==================== */
html {
    background-color: var(--surface-page);
    color: var(--text-primary);
}

body {
    background-color: var(--surface-page);
    background-image: var(--bg-floral-pattern);
    background-repeat: repeat;
    background-size: 220px 220px;
    background-position: top left;
    color: var(--text-primary);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
select,
textarea {
    color: var(--text-primary);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-secondary);
}

/* ==================== 2. UNIFIED PRODUCT CARDS & FAVORITES ==================== */
.product-card,
#favoritesModal .product-card {
    background: var(--surface-card) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

.product-card .product-image,
#favoritesModal .product-image {
    background: var(--surface-soft) !important;
}

.product-card .product-name,
#favoritesModal .product-name,
.favorite-item-name {
    color: var(--text-primary) !important;
}

.product-card .product-price .current-price,
#favoritesModal .product-price .current-price,
.favorite-item-price .current-price {
    color: var(--text-primary) !important;
}

.product-card .product-price .original-price,
#favoritesModal .product-price .original-price,
.favorite-item-price .original-price {
    color: var(--text-secondary) !important;
}

.product-card .product-rating .rating-score,
#favoritesModal .product-rating .rating-score {
    color: var(--badge-rating-text) !important;
}

.product-card .product-rating .rating-count,
#favoritesModal .product-rating .rating-count {
    color: var(--text-secondary) !important;
}

.product-card .product-discount-badge,
#favoritesModal .product-discount-badge {
    background: var(--brand-accent-solid, var(--brand-accent)) !important;
    color: #FFFFFF !important;
}

.product-card .wishlist-btn {
    background: var(--surface-glass) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}

.product-card .wishlist-btn.active,
.product-card .wishlist-btn.favorited {
    color: var(--brand-accent) !important;
}

.hero-section,
.categories-section,
.todays-section {
    background: transparent;
}

.flash-nav-btn {
    background: var(--surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    box-shadow: var(--shadow-soft);
}

/* ==================== 3. GLOBAL SKELETONS ==================== */
.product-skeleton,
.favorite-skeleton-item {
    background: var(--surface-card) !important;
    border-color: var(--border-subtle) !important;
}

.skeleton-image,
.skeleton-line,
.favorite-skeleton-image,
.favorite-skeleton-line,
.favorite-skeleton-action {
    background: linear-gradient(
        90deg,
        var(--skeleton-base) 25%,
        var(--skeleton-highlight) 50%,
        var(--skeleton-base) 75%
    ) !important;
    background-size: 200% 100% !important;
}

/* ==================== 4. EXPLORE (explore.html) ==================== */
.explore-sidebar,
.sidebar-header,
.explore-top-bar,
.mobile-category-select select,
.mobile-filters-toggle,
.sort-select-container select,
.price-input-inline,
.top-filter-group,
.discount-filter-inline {
    background: var(--surface-card) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

.sort-select-container select,
.mobile-category-select select {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

.sidebar-title,
.category-filter-name,
.explore-results-info strong,
.explore-empty h3 {
    color: var(--text-primary) !important;
}

.explore-results-info,
.top-filter-label,
.price-separator,
.explore-empty p,
.discount-filter-inline {
    color: var(--text-secondary) !important;
}

.category-filter-item:hover,
.category-filter-item.active {
    background: var(--brand-primary-soft) !important;
    color: var(--brand-primary) !important;
}

.category-filter-item.active .category-filter-name {
    color: var(--brand-primary) !important;
}

.mobile-filters-toggle.is-active,
.explore-page-body .load-more-btn {
    background: var(--brand-primary-solid, var(--brand-primary)) !important;
    border-color: var(--brand-primary-solid, var(--brand-primary)) !important;
    color: #FFFFFF !important;
}

.explore-page-body .load-more-btn:hover {
    background: var(--brand-primary-solid-hover, var(--brand-primary-hover)) !important;
}

/* ==================== 5. SEARCH RESULTS (search-results.html) ==================== */
.results-header,
.filter-select,
.filter-input,
.results-mobile-toggle {
    background: var(--surface-card) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

.results-mobile-toggle.is-active {
    background: var(--brand-primary-solid, var(--brand-primary)) !important;
    border-color: var(--brand-primary-solid, var(--brand-primary)) !important;
    color: #FFFFFF !important;
}

.search-page-title__heading,
.search-page-title__query {
    color: var(--text-primary) !important;
}

.results-info,
.filter-sep,
.filter-discount-label {
    color: var(--text-secondary) !important;
}

.results-info .results-count,
.search-page-title__icon {
    color: var(--brand-primary) !important;
}

.search-results-container .load-more-btn {
    background: var(--brand-primary-solid, var(--brand-primary)) !important;
    color: #FFFFFF !important;
}

.search-results-container .load-more-btn:hover {
    background: var(--brand-primary-solid-hover, var(--brand-primary-hover)) !important;
}

/* ==================== 6. PRODUCT DETAIL (product-detail.html) ==================== */
/* Light & Dark surfaces, 3:4 portrait gallery, accordions, reviews, and mobile sticky buy bar
   are owned directly by css/product-detail.css and css/product-detail-skeleton.css. */
body.product-detail-view {
    --accent: var(--brand-primary);
    --accent-rgb: var(--brand-primary-rgb);
    --primary-text: var(--text-primary);
    --secondary-text: var(--text-secondary);
}

/* ==================== 7. CART (cart.html) ==================== */
body.cart-view {
    --accent: var(--brand-primary);
    --accent-rgb: var(--brand-primary-rgb);
    --primary-text: var(--text-primary);
    --secondary-text: var(--text-secondary);
    --background-color: var(--surface-page);
    --card-background: var(--surface-card);
    --cart-border: var(--border-subtle);
    --cart-selected: var(--brand-primary-soft);
    --cart-control: var(--brand-primary);
}

.cart-view #clearCartModal .modal-content {
    background: var(--surface-card) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

@media (max-width: 768px) {
    .cart-view .bottom-nav {
        background: transparent !important;
        border-top: none !important;
    }
}

/* ==================== 8. CHECKOUT (checkout.html) ==================== */
/* Semantic Light & Dark surfaces, cards, inputs, steppers, and modals
   are owned cleanly by css/checkout-theme.css without blanket overrides. */
body.checkout-mode {
    --accent: var(--brand-primary);
    --accent-rgb: var(--brand-primary-rgb);
    --primary-text: var(--text-primary);
    --secondary-text: var(--text-secondary);
}

/* ==================== 9. PROFILE, SETTINGS & MODALS ==================== */
body.profile-fullscreen,
.profile-page-container,
.settings-page {
    background: var(--surface-page) !important;
    color: var(--text-primary) !important;
}

.settings-modal:not(#favoritesModal) .settings-modal-overlay {
    background: rgba(9, 12, 18, 0.58) !important;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.settings-modal:not(#favoritesModal).active {
    opacity: 1 !important;
    animation: none !important;
}

.settings-modal:not(#favoritesModal).active .settings-modal-content {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    border: 1px solid var(--border-subtle) !important;
    box-shadow: var(--shadow-elevated) !important;
}

.settings-list,
.settings-card,
.language-list-container,
.profile-card,
.profile-notification-dropdown,
.settings-modal-content,
.settings-modal-header,
.settings-modal-body,
.campaign-products-modal,
.campaign-modal-header {
    background: var(--surface-card) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

.settings-list-item:hover,
.settings-modal-close {
    background: var(--surface-soft) !important;
    color: var(--text-primary) !important;
}

.profile-topbar-action {
    background: var(--brand-primary-soft) !important;
    color: var(--brand-primary) !important;
}

.settings-modal-header h2,
.settings-list-title,
.info-value,
.profile-topbar-title,
.settings-header h1 {
    color: var(--text-primary) !important;
}

.info-label,
.info-subvalue,
.app-version,
.app-description,
.order-tracking-help,
.settings-section-title {
    color: var(--text-secondary) !important;
}

.order-tracking-input-group {
    background: var(--surface-page) !important;
    border-color: var(--border-strong) !important;
}

.order-tracking-prefix {
    background: var(--surface-soft) !important;
    color: var(--text-secondary) !important;
    border-right-color: var(--border-subtle) !important;
}

.order-tracking-btn {
    background: var(--brand-primary-solid, var(--brand-primary)) !important;
    color: #FFFFFF !important;
}

.order-tracking-btn:hover {
    background: var(--brand-primary-solid-hover, var(--brand-primary-hover)) !important;
}

.order-tracking-input,
body:not(.auth-unified-page) .auth-input-wrapper,
body:not(.auth-unified-page) .auth-input-wrapper input {
    background: var(--surface-page) !important;
    border-color: var(--border-strong) !important;
    color: var(--text-primary) !important;
}

body:not(.auth-unified-page) .auth-button.primary {
    background: var(--brand-primary-solid, var(--brand-primary)) !important;
    color: #FFFFFF !important;
}

body:not(.auth-unified-page) .auth-button.primary:hover {
    background: var(--brand-primary-solid-hover, var(--brand-primary-hover)) !important;
}

body:not(.auth-unified-page) .auth-button.secondary {
    background: var(--surface-soft) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}

/* ==================== 10. AUTH, LEGAL, FAQ & NOTIFICATIONS ==================== */
body.auth-login-page:not(.auth-unified-page),
body.auth-signup-page:not(.auth-unified-page) {
    background: var(--surface-page) !important;
    color: var(--text-primary) !important;
}

body:not(.auth-unified-page) .back-button a,
body:not(.auth-unified-page) .back-button.back-button--inside a {
    background: var(--surface-soft) !important;
    border: 1px solid var(--border-subtle) !important;
    color: var(--text-primary) !important;
    box-shadow: var(--shadow-soft) !important;
}

body:not(.auth-unified-page) .back-button a i,
body:not(.auth-unified-page) .back-button.back-button--inside a i {
    color: var(--text-primary) !important;
}

.legal-modal-content,
.legal-modal-header,
.legal-modal-footer {
    background: var(--surface-card) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

.legal-modal-body,
.legal-text-pre {
    color: var(--text-secondary) !important;
}

body:not(.auth-unified-page) .auth-modal-content,
body:not(.auth-unified-page) .auth-split-panel--form,
.faq-item,
.legal-section,
.help-card {
    background: var(--surface-card) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

body:not(.auth-unified-page) .auth-title,
.faq-question {
    color: var(--text-primary) !important;
}

body:not(.auth-unified-page) .auth-subtitle,
.faq-answer {
    color: var(--text-secondary) !important;
}

body:not(.auth-unified-page) .auth-secondary-action {
    background: var(--surface-card) !important;
    border-color: var(--brand-primary) !important;
    color: var(--brand-primary) !important;
}

.notification-item {
    background: var(--surface-card);
    border-bottom-color: var(--border-subtle);
    color: var(--text-primary);
}

.notification-item:hover {
    background: var(--surface-soft);
}

/* Consent uses the same opaque surfaces, accents and elevation as the storefront. */
.cookie-consent-banner[hidden] { display: none !important; }
.cookie-consent-banner {
    position: fixed;
    z-index: 11050;
    inset-inline: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    max-width: 900px;
    margin-inline: auto;
    padding: 16px 20px;
    color: var(--text-primary);
    background: var(--surface-card);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    box-shadow: var(--shadow-elevated);
}
.cookie-consent-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 20px;
}
.cookie-consent-message {
    flex: 1 1 280px;
    margin: 0;
    color: var(--text-primary);
    font-size: .875rem;
    line-height: 1.5;
}
.cookie-consent-link {
    color: var(--brand-primary);
    font-weight: 600;
    text-underline-offset: .18em;
    text-decoration: underline;
}
.cookie-consent-options { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.cookie-consent-options[hidden], .cookie-consent-btn[hidden] { display: none; }
.cookie-consent-options label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--text-primary); font-size: .875rem; cursor: pointer; }
.cookie-consent-options input { width: 20px; height: 20px; accent-color: var(--brand-primary-solid); }
.cookie-consent-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cookie-consent-btn {
    min-height: 44px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
}
.cookie-consent-accept { background: var(--brand-primary-solid); color: white; }
.cookie-consent-accept:hover { background: var(--brand-primary-solid-hover); }
.cookie-consent-decline {
    background: var(--surface-card);
    color: var(--brand-primary);
    border-color: var(--border-strong);
}
.cookie-consent-decline:hover { background: var(--brand-primary-soft); }
.cookie-consent-banner :focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
@media (max-width: 768px) {
    body:has(#bottomNav) .cookie-consent-banner { bottom: calc(90px + env(safe-area-inset-bottom)); }
}
@media (max-width: 600px) {
    .cookie-consent-banner {
        inset-inline: 12px;
        padding: 10px 12px;
        border-radius: 12px;
        box-shadow: var(--shadow-soft);
    }
    .cookie-consent-content { display: grid; gap: 6px; }
    .cookie-consent-message { font-size: .8125rem; line-height: 1.4; }
    .cookie-consent-actions { justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
    .cookie-consent-btn { padding-inline: 12px; }
}

/* ==================== 11. FOOTER (UNIFIED LIGHT & DARK) ==================== */
.footer {
    --footer-ink: var(--text-primary);
    --footer-muted: var(--text-secondary);
    --footer-blue: var(--brand-primary);
    --footer-border: var(--border-subtle);
    background: var(--footer-top-fade, var(--surface-card));
    color: var(--text-primary);
    border-top: 1px solid var(--border-subtle);
}

.footer a,
.footer p,
.footer li {
    color: var(--text-secondary);
}

.footer h3,
.footer h4,
.footer-col-title,
.footer-contact-item {
    color: var(--text-primary);
}

.footer-support {
    background: linear-gradient(135deg, var(--surface-soft) 0%, var(--surface-card) 100%);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 15px 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-soft);
}

.footer-support-copy > i {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    padding: 0;
    border-right: none;
    background: var(--brand-primary-soft);
    color: var(--brand-primary);
    flex-shrink: 0;
}

.footer-support h2 {
    font-size: 18px;
    line-height: 1.25;
    margin: 0 0 2px;
    color: var(--text-primary);
}

.footer-support p {
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-secondary);
}

.footer-whatsapp {
    background: rgba(22, 163, 74, 0.11) !important;
    border: 1px solid rgba(22, 163, 74, 0.28) !important;
    color: #15803D !important;
    border-radius: 999px !important;
    min-height: 40px !important;
    padding: 8px 18px !important;
    font-size: 13.5px !important;
    font-weight: 700 !important;
    gap: 8px !important;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.footer-whatsapp > i {
    font-size: 18px !important;
    color: inherit !important;
}

.footer-whatsapp:hover {
    background: #16A34A !important;
    border-color: #16A34A !important;
    color: #FFFFFF !important;
}

.footer-support-phone {
    font-size: 12.5px;
    color: var(--text-secondary);
}

.footer .app-store-link,
.footer-directions {
    background: var(--surface-soft) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

.footer .app-store-link:hover,
.footer .social-link:hover {
    background: var(--surface-elevated) !important;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .footer-whatsapp {
        background: rgba(34, 197, 94, 0.16) !important;
        border-color: rgba(34, 197, 94, 0.34) !important;
        color: #4ADE80 !important;
    }

    :root:not([data-theme="light"]) .footer-whatsapp:hover {
        background: #16A34A !important;
        border-color: #16A34A !important;
        color: #FFFFFF !important;
    }
}

:root[data-theme="dark"] .footer-whatsapp {
    background: rgba(34, 197, 94, 0.16) !important;
    border-color: rgba(34, 197, 94, 0.34) !important;
    color: #4ADE80 !important;
}

:root[data-theme="dark"] .footer-whatsapp:hover {
    background: #16A34A !important;
    border-color: #16A34A !important;
    color: #FFFFFF !important;
}

.footer .app-store-name {
    color: var(--text-primary) !important;
}

.footer .app-store-label {
    color: var(--text-secondary) !important;
}

.footer .social-link {
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

.footer-payment-methods .payment-icon:not(.iyzico) {
    background: var(--surface-soft);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .footer-dev-brand {
        background: rgba(255, 255, 255, 0.92);
        padding: 4px 10px;
        border-radius: 8px;
    }
}

:root[data-theme="dark"] .footer-dev-brand {
    background: rgba(255, 255, 255, 0.92);
    padding: 4px 10px;
    border-radius: 8px;
}

@media (max-width: 768px) {
    .footer {
        margin-top: 24px !important;
        padding-top: 16px !important;
    }

    .footer > .container {
        padding-inline: 14px !important;
    }

    .footer-support {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 12px 14px !important;
        gap: 10px !important;
        margin-bottom: 18px !important;
        border-radius: 14px !important;
    }

    .footer-support-copy {
        gap: 0 !important;
        align-items: flex-start !important;
        min-width: 0;
        flex: 1;
    }

    .footer-support-copy > i {
        display: none !important;
    }

    .footer-support h2 {
        font-size: 13.5px !important;
        line-height: 1.25 !important;
        letter-spacing: -0.015em !important;
        margin: 0 !important;
    }

    .footer-support p {
        font-size: 11.5px !important;
        line-height: 1.3 !important;
        margin: 2px 0 0 !important;
    }

    .footer-support-action {
        display: flex !important;
        align-items: center !important;
        flex-shrink: 0 !important;
        gap: 0 !important;
    }

    .footer-whatsapp {
        min-height: 36px !important;
        padding: 7px 12px !important;
        border-radius: 999px !important;
        font-size: 12px !important;
        gap: 6px !important;
        white-space: nowrap !important;
    }

    .footer-whatsapp > i {
        font-size: 15px !important;
    }

    .footer-support-phone {
        display: none !important;
    }

    body.has-bottom-nav,
    body:has(#bottomNav) {
        padding-bottom: calc(104px + env(safe-area-inset-bottom));
    }

    body.has-bottom-nav .footer,
    body:has(#bottomNav) .footer {
        position: relative;
        padding-bottom: 16px;
    }

    body.has-bottom-nav .footer::after,
    body:has(#bottomNav) .footer::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: calc(-104px - env(safe-area-inset-bottom));
        height: calc(104px + env(safe-area-inset-bottom));
        background: var(--surface-card);
    }
}

@media (max-width: 360px) {
    .footer-support {
        padding: 10px 12px !important;
        gap: 8px !important;
    }

    .footer-support h2 {
        font-size: 12.5px !important;
    }

    .footer-support p {
        font-size: 11px !important;
    }

    .footer-whatsapp {
        padding: 6px 10px !important;
        font-size: 11.5px !important;
    }
}

/* ==================== 12. 3-MODE THEME SEGMENTED CONTROL (ayarlarim.html) ==================== */
.settings-theme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    flex-wrap: wrap;
}

.settings-theme-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.settings-theme-sub {
    font-size: 12.5px;
    color: var(--text-secondary);
}

.theme-segmented {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: var(--surface-page);
    border: 1px solid var(--border-subtle);
}

.theme-segmented__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
    touch-action: manipulation;
}

.theme-segmented__btn:hover {
    color: var(--text-primary);
}

.theme-segmented__btn.is-active {
    background: var(--brand-primary-solid, var(--brand-primary));
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(var(--brand-primary-rgb), 0.28);
}
