/* ═══════════════════════════════════════════════════════════════════════════
   DoKoPanel — MOBİL TASARIM ŞEMASI
   ---------------------------------------------------------------------------
   TEK KURAL: bu dosyadaki HER ŞEY @media (max-width:767px) içindedir.
   Masaüstü ve tablet (>=768px) bu dosyadan hiç etkilenmez — style.css aynen
   geçerlidir. Yeni bir ekran eklendiğinde de aynı iskeleti kullandığı sürece
   (.page-header / .card.filter-card / .table-wrapper > table) mobil görünümü
   kendiliğinden doğru olur; ekran başına ayrı CSS yazılmaz.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Geniş ekranda mobil parçaları hiç görünmesin */
#mb-topbar, #mb-tabbar, #mb-filtre-perde, .mb-filtre-ac, .mb-sheet-bas { display: none; }
/* Mobilde eklenip geniş ekrana dönülünce artık kalan hücre görünmesin */
table td.mb-daha, table span.mb-daha { display: none; }

@media (max-width: 767px) {

  /* ── 0. Temel ─────────────────────────────────────────────────────────── */
  body { -webkit-text-size-adjust: 100%; }
  html { scroll-padding-top: 60px; }

  /* iOS'ta 16px altındaki input'a dokununca ekran zoom yapıyor. 16px şart. */
  .input, input, select, textarea {
    font-size: 16px !important;
    min-height: 44px;
    padding: 10px 12px;
  }
  textarea.input { min-height: 88px; }
  select.input { appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='2' fill='none' stroke-linecap='round'/></svg>");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

  /* Dokunma hedefi minimum 44px (Apple/Google eşiği) */
  .btn { min-height: 44px; padding: 11px 16px; font-size: 14px; }
  /* Takvim okları gibi dar düğmeler de parmakla vurulabilsin (min 42x42) */
  .btn-sm { min-height: 42px; min-width: 42px; padding: 8px 12px; font-size: 13px;
            justify-content: center; }
  .btn-icon { width: 40px; height: 40px; font-size: 17px; }

  /* ── 1. Üst çubuk (fixed) ─────────────────────────────────────────────── */
  #mb-topbar {
    display: flex; align-items: center; gap: 10px;
    position: fixed; top: 0; left: 0; right: 0; z-index: 150;
    height: 54px; padding: 0 8px 0 4px;
    padding-top: env(safe-area-inset-top);
    height: calc(54px + env(safe-area-inset-top));
    background: var(--nav-bg); color: #fff;
    box-shadow: 0 1px 6px rgba(0,0,0,.28);
  }
  #mb-topbar .mb-menu {
    background: none; border: none; color: #fff; font-size: 21px;
    width: 46px; height: 46px; border-radius: 10px; cursor: pointer; flex: 0 0 auto;
  }
  #mb-topbar .mb-menu:active { background: rgba(255,255,255,.14); }
  #mb-topbar .mb-baslik {
    font-size: 16px; font-weight: 700; flex: 1 1 auto; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #mb-topbar .mb-filtre-ac {
    display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto;
    background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
    color: #D5DED8; border-radius: 9px; height: 38px; padding: 0 12px;
    font-size: 13px; font-weight: 600; cursor: pointer;
  }
  #mb-topbar .mb-filtre-ac.dolu { background: var(--blue); border-color: var(--blue); color: #fff; }

  /* Eski yüzen ☰ düğmesi artık üst çubukta */
  .sidebar-toggle { display: none !important; }

  /* ── 2. Alt sekme çubuğu (başparmak bölgesi) ──────────────────────────── */
  #mb-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
    background: #fff; border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(15,23,42,.07);
  }
  #mb-tabbar a {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px;
    height: 56px; text-decoration: none; color: #7F9189;
    font-size: 10.5px; font-weight: 600; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  #mb-tabbar a i { font-style: normal; font-size: 20px; line-height: 1; }
  #mb-tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #mb-tabbar a.aktif { color: var(--blue); }
  #mb-tabbar a:active { background: #EEF3EF; }

  /* ── 3. Sayfa gövdesi ─────────────────────────────────────────────────── */
  .main-content {
    margin-left: 0;
    padding: calc(64px + env(safe-area-inset-top)) 12px
             calc(72px + env(safe-area-inset-bottom));
  }
  /* Başlık artık üst çubukta; burada tekrar etmesin */
  .page-header .page-title { display: none; }
  .page-header:not(:has(.header-actions > *)) { margin-bottom: 0; }
  .page-header {
    margin-bottom: 12px; gap: 8px;
    /* Eylem düğmeleri tek satır, yatay kaydırmalı şerit */
  }
  .page-header .header-actions {
    width: 100%; display: flex; gap: 8px; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding-bottom: 2px;
  }
  .page-header .header-actions::-webkit-scrollbar { display: none; }
  .page-header .header-actions > * { flex: 0 0 auto; }
  .page-header .header-actions > .input,
  .page-header .header-actions > select { min-width: 130px; width: auto; }

  .card { padding: 14px; border-radius: 12px; margin-bottom: 12px; }
  .card.p0 { padding: 0; }

  /* ── 4. Kenar çubuğu (drawer) ─────────────────────────────────────────── */
  /* Üst çubuk da z-index:150 — drawer onun ÜSTÜNDE açılmalı */
  .sidebar { width: min(84vw, 300px); z-index: 175; }
  body.sidebar-open .sidebar-backdrop { z-index: 170 !important; }
  /* Panel açıkken arka plan kaymasın */
  body.sidebar-open, body.mb-filtre-acik { overflow: hidden; }
  .sidebar-nav .nav-link { padding: 12px 14px; font-size: 15px; }
  .sidebar-brand { font-size: 17px; }

  /* ── 5. FİLTRELER → alt sayfa (bottom sheet) ──────────────────────────── */
  /* Filtre kartı akıştan çıkar, alttan açılan bir panele dönüşür. DOM'da
     yerinden OYNAMAZ — mevcut id'ler ve onchange bağlantıları aynen çalışır. */
  .card.filter-card.mb-filtre {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 210;
    margin: 0 !important; max-height: 82vh; overflow-y: auto;
    border-radius: 18px 18px 0 0; padding: 0 16px 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 40px rgba(15,23,42,.28);
    transform: translateY(101%); transition: transform .22s ease;
    visibility: hidden;
  }
  .card.filter-card.mb-filtre.acik { transform: translateY(0); visibility: visible; }
  .mb-sheet-bas {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; background: #fff; z-index: 2;
    margin: 0 -16px 10px; padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border);
  }
  .mb-sheet-bas b { font-size: 15px; }
  .mb-sheet-bas .mb-sheet-kapat {
    background: var(--blue); color: #fff; border: none; border-radius: 9px;
    height: 38px; padding: 0 18px; font-size: 14px; font-weight: 600; cursor: pointer;
  }
  /* Sheet içinde filtreler alt alta, tam genişlik */
  .mb-filtre .filter-row { flex-direction: column; align-items: stretch; gap: 12px; }
  .mb-filtre .filter-group { width: 100%; min-width: 0; flex: none; }
  .mb-filtre .filter-group label { font-size: 12px; }
  .mb-filtre .btn { width: 100%; justify-content: center; }

  #mb-filtre-perde {
    display: none; position: fixed; inset: 0; z-index: 205;
    background: rgba(15,23,42,.5);
  }
  #mb-filtre-perde.acik { display: block; }

  /* ── 6. TABLO → KART  (mobil şemanın kalbi) ───────────────────────────── */
  /* JS her <td>'ye başlıktan okuduğu data-mlabel'ı yazar; düzeni CSS kurar.
     4+ sütunlu her tablo otomatik karta döner. Opt-out: <table data-mobil="tablo"> */
  .mb-kart-kap { background: transparent !important; box-shadow: none !important;
                 padding: 0 !important; overflow: visible !important; }
  .mb-kart-kap .table-wrapper { overflow: visible; }

  table.mb-kart, table.mb-kart tbody, table.mb-kart tfoot,
  table.mb-kart tr, table.mb-kart td { display: block; width: auto; }
  table.mb-kart thead { display: none; }

  table.mb-kart tbody tr {
    display: flex; flex-direction: column;
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 12px 14px; margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(15,23,42,.05);
  }
  table.mb-kart tbody tr:hover { background: #fff; }
  table.mb-kart tbody tr:active { background: #F5F8F5; }

  table.mb-kart td {
    border: none; padding: 5px 0; font-size: 13.5px;
    display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
    text-align: left !important;
    order: 1;   /* başlık -1, önemli 0, normal 1, detay 98, işlem 99 */
  }
  table.mb-kart td::before {
    content: attr(data-mlabel);
    flex: 0 0 40%; max-width: 40%;
    font-size: 11px; font-weight: 700; letter-spacing: .3px;
    text-transform: uppercase; color: #7F9189; line-height: 1.5;
  }
  table.mb-kart td > * { min-width: 0; }
  /* Değer iki satırlıysa ("151.392,88 ₺" + "3 fatura · en eski …") ikincisi alta iner;
     masaüstündeki satır içi white-space:nowrap kartta metni üst üste bindiriyordu. */
  table.mb-kart td { flex-wrap: wrap; white-space: normal !important; }
  table.mb-kart td > * { white-space: normal !important; }
  table.mb-kart td:not(.mb-bas) > div ~ div, table.mb-kart td:not(.mb-bas) > div ~ small { flex: 0 0 100%; text-align: right; margin-top: -2px; }
  table.mb-kart td.mb-bas { flex-direction: column; align-items: flex-start; }
  /* Masaüstünde son sütunu sabitleyen gölge kartta şerit olarak görünüyordu */
  table.mb-kart td:last-child, table.mb-kart th:last-child { position: static; box-shadow: none; min-width: 0; background: transparent; }
  /* Sekme düğmesi sıraları (Gelen e-Belgeler, Faturalar): sığmayan alt satıra */
  #eb-sekme, #ft-sekme { flex-wrap: wrap; }
  /* Ödeme takvimi: 7 gün ekrana sığsın (içerik sütunu genişletmesin) */
  .acc-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .acc-cell { min-width: 0; overflow: hidden; }
  /* Değer tarafı sağa dayalı ve satır kırılabilir */
  table.mb-kart td { word-break: break-word; }

  /* "Önemli" sütun: başlığın hemen altında, vurgulu — asla katlanmaz */
  table.mb-kart td.mb-onemli { order: 0; font-size: 15px; font-weight: 700; color: #10231C; }
  table.mb-kart td.mb-onemli::before { color: #53655D; font-size: 11px; }

  /* Başlık hücresi: kartın adı */
  table.mb-kart td.mb-bas {
    display: block; font-size: 15.5px; font-weight: 700; color: #10231C;
    line-height: 1.3; padding: 0 0 9px; margin-bottom: 5px;
    border-bottom: 1px dashed var(--border);
    order: -1;
  }
  table.mb-kart td.mb-bas::before { content: none; }
  table.mb-kart td.mb-bas .nav-cell-link { text-decoration: none; color: inherit; }

  /* İşlem hücresi: kart altında düğme şeridi.
     "Detay" düğmesi buraya girdiğinde solda, işlem düğmeleri sağda kalır. */
  table.mb-kart td.mb-islem {
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
    padding: 9px 0 0; margin-top: 3px; border-top: 1px dashed var(--border);
    position: static !important; box-shadow: none !important; min-width: 0 !important;
    order: 99;
  }
  table.mb-kart td.mb-islem > .mb-daha { margin-right: auto; }
  table.mb-kart td.mb-islem::before { content: none; }
  table.mb-kart td.mb-islem .td-actions { justify-content: flex-end; width: 100%; }
  table.mb-kart td.mb-islem .btn-icon { width: 44px; height: 40px; }

  /* Boş hücre kartı şişirmesin */
  table.mb-kart td.mb-bos { display: none; }

  /* "Kayıt yok" gibi tek hücreli satırlar */
  table.mb-kart tbody tr.mb-tekil { text-align: center; color: var(--text-muted); }
  table.mb-kart tbody tr.mb-tekil td { display: block; text-align: center; }
  table.mb-kart tbody tr.mb-tekil td::before { content: none; }

  /* Uzun kartlar: ilk 5 satır görünür, gerisi "daha fazla" ile açılır */
  table.mb-kart tbody tr.mb-uzun td.mb-ek { display: none; }
  table.mb-kart tbody tr.mb-uzun.mb-acik td.mb-ek { display: flex; }
  /* Kendi satırında (işlem hücresi olmayan tablolarda) */
  table.mb-kart td.mb-daha {
    display: block; padding: 9px 0 0; margin-top: 3px; order: 98;
    border-top: 1px dashed var(--border);
    color: var(--blue); font-size: 12.5px; font-weight: 700; text-align: center;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  /* İşlem şeridinin içinde (normal durum) */
  table.mb-kart span.mb-daha {
    display: inline-block;
    color: var(--blue); font-size: 13px; font-weight: 700; white-space: nowrap;
    padding: 9px 4px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  table.mb-kart td.mb-daha::before { content: none; }
  table.mb-kart tr.mb-acik .mb-daha { color: var(--text-muted); }

  /* Dip toplam satırı: vurgulu özet kartı */
  table.mb-kart tfoot tr {
    background: #10231C; color: #fff; border-radius: 12px;
    padding: 12px 14px; margin-bottom: 10px; display: block;
  }
  table.mb-kart tfoot td {
    background: transparent; border: none; padding: 5px 0;
    font-size: 13.5px; font-weight: 700; position: static !important; box-shadow: none !important;
  }
  table.mb-kart tfoot td::before { color: #7F9189; }
  table.mb-kart tfoot td.mb-bos { display: none; }

  /* Karta dönmeyen dar tablolar: yatay kaydırma yine de rahat olsun */
  .table-wrapper { -webkit-overflow-scrolling: touch; }
  table:not(.mb-kart) { font-size: 12.5px; }
  table:not(.mb-kart) th, table:not(.mb-kart) td { padding: 9px 10px; }

  /* ── 7. Modal → alt sayfa ─────────────────────────────────────────────── */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%; max-width: none !important; max-height: 94vh;
    border-radius: 18px 18px 0 0;
  }
  .modal-header { padding: 15px 16px; position: sticky; top: 0; background: #fff;
    border-radius: 18px 18px 0 0; z-index: 2; }
  .modal-header h2 { font-size: 15.5px; }
  .modal-close-btn { font-size: 22px; width: 40px; height: 40px; }
  .modal-body { padding: 16px; padding-bottom: 20px; }
  .modal-body .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .modal-footer {
    padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
    position: sticky; bottom: 0; background: #fff; gap: 8px;
  }
  .modal-footer .btn { flex: 1 1 0; justify-content: center; }
  /* Modal içindeki tablolar da karta döner */
  .modal-body table.mb-kart tbody tr { border-color: #E4EBE6; }

  /* Çok satırlı seçim listesi (ürün birleştirme) ekranı doldurmasın */
  select[size] { height: 34vh !important; min-height: 0; font-size: 15px !important; }

  /* ── 8. Açılır listeler ───────────────────────────────────────────────── */
  .sd-dropdown { max-height: 46vh; font-size: 15px; }
  .sd-item { padding: 12px 14px; font-size: 15px; }
  .ms-menu { width: calc(100vw - 32px); max-width: none; left: 0; }
  .ms-menu .ms-search { font-size: 16px; }

  /* ── 9. İstatistik/özet kutuları ──────────────────────────────────────── */
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 21px; }
  .employee-grid, .ted-grid, .kap-kartlar,
  .dashboard-layout, .dash-detail-grid, .gun-bloklar, .gun-sayfa, .acc-two {
    grid-template-columns: 1fr !important;
  }
  .chart-container { width: 190px; height: 190px; }

  /* ── Ürün detayı: özet kutuları ikişerli, yoksa ekranı doldurup
        asıl tabloyu aşağı itiyor ────────────────────────────────────────── */
  .pd-kutular { grid-template-columns:1fr 1fr; gap:8px; margin-bottom:10px; }
  .pd-kutu { padding:10px 12px; border-radius:10px; }
  .pd-kutu span { font-size:10px; letter-spacing:.3px; }
  .pd-kutu strong { font-size:16px; }
  .pd-kutu small { font-size:10.5px; line-height:1.3; }
  #pd-sekmeler { padding:8px 8px 0; overflow-x:auto; scrollbar-width:none; }
  #pd-sekmeler::-webkit-scrollbar { display:none; }
  #pd-sekmeler .kap-sekme { white-space:nowrap; }
  .pd-uyari { font-size:12.5px; padding:9px 12px; }

  /* ── 10. Ay Kapanışları / tedarikçi kartları ──────────────────────────── */
  .kap-sekme { padding: 9px 12px; font-size: 13px; }
  #kap-sekmeler { overflow-x: auto; scrollbar-width: none; }
  #kap-sekmeler::-webkit-scrollbar { display: none; }
  .kap-kanallar { flex-wrap: wrap; }

  /* ── 11. Toast: alt çubuğun üstünde ───────────────────────────────────── */
  .toast {
    left: 12px; right: 12px; bottom: calc(70px + env(safe-area-inset-bottom));
    max-width: none; text-align: center; font-size: 14px;
  }

  /* ── 12. Yatay taşma sigortası ────────────────────────────────────────── */
  body { overflow-x: hidden; }
  .main-content, .page, .card { max-width: 100%; }
  img, canvas { max-width: 100%; }
}

/* Telefonu yan çevirince de kart düzeni sürsün (yükseklik dar) */
@media (max-width: 950px) and (max-height: 480px) and (orientation: landscape) {
  #mb-tabbar a { height: 46px; font-size: 10px; }
  #mb-tabbar a i { font-size: 17px; }
}

/* ═══════════ SAHA GÖRÜNÜMÜ — mobil parçalar (yalnız dar ekran) ═══════════ */
@media (max-width: 767px) {
  #mb-topbar { background: var(--surface); color: var(--ink); box-shadow: none; border-bottom: 1px solid var(--line); }
  #mb-topbar .mb-menu { color: var(--ink); display: grid; place-items: center; }
  #mb-topbar .mb-menu svg { width: 22px; height: 22px; }
  #mb-topbar .mb-menu:active { background: var(--surface-2); }
  #mb-topbar .mb-baslik { font-family: var(--f-display); font-size: 19px; letter-spacing: -.01em; }
  #mb-topbar .mb-filtre-ac { background: var(--surface-2); border-color: var(--line); color: var(--ink); border-radius: 12px; }
  #mb-topbar .mb-filtre-ac svg { width: 16px; height: 16px; }
  #mb-topbar .mb-filtre-ac.dolu { background: var(--accent); border-color: var(--accent); color: #fff; }
  #mb-tabbar { border-top-color: var(--line); box-shadow: none; }
  #mb-tabbar a { color: var(--muted); font-size: 11px; }
  #mb-tabbar a svg { width: 22px; height: 22px; }
  #mb-tabbar a.aktif { color: var(--accent); }
  #mb-tabbar a:active { background: var(--surface-2); }
  .card { border-radius: 18px; }
  table.mb-kart tbody tr { border-radius: 18px; box-shadow: none; border-color: var(--line); }
  table.mb-kart tbody tr:active { background: #F5F8F5; }
  table.mb-kart td::before { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
  table.mb-kart tfoot tr { background: var(--accent); border-radius: 18px; }
  table.mb-kart tfoot td::before { color: rgba(255,255,255,.75); }
  .mb-sheet-bas .mb-sheet-kapat { background: var(--accent); border-radius: 12px; }
  .card.filter-card.mb-filtre { border-radius: 22px 22px 0 0; }
  .modal, .modal-header { border-radius: 22px 22px 0 0; }
  .page-title { font-size: 22px; }
}
