/**
 * Mobil & tablet UX polish (production)
 * Desktop / tema / navbar / alt nav / hamburger / drawer’a dokunmaz.
 *
 * DOKUNULMAZ sınıflar:
 * .mobile-bottom-nav*, .mobile-menu-toggle*, .mobile-menu-overlay*,
 * .mobile-category-drawer*, #mobileCategoryDrawer*
 */

/* ─── Mobil + tablet token’lar (≤991px) ─── */
@media (max-width: 1024px) {
    :root {
        --m-safe-x: max(12px, env(safe-area-inset-left, 0px));
        --m-safe-x-r: max(12px, env(safe-area-inset-right, 0px));
        --m-safe-b: env(safe-area-inset-bottom, 0px);
        --m-nav-clearance: var(--mobile-bottom-nav-clearance, max(96px, calc(72px + var(--m-safe-b))));
        --m-touch-min: 44px;
        --m-input-fs: 16px;
        --m-input-min-h: 48px;
        --m-card-gap: 12px;
        --m-radius-card: 12px;
        /* Nav 2147482000 · drawer 2147483000+ — arada panel/cart/modal */
        --m-z-cart: 2147482500;
        --m-z-panel: 2147482600;
        --m-z-modal: 2147483100;
        --m-z-toast: 2147482700;
    }

    /* İçerik: alt sabit nav ile çakışmayı önle (main.css body padding’i tamamlar) */
    .site-footer,
    .ilan-pazari-page,
    .profile-page,
    .mesajlar-page,
    .bildirimler-page,
    .ilanlarim-page,
    body:has(.dashboard-wrapper) .dashboard-wrapper {
        scroll-margin-bottom: var(--m-nav-clearance);
    }

    /* Taşma: dekoratif genişlikler */
    main.kategoriler-main,
    .profile-page {
        overflow-x: clip;
    }

    .profile-page .profile-cover-section {
        overflow-x: clip;
    }

    /* Z-index: modallar alt nav üstünde, drawer altında (drawer açıkken menü öncelikli) */
    .mail-modal:not(.mail-modal--hidden),
    .notif-modal-overlay.show,
    .success-modal-overlay.show,
    .error-modal-overlay.show,
    .purchase-modal-overlay.show,
    .playerid-modal-overlay.show,
    .modal-overlay.active,
    .doping-modal.active {
        z-index: var(--m-z-modal) !important;
    }

    .notification-drawer-root.is-open {
        z-index: var(--m-z-panel) !important;
    }

    .yer6-cart-root.is-open {
        z-index: var(--m-z-cart) !important;
    }

    .kyc-toast-host,
    .fatura-toast-host,
    .site-toast {
        z-index: var(--m-z-toast) !important;
    }

    /* Kart ritmi */
    .listing-card,
    .benzer-ilan-card,
    .category-card,
    .dashboard-wrapper .header-card,
    .dashboard-wrapper .content-card,
    .pwd-card,
    .mail-card,
    .kyc-card {
        gap: var(--m-card-gap);
    }

    /* GPU-friendly: sabit yardımcılar (nav hariç) */
    .scroll-to-top.show,
    .canli-destek-label:not(.hidden) {
        transform: translateZ(0);
        transition: transform 0.25s ease, opacity 0.25s ease, bottom 0.25s ease;
    }

    /* Ağır blur — mobilde repaint azalt (görünüm korunur) */
    .yer6-cart-overlay,
    .notif-modal-overlay,
    .success-modal-overlay,
    .error-modal-overlay,
    .purchase-modal-overlay,
    .playerid-modal-overlay.show,
    .modal-overlay.active {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

/* ─── Mobil + tablet (≤991px, masaüstü PC ≥992px) ─── */
@media (max-width: 1024px) {
    .search-filter-wrapper {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    .search-area-wrapper {
        min-width: 0 !important;
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }

    .filter-btn {
        flex: 1 1 auto;
        min-height: var(--m-input-min-h);
    }

    .ilan-pazari-layout {
        gap: 14px;
    }

    .listing-tabs-section .listing-tabs-container {
        scrollbar-width: none;
    }

    .listing-tabs-section .listing-tabs-container::-webkit-scrollbar {
        display: none;
    }
}

/* ─── iPad / tablet dar (≤820) ─── */
@media (max-width: 820px) {
    .pubg-categories-grid,
    .kategoriler-grid {
        gap: 12px !important;
    }

    .ilan-pazari-toolbar {
        row-gap: 10px;
    }

    .mesajlar-sidebar {
        max-height: 38vh;
    }
}

/* ─── Mobil (≤768) ─── */
@media (max-width: 1024px) {
    /* iOS input zoom önleme */
    input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='hidden']):not([type='file']):not(.notification-drawer__search-input):not(.message-drawer__search-input):not(.message-drawer-modal__input),
    select,
    textarea,
    .search-area-wrapper input,
    .telefon-degistir-wrap input,
    .mail-field input,
    .pwd-field input,
    .fatura-bilgileri-wrap input,
    .fatura-bilgileri-wrap select,
    .fatura-bilgileri-wrap textarea,
    .live-chat-window .form-group input,
    .live-chat-window .form-group textarea {
        font-size: var(--m-input-fs) !important;
        line-height: 1.35;
    }

    input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='hidden']):not(.notification-drawer__search-input):not(.message-drawer__search-input):not(.message-drawer-modal__input),
    select,
    textarea,
    .mail-field,
    .pwd-field,
    .fatura-bilgileri-wrap .f-field input,
    .fatura-bilgileri-wrap .f-field select {
        min-height: var(--m-input-min-h);
        box-sizing: border-box;
    }

  textarea {
        min-height: 96px;
        resize: vertical;
        max-width: 100%;
    }

    /* Dokunma alanları — alt nav / hamburger / drawer hariç */
    .action-btn,
    .ilan-pazari-btn,
    .ilan-pazari-toolbar__sort-option,
    .mail-flow-btn,
    .pwd-submit,
    .notif-modal-btn,
    .success-modal-btn,
    .error-modal-btn,
    .home-see-all-btn,
    .yer6-cart-btn,
    .header-cart-link,
    .new-message-btn,
    .bildirimler-header button,
    .notification-drawer__pill,
    .notification-drawer__close {
        min-height: var(--m-touch-min);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .filter-btn {
        min-height: var(--m-touch-min);
        min-width: 0;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .mail-flow-btn--block,
    .pwd-submit,
    .notif-modal-btn {
        min-width: 0;
        width: 100%;
        max-width: 100%;
        justify-content: center;
    }

    /* Scroll deneyimi */
    main.container,
    .ilan-pazari-page,
    .yer6-cart-main-scroll,
    .mesajlar-main,
    .bildirimler-list,
    .mail-modal__dialog,
    .notif-modal {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }

    /* Sabit FAB / destek — alt nav üstü (main.css offset’leri ile uyumlu) */
    .scroll-to-top.show {
        bottom: max(100px, calc(var(--m-nav-clearance) + 12px)) !important;
        width: 48px;
        height: 48px;
        z-index: 2147482400 !important;
    }

    .canli-destek-label:not(.hidden) {
        bottom: max(96px, calc(var(--m-nav-clearance) + 4px)) !important;
        z-index: 2147482400 !important;
        max-width: calc(100% - var(--m-safe-x) - var(--m-safe-x-r) - 24px);
    }

    /* Sepet çekmecesi safe-area */
    .yer6-cart-drawer {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .yer6-cart-footer {
        padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    }

    /* Tablo yatay kaydırma ipucu */
    .dashboard-wrapper table,
    .fatura-bilgileri-wrap table {
        -webkit-overflow-scrolling: touch;
    }
}

/* ─── iPhone genişlikleri ─── */
@media (max-width: 414px) {
    :root {
        --m-card-gap: 10px;
    }

    .section-title {
        font-size: 1.1rem;
        line-height: 1.3;
    }

    .listing-card .card-title,
    .benzer-ilan-card .card-title {
        font-size: 14px;
        line-height: 1.35;
    }
}

@media (max-width: 390px) {
    main.container,
    .ilan-pazari-toolbar-strip__inner,
    .mesajlar-container,
    .bildirimler-container {
        padding-left: max(10px, env(safe-area-inset-left)) !important;
        padding-right: max(10px, env(safe-area-inset-right)) !important;
    }
}

@media (max-width: 375px) {
    .categories-grid,
    .pubg-categories-grid {
        gap: 8px !important;
    }
}

@media (max-width: 320px) {
    .breadcrumb-links a,
    .breadcrumb-current {
        font-size: 11px;
    }

    .category-name {
        font-size: 10px;
    }

    .mail-modal__dialog,
    .notif-modal {
        max-width: calc(100% - 16px) !important;
    }
}

/* ─── Performans: hareket azaltma ─── */
@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    *:not(#snowfall):not(#snowfall *),
    *:not(#snowfall):not(#snowfall *)::before,
    *:not(#snowfall):not(#snowfall *)::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .scroll-to-top.show,
    .canli-destek-label {
        transition: none !important;
    }
}

/* ─── Modal scroll lock yardımcısı (mevcut JS overflow:hidden ile) ─── */
@media (max-width: 1024px) {
    html:has(body[style*='overflow: hidden']),
    html:has(body[style*='overflow:hidden']) {
        overscroll-behavior: none;
    }
}
