/* ==========================================================================
   WORLD-CLASS MOBILE UX & ACCESSIBILITY ENGINE (Apple HIG / Material 3 / WCAG AAA)
   Sporcu Bilgi Sistemi (SBS) V2 - Tüm Sayfalar İçin Evrensel Mobil Standartlar
   ========================================================================== */

/* 1. SIFIR YATAY TAŞMA (ZERO HORIZONTAL OVERFLOW) */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Tablo kaydırma kapsayıcısı */
.wc-table-scroll,
.overflow-x-auto {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100%;
}

/* 2. MOBİL EKRAN STANDARTLARI (< 768px) */
@media (max-width: 768px) {

    /* Kök Font Boyutu: Masaüstündeki 13px küçültmesini mobilde 15.5px standardına yükseltir */
    html {
        font-size: 15.5px !important;
    }

    /* A. OKUNABİLİRLİK (READABILITY): Mikro yazıları (7px-10px) okunabilir boyuta (min 11.5px - 12.5px) yükselt */
    [class*="text-[6px]"],
    [class*="text-[7px]"],
    [class*="text-[8px]"],
    [class*="text-[9px]"] {
        font-size: 11.5px !important;
        line-height: 1.38 !important;
        letter-spacing: 0.01em !important;
    }

    [class*="text-[10px]"] {
        font-size: 12px !important;
        line-height: 1.42 !important;
    }

    [class*="text-[11px]"],
    .text-xs {
        font-size: 13px !important;
        line-height: 1.45 !important;
    }

    .text-sm {
        font-size: 14.5px !important;
        line-height: 1.5 !important;
    }

    /* B. FORM ERGONOMİSİ & iOS OTOMATİK ZOOM ENGELİ (Min 16px Font & 44px Parmak Yüksekliği) */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]),
    select,
    textarea {
        font-size: 16px !important;
        min-height: 44px !important;
        line-height: 1.35 !important;
        border-radius: 0.75rem;
    }

    /* Checkbox ve Radio butonları parmakla rahat seçilsin */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 20px !important;
        min-height: 20px !important;
        width: 20px !important;
        height: 20px !important;
        cursor: pointer;
    }

    /* C. PARMAK BÜYÜKLÜĞÜ (44px TOUCH TARGETS - Apple HIG / Material Design Standardı) */
    button:not(.wc-no-touch-expand):not(.hidden),
    [role="button"]:not(.wc-no-touch-expand):not(.hidden),
    a.sidebar-item:not(.hidden),
    a[class*="bg-"][class*="rounded"]:not(.hidden),
    a[class*="border"][class*="rounded"]:not(.hidden) {
        min-height: 42px !important;
        touch-action: manipulation;
    }

    /* Footer ve Üst Bar düz metin linkleri de parmakla rahat dokunulabilir olsun */
    footer a:not(.hidden),
    header a:not(.hidden) {
        min-height: 38px !important;
        padding-top: 4px;
        padding-bottom: 4px;
        touch-action: manipulation;
    }

    /* Tam genişlikli (w-full) link ve butonların flex düzenini koru */
    a.w-full[class*="rounded"],
    button.w-full,
    a.sidebar-item {
        display: flex !important;
    }

    /* Küçük ikon butonlarını (w-6, w-7, w-8) mobilde 40x40px parmak hedefi yap */
    a.w-6.h-6, a.w-7.h-7, a.w-8.h-8,
    button.w-6.h-6, button.w-7.h-7, button.w-8.h-8,
    button.p-1, button.p-1\.5 {
        min-width: 40px !important;
        min-height: 40px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Arama kutusu içindeki temizle (X) butonu input'u taşırmasın */
    input ~ button[class*="absolute"],
    .relative > button[class*="absolute"][class*="right-"] {
        min-height: 32px !important;
        min-width: 32px !important;
    }

    /* D. ADMIN SIDEBAR MOBİL ERGONOMİSİ */
    aside.sidebar:not(.collapsed) {
        width: 82vw !important;
        max-width: 310px !important;
    }

    aside.sidebar .sidebar-item {
        min-height: 46px !important;
        padding-top: 10px !important;
        padding-bottom: 10px !important;
        padding-left: 14px !important;
        padding-right: 14px !important;
        font-size: 14px !important;
    }

    /* Mobilde kapalı sidebar tamamen ekran dışına çıksın (64px yer kaplamasın!) */
    aside.sidebar.collapsed {
        width: 0 !important;
        min-width: 0 !important;
        border-right: none !important;
        overflow: hidden !important;
        transform: translateX(-100%) !important;
    }

    /* E. TABLO HÜCRELERİ MOBİL OKUNABİLİRLİK */
    table th,
    table td {
        padding-top: 9px !important;
        padding-bottom: 9px !important;
        font-size: 12.5px !important;
    }

    /* F. MODAL PENCERELERİ MOBİL UYUMU */
    .modal-backdrop > div,
    [role="dialog"] .sm\:max-w-2xl,
    [role="dialog"] .sm\:max-w-lg,
    [role="dialog"] .max-w-4xl,
    [role="dialog"] .max-w-3xl,
    [role="dialog"] .max-w-2xl {
        max-width: calc(100vw - 16px) !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* G. EVRENSEL MOBİL ALT NAVİGASYON BARI (BOTTOM APP BAR) İÇİN ALT BOŞLUK */
    body.has-wc-mobile-nav {
        padding-bottom: 76px !important;
    }
}

/* 3. ÇOK DAR EKRANLAR (< 400px - iPhone SE / Mini / Galaxy S) */
@media (max-width: 400px) {
    /* 3'lü sıkışık gridlerde yazı taşmasını önle */
    .grid-cols-3 {
        gap: 0.375rem !important;
    }
    .grid-cols-3 > div {
        padding-left: 0.375rem !important;
        padding-right: 0.375rem !important;
    }
}

/* 4. EVRENSEL MOBİL ALT NAVİGASYON BARI & TÜM LİNKLER ÇEKMECESİ STİLLERİ */
.wc-mobile-bottom-nav,
.wc-mobile-drawer-backdrop,
.wc-mobile-drawer {
    display: none;
}

@media (max-width: 768px) {
    .wc-mobile-drawer-backdrop,
    .wc-mobile-drawer {
        display: block;
    }

    .wc-mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9990;
        background: rgba(10, 14, 23, 0.96);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(245, 158, 11, 0.25);
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.75);
        padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)) 6px;
        justify-content: space-around;
        align-items: center;
        height: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    .wc-mobile-nav-item {
        flex: 1;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 3px;
        min-height: 52px !important;
        padding: 4px 2px !important;
        border-radius: 12px;
        color: #94a3b8;
        font-family: 'Inter', system-ui, sans-serif;
        font-size: 11px !important;
        font-weight: 700;
        text-decoration: none !important;
        transition: all 0.2s ease;
        border: none !important;
        background: transparent !important;
        cursor: pointer;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    .wc-mobile-nav-item svg {
        width: 20px;
        height: 20px;
        stroke-width: 2.2;
        transition: transform 0.2s ease;
    }

    .wc-mobile-nav-item.active,
    .wc-mobile-nav-item:active {
        color: #fbbf24 !important;
        background: rgba(245, 158, 11, 0.12) !important;
    }

    .wc-mobile-nav-item.active svg {
        transform: translateY(-1px) scale(1.08);
        color: #f59e0b;
    }

    /* Tüm Linkler Hızlı Erişim Çekmecesi (Drawer) */
    .wc-mobile-drawer-backdrop {
        position: fixed;
        inset: 0;
        z-index: 9995;
        background: rgba(0, 0, 0, 0.8);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .wc-mobile-drawer-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }

    .wc-mobile-drawer {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9998;
        background: linear-gradient(180deg, #111827 0%, #090d16 100%);
        border-top: 2px solid rgba(245, 158, 11, 0.4);
        border-radius: 24px 24px 0 0;
        padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px)) 16px;
        max-height: 85vh;
        overflow-y: auto;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
        box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.9);
    }

    .wc-mobile-drawer.open {
        transform: translateY(0);
    }

    .wc-drawer-link {
        display: flex !important;
        align-items: center !important;
        gap: 12px;
        min-height: 50px !important;
        padding: 10px 14px !important;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.08);
        color: #f8fafc !important;
        font-size: 13.5px !important;
        font-weight: 700;
        text-decoration: none !important;
        transition: all 0.2s ease;
    }

    .wc-drawer-link:active,
    .wc-drawer-link:hover {
        background: rgba(245, 158, 11, 0.15);
        border-color: rgba(245, 158, 11, 0.4);
    }
}

/* Yazıcı Çıktısında Mobil Navigasyonu Gizle */
@media print {
    .wc-mobile-bottom-nav,
    .wc-mobile-drawer-backdrop,
    .wc-mobile-drawer {
        display: none !important;
    }
}
