/* =========================================================================
   KLC Destek Sistemi - Mobil Uyumluluk Katmani (v2.2)
   =========================================================================
   Bu dosya modern-corporate.css'ten SONRA yuklenir ve yalnizca kucuk ekran
   duzeltmelerini icerir. Masaustu gorunumu etkilememesi icin tum kurallar
   media query icindedir.

   Cozulen sorunlar:
   1. Form alanlarinda font-size < 16px -> iOS Safari odaklaninca sayfayi
      otomatik yakinlastiriyor ve kullanici surekli uzaklastirmak zorunda
      kaliyordu.
   2. ".btn { width: 100% }" kurali TUM butonlari tam genislik yapiyordu;
      filtre haplari (btn-sm rounded-pill) alt alta diziliyor ve talep
      listesinin ustunde devasa bir sutun olusturuyordu.
   3. Dokunma hedefleri 14-36px idi (onerilen en az 44px).
   4. Genis tablolar tasiyor, kaydirilabilir oldugu belli olmuyordu.
   5. Centikli telefonlarda alt/ust guvenli alan bosluklari yoktu.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1) TABLET VE ALTI  (<= 991px)
   ------------------------------------------------------------------------- */
@media (max-width: 991.98px) {

    /* Sayfanin yatay kaymasini kesin olarak engelle */
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Genis tablolar her zaman kendi kutusu icinde kaysin */
    .table-responsive,
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    /* Tablonun kaydirilabildigini gorsel olarak belli et */
    .table-responsive {
        position: relative;
        background:
            linear-gradient(to right, var(--surface, #fff) 30%, rgba(255, 255, 255, 0)),
            linear-gradient(to right, rgba(255, 255, 255, 0), var(--surface, #fff) 70%) 100% 0,
            radial-gradient(farthest-side at 0 50%, rgba(15, 23, 42, .12), rgba(0, 0, 0, 0)),
            radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, .12), rgba(0, 0, 0, 0)) 100% 0;
        background-repeat: no-repeat;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-attachment: local, local, scroll, scroll;
    }

    /* Tablo hucreleri gereksiz yere sarmasin */
    .table> :not(caption)>*>* {
        white-space: nowrap;
    }

    .table .text-wrap,
    .table .allow-wrap {
        white-space: normal;
    }
}

/* -------------------------------------------------------------------------
   2) MOBIL  (<= 768px)
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {

    /* ---- 2.1 iOS otomatik yakinlastirma duzeltmesi ----
       Form alanlarinin yazi boyutu 16px'in altina dusememeli. */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="time"],
    select,
    textarea,
    .form-control,
    .form-select {
        font-size: 16px !important;
    }

    /* ---- 2.2 Buton genisligi duzeltmesi ----
       modern-corporate.css icindeki ".btn { width: 100% }" kuralini
       yalnizca gercekten tam genislik olmasi gereken butonlarda birak. */
    .btn-sm,
    .btn-group .btn,
    .btn-toolbar .btn,
    .input-group .btn,
    .nav-pills .btn,
    .dropdown .btn,
    .filter-bar .btn,
    .table .btn,
    .card-header .btn,
    .modal-footer .btn,
    .pagination .btn,
    .btn-icon,
    .btn-inline {
        width: auto !important;
        margin-bottom: 0;
    }

    /* Ikon-only butonlar kare kalsin */
    .btn-icon,
    .btn.btn-square {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
    }

    /* ---- 2.3 Filtre haplarini yatay kaydirilabilir serit yap ----
       Alt alta 6 durum filtresi yerine tek satirda kayan serit. */
    .nav-pills,
    .filter-pills,
    .status-filter-bar {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.4rem;
        padding-bottom: 0.35rem;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
    }

    .nav-pills::-webkit-scrollbar,
    .filter-pills::-webkit-scrollbar,
    .status-filter-bar::-webkit-scrollbar {
        display: none;
    }

    .nav-pills>*,
    .filter-pills>*,
    .status-filter-bar>* {
        flex: 0 0 auto;
        scroll-snap-align: start;
    }

    /* ---- 2.4 Dokunma hedefleri (WCAG 2.5.5 / Apple HIG: en az 44px) ---- */
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-success,
    .btn-danger,
    .btn-warning,
    .btn-info,
    .btn-light,
    .btn-dark,
    button[type="submit"] {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 38px;
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .dropdown-item,
    .list-group-item-action,
    .sidebar .nav-item,
    .page-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Alt bilgi ve yardimci baglantilara dokunma payi ver */
    .footer-links a,
    .auth-footer a,
    .text-muted a,
    .small a {
        display: inline-block;
        padding: 0.4rem 0.25rem;
    }

    /* Onay kutusu / radyo buyutulsun */
    .form-check-input {
        width: 1.15rem;
        height: 1.15rem;
        margin-top: 0.15rem;
    }

    .form-check-label {
        padding-left: 0.15rem;
        line-height: 1.5;
    }

    /* ---- 2.5 Baslik ve icerik yogunlugu ----
     *
     * !important ZORUNLU: modern-corporate.css:1157 satirinda
     * ".content-area { padding: 1.75rem 2rem !important }" var.
     * mobile.css daha SONRA yuklendigi halde !important tasimadigi
     * icin bu kural KAZANMIYORDU; mobil dolgu azaltmasi hicbir zaman
     * uygulanmadi.
     *
     * Etkisi buyuktu: 375px genisligindeki bir ekranda yalnizca bu
     * kural 64px yiyordu. Ic ice kartlarla birlikte ekranin yarisi
     * bosluga gidiyor, metin ~200px lik bir seride sikisiyordu.
     */
    .content-area,
    .container-fluid {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }

    .card {
        border-radius: 12px;
    }

    .card-body {
        padding: 0.9rem;
    }

    h1,
    .h1 {
        font-size: 1.4rem;
    }

    h2,
    .h2 {
        font-size: 1.25rem;
    }

    h3,
    .h3 {
        font-size: 1.1rem;
    }

    h4,
    .h4 {
        font-size: 1rem;
    }

    /* ---- 2.6 Modal pencereler ----
       Kucuk ekranda tam yukseklik, icerik kaydirilabilir. */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-body {
        max-height: calc(100vh - 12rem);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .modal-footer>.btn {
        flex: 1 1 auto;
    }

    /* ---- 2.7 Form duzeni ---- */
    .row>[class*="col-"] {
        margin-bottom: 0.5rem;
    }

    .form-label {
        margin-bottom: 0.3rem;
        font-weight: 600;
    }

    /* Yan yana sigmayan input gruplarini alt alta al */
    .input-group.stack-mobile {
        flex-direction: column;
    }

    .input-group.stack-mobile>* {
        width: 100%;
        border-radius: var(--radius-md, 8px) !important;
    }

    /* ---- 2.8 Select2 mobil uyumu ---- */
    .select2-container {
        width: 100% !important;
    }

    .select2-container--default .select2-selection--single,
    .select2-container--default .select2-selection--multiple {
        min-height: 44px !important;
        font-size: 16px !important;
    }

    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 42px !important;
    }

    .select2-search__field {
        font-size: 16px !important;
    }

    /* ---- 2.9 Yan menu genisligi kucuk telefonlarda ---- */
    .sidebar {
        width: min(280px, 85vw);
    }

    /* ---- 2.10 Ustteki arac cubugu ----
       OLCULEN SORUN (375px): .header-actions-frame 372px genisligindeydi ve
       311px'lik ebeveynin icine sigmiyordu; sag kenari 580px'e tasiyordu.
       Body'de overflow-x gizli oldugu icin kullanici menusu (Profilim / Cikis)
       ekranin disinda kaliyor ve ACILAMIYORDU. */
    .top-bar {
        gap: 0.5rem;
    }

    .top-bar .btn {
        width: auto !important;
        margin-bottom: 0;
    }

    .header-actions-frame {
        gap: 0.4rem !important;
        min-width: 0;
        flex-shrink: 1;
        max-width: 100%;
    }

    .header-actions-frame>* {
        min-width: 0;
    }

    /* Kullanici adini gizle, ikon ve rol rozeti kalsin */
    .user-info {
        max-width: 100%;
        gap: 0.25rem;
    }

    .user-info>span:not(.badge) {
        display: none !important;
    }

    .user-info>i {
        font-size: 1.4rem;
        margin: 0 !important;
    }

    .user-info .badge {
        font-size: 0.6rem !important;
        padding: 0.2rem 0.4rem;
        margin-left: 0.2rem !important;
    }

    /* Acilan menu ekran disina tasmasin */
    .header-actions-frame .dropdown-menu {
        max-width: calc(100vw - 1.5rem);
        min-width: 200px !important;
    }

    /* ---- 2.11 Istatistik kartlari ----
       Tek sutun yerine 2'li izgara: dikey kaydirma yariya iner. */
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.6rem;
    }

    .stat-card-modern .stat-value,
    .stat-card .stat-value {
        font-size: 1.35rem;
    }

    .stat-card-modern .stat-label,
    .stat-card .stat-label {
        font-size: 0.72rem;
    }

    /* ---- 2.12 Grafikler ---- */
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }

    /* ---- 2.13 Centikli cihazlarda guvenli alan ---- */
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .sidebar {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Sabit alt cubuk varsa ---- */
    .fixed-bottom,
    .sticky-actions {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }
}

/* -------------------------------------------------------------------------
   3) KUCUK TELEFONLAR  (<= 576px)
   ------------------------------------------------------------------------- */
@media (max-width: 576px) {

    /* Istatistik kartlari 2 sutunda kalsin.
       Panoda 14 adet kart var; tek sutunda sayfa gereksiz yere uzuyor
       ve kullanici ozet bilgiyi gormek icin uzun uzun kaydiriyordu.
       Kompakt kartlar 375px'te 2 sutuna rahat sigiyor. */
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.5rem;
    }

    /* Cok dar ekranlarda (<=360px) tek sutun */
    @media (max-width: 360px) {
        .stats-grid {
            grid-template-columns: 1fr !important;
        }
    }

    /* Sayfalama sikisimasin */
    .pagination {
        flex-wrap: wrap;
        gap: 0.2rem;
        justify-content: center;
    }

    .pagination .page-item .page-link {
        min-width: 40px;
        justify-content: center;
    }

    /* Uzun tablolari kart gorunumune cevirmek icin isaretli tablolar
       (view dosyasinda <table class="table mobile-cards"> ile kullanilir) */
    .table.mobile-cards thead {
        display: none;
    }

    .table.mobile-cards,
    .table.mobile-cards tbody,
    .table.mobile-cards tr,
    .table.mobile-cards td {
        display: block;
        width: 100%;
    }

    .table.mobile-cards tr {
        margin-bottom: 0.75rem;
        border: 1px solid var(--gray-200, #e2e8f0);
        border-radius: 10px;
        padding: 0.5rem 0.75rem;
        background: var(--surface, #fff);
    }

    .table.mobile-cards td {
        white-space: normal;
        border: 0;
        padding: 0.35rem 0;
        display: flex;
        justify-content: space-between;
        gap: 0.75rem;
    }

    /* Hucre basligi: <td data-label="Talep No"> */
    .table.mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-500, #64748b);
        flex: 0 0 40%;
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.02em;
    }

    .table.mobile-cards td:last-child {
        justify-content: flex-end;
        padding-top: 0.5rem;
        border-top: 1px dashed var(--gray-200, #e2e8f0);
        margin-top: 0.25rem;
    }

    .table.mobile-cards td:last-child::before {
        content: "";
        flex: 0;
    }

    /* Modal tam ekrana yakin */
    .modal-dialog {
        margin: 0.35rem;
        max-width: calc(100% - 0.7rem);
    }

    /* Butonlar arasi bosluk */
    .d-flex.gap-2>.btn,
    .d-flex.gap-3>.btn {
        margin-bottom: 0;
    }
}

/* -------------------------------------------------------------------------
   3b) GIRIS / KAYIT SAYFALARI
   Bu sayfalar kendi satir ici CSS'lerini tasidigi icin ayrica ele alinir.
   Olculen degerler (375px genislikte): baglantilar 14px, dokuman
   sekmeleri 22px, kapatma butonu 32px yuksekligindeydi.
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {

    /* Alt bilgi yasal baglantilari */
    .legal-compact-bar {
        gap: 0.15rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .legal-compact-link,
    .legal-more-trigger {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        padding: 0.5rem 0.55rem;
    }

    /* "Hemen Kayit Ol" gibi kart ici metin baglantilari */
    .auth-card a,
    .login-card a,
    .register-link a,
    .auth-switch a {
        display: inline-block;
        padding: 0.45rem 0.3rem;
        min-height: 40px;
        line-height: 1.6;
    }

    /* Yasal dokuman modali */
    .modal-close {
        min-width: 44px;
        min-height: 44px;
    }

    .modal-doc-nav {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.3rem;
        scrollbar-width: none;
    }

    .modal-doc-nav::-webkit-scrollbar {
        display: none;
    }

    .modal-doc-tab {
        flex: 0 0 auto;
        min-height: 40px;
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
    }
}

/* -------------------------------------------------------------------------
   4) DOKUNMATIK CIHAZLAR (fare olmayan)
   ------------------------------------------------------------------------- */
@media (hover: none) and (pointer: coarse) {

    /* Dokunmatikte hover efektleri "yapisik" kaliyor; kapat */
    .btn:hover,
    .card:hover,
    .nav-item:hover {
        transform: none !important;
    }

    /* Tooltip yerine baslik yeterli */
    .table td[title] {
        cursor: default;
    }
}

/* -------------------------------------------------------------------------
   5) YAZDIRMA
   ------------------------------------------------------------------------- */
@media print {

    .sidebar,
    .top-bar,
    .mobile-nav-toggle,
    .sidebar-overlay,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }
}
