/* Stok & Malzeme modül stilleri — sahibi: public/js/stock.js
   Ortak sınıflar (.card, .kpi-grid, .data-table, .pill, .toolbar, .form-grid, .tabbar, .modal…) styles.css'tedir;
   burada yalnızca stk- önekli, bu sayfaya özgü kurallar var. Belirteçler: --primary, --line, --tone-*, --radius… */

/* hidden özniteliği .btn / .field gibi display veren sınıflarda da çalışsın */
.stk-page [hidden], .stk-form [hidden] { display: none !important; }

/* ------------------------------------------------------------------ KPI */
.stk-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stk-kpis .kpi-card { min-width: 0; }
.stk-kpis .kpi-sub { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stk-kpis .kpi-label, .stk-kpis .kpi-value { max-width: 100%; }
.stk-kpi-kritik .kpi-value { color: var(--danger); }
.stk-kpi-kritik .kpi-sub { color: var(--danger); font-weight: 600; }
.stk-kpis a.kpi-card { color: inherit; text-decoration: none; }
.stk-kpis a.kpi-card:hover { border-color: var(--line-hover); }
.stk-kpis a.kpi-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ------------------------------------------------------------------ KART: sekmeler + araç çubuğu + tablo */
.stk-card { overflow: visible; }
.stk-tabs { padding: 4px 20px 0; }
.stk-tabs .tabbar { margin-bottom: 0; }
.stk-govde { padding: 16px 20px 20px; min-width: 0; }
.stk-toolbar { margin-bottom: 14px; gap: 10px; }
.stk-toolbar .stk-kategori { min-width: 170px; }
.stk-sayi { font-size: 13px; color: var(--muted); white-space: nowrap; }
.stk-sayi-kritik { color: var(--danger); font-weight: 600; }
.stk-hata { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0; }
.stk-btn-ikon { display: inline-flex; align-items: center; }
.stk-btn-ikon svg { width: 18px; height: 18px; }

/* Aç / kapa filtre çipi (onay kutusu görünümlü) */
.stk-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.stk-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px 6px 10px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--panel); color: var(--ink);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.stk-chip:hover { background: var(--surface-2); border-color: var(--line-hover); }
.stk-chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.stk-chip-kutu {
  width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-strong); background: var(--panel);
  display: inline-flex; align-items: center; justify-content: center; color: transparent; flex: 0 0 auto;
}
.stk-chip-kutu svg { width: 12px; height: 12px; }
.stk-chip[aria-pressed="true"] { background: var(--tone-soft); border-color: var(--tone); color: var(--heading); }
.stk-chip[aria-pressed="true"] .stk-chip-kutu { background: var(--tone); border-color: var(--tone); color: #fff; }
.stk-chip.tone-gray[aria-pressed="true"] { --tone: var(--navy); }

/* ------------------------------------------------------------------ TABLOLAR */
/* .data-table'ın overflow:hidden'ı tabloyu kaydırma kabı yapar ve sabit (sticky) sütunları bozar; köşeleri zaten .table-wrap kırpar */
.data-table.stk-table { overflow: visible; }
.stk-table th, .stk-table td { padding-left: 8px; padding-right: 8px; }
.stk-table th:first-child, .stk-table td:first-child { padding-left: 12px; }
.stk-table th:last-child, .stk-table td:last-child { padding-right: 12px; }
.stk-table td { white-space: nowrap; }
.stk-table td.stk-col-ad { white-space: normal; min-width: 150px; }
.stk-table td.stk-col-ted { white-space: normal; min-width: 100px; }
.stk-table td.stk-col-kul { white-space: normal; min-width: 72px; }
.stk-kisa { display: inline-block; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.stk-table th.stk-col-islem, .stk-table td.stk-col-islem { width: 1%; text-align: right; }
/* Geniş ekranda işlem sütunu yatay kaydırmada sağda sabit kalır (dar dizüstünde de düğmeler görünür) */
@media (min-width: 641px) {
  .stk-table td.stk-col-islem { position: sticky; right: 0; z-index: 1; background: var(--panel); }
  .stk-table th.stk-col-islem { position: sticky; right: 0; z-index: 2; }
  .stk-tasiyor .stk-col-islem { box-shadow: -1px 0 0 var(--line), -8px 0 10px -8px rgba(15, 23, 42, 0.18); }
}
.stk-th-2 { display: inline-block; max-width: 64px; white-space: normal; line-height: 1.25; vertical-align: middle; }
.stk-kod { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; font-weight: 600; color: var(--heading); letter-spacing: -0.2px; }
.stk-ad { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 600; color: var(--heading); }
.stk-alt { margin-top: 2px; font-size: 12px; color: var(--muted); }
.stk-alt-kod { display: none; }
.stk-miktar { font-weight: 600; color: var(--heading); }
.stk-deger { font-weight: 600; color: var(--heading); }
.stk-kritik { display: inline-flex; align-items: center; gap: 4px; color: var(--danger) !important; }
.stk-kritik-ikon { display: inline-flex; }
.stk-kritik-ikon svg { width: 14px; height: 14px; }
.data-table tr.stk-row-kritik td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.data-table tr.stk-row-pasif td { background: var(--surface-2); color: var(--muted); }
.data-table tr.stk-row-pasif .stk-ad, .data-table tr.stk-row-pasif .stk-miktar,
.data-table tr.stk-row-pasif .stk-deger, .data-table tr.stk-row-pasif .stk-kod { color: var(--muted); }
.stk-foot-label { color: var(--muted) !important; font-weight: 600 !important; }

.stk-islemler { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: nowrap; }
.stk-hareket-btn { gap: 4px; }
.stk-hareket-btn .stk-btn-ikon svg { width: 15px; height: 15px; color: var(--primary-d); }
.stk-caret { display: inline-flex; color: var(--muted); }
.stk-caret svg { width: 13px; height: 13px; }
.stk-hareket-btn[aria-expanded="true"] { background: var(--surface-2); border-color: var(--line-hover); }

/* Hareketler tablosu */
.stk-kalem-link {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 0; border: 0; background: none;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.stk-kalem-link .stk-kalem-ad { font-size: 13px; color: var(--ink); white-space: normal; }
.stk-kalem-link:hover .stk-kalem-ad { color: var(--primary-d); text-decoration: underline; }
.stk-kalem-link:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 4px; }
.stk-m-in { color: var(--primary-d); font-weight: 700; }
.stk-m-out { color: var(--tone-orange-ink); font-weight: 700; }
.stk-m-adjust { color: var(--blue); font-weight: 700; }
.stk-wo-link { font-weight: 600; color: var(--blue); text-decoration: none; }
.stk-wo-link:hover { text-decoration: underline; }
.stk-not { display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.stk-hareket-toolbar .input { min-width: 0; }
.stk-hareket-toolbar .stk-f-kalem { width: 230px; }
.stk-hareket-toolbar .stk-f-wo { width: 210px; }
.stk-hareket-toolbar .stk-f-tur { width: 140px; }
.stk-tarih-aralik { display: inline-flex; align-items: center; gap: 6px; }
.stk-tarih-aralik .stk-f-tarih { width: 150px; min-width: 0; }
.stk-tarih-ayrac { color: var(--muted); }
.stk-temizle { white-space: nowrap; }

/* Tedarikçiler */
.stk-iletisim { color: var(--ink); text-decoration: none; }
.stk-iletisim:hover { color: var(--primary-d); text-decoration: underline; }
.stk-yeni-ted { white-space: nowrap; }

/* ------------------------------------------------------------------ HIZLI HAREKET MENÜSÜ (gövdeye sabit konumlu) */
.stk-menu {
  position: fixed; z-index: 1200; min-width: 250px; padding: 6px; display: flex; flex-direction: column; gap: 2px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.stk-menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 8px 10px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.stk-menu-item:hover, .stk-menu-item:focus-visible { background: var(--hover-bg); outline: none; }
.stk-menu-ikon {
  width: 34px; height: 34px; border-radius: var(--radius-sm); background: var(--tone-soft); color: var(--tone);
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.stk-menu-item.tone-orange .stk-menu-ikon { color: var(--tone-orange-ink); }
.stk-menu-ikon svg { width: 18px; height: 18px; }
.stk-menu-text { display: flex; flex-direction: column; min-width: 0; }
.stk-menu-text b { font-size: 14px; font-weight: 600; color: var(--heading); }
.stk-menu-text small { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------ FORMLAR (modal) */
.modal.stk-modal { max-width: 640px; }
.stk-form-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stk-form .field-label { white-space: nowrap; }
.stk-form-hata { margin: 14px 0 0; }
.stk-not-kutu { margin-bottom: 14px; }
.stk-ipucu { margin-top: 5px; font-size: 12.5px; line-height: 1.4; color: var(--muted); font-weight: 400; }
.stk-ipucu.hata { color: var(--danger); font-weight: 600; }
.stk-ipucu.uyari { color: var(--tone-orange-ink); font-weight: 600; }
.stk-ipucu.ok { color: var(--primary-d); font-weight: 600; }
.stk-kullanim { margin-top: 12px; }

/* Hareket türü seçici (segmented): etkin düğme kendi tonunda */
.stk-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.stk-seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel); color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.stk-seg-btn:hover { background: var(--surface-2); color: var(--ink); }
.stk-seg-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.stk-seg-btn.aktif { background: var(--tone-soft); border-color: var(--tone); color: var(--tone); box-shadow: inset 0 0 0 1px var(--tone); }
.stk-seg-btn.tone-orange.aktif { color: var(--tone-orange-ink); }

/* Seçili kalem bilgi şeridi */
.stk-bilgi {
  display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; padding: 9px 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; color: var(--muted);
}
.stk-bilgi b { color: var(--heading); font-weight: 600; }

/* Birim son ekli sayı kutusu */
.stk-birimli { position: relative; display: flex; align-items: center; }
.stk-birimli .input { padding-right: 64px; }
.stk-birim { position: absolute; right: 12px; max-width: 52px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 13px; pointer-events: none; }

/* Aranabilir seçim (combobox): liste satır içi açılır, modalda kırpılmaz */
.stk-combo { position: relative; }
.stk-combo-input { padding-right: 34px; }
.stk-combo-ok { position: absolute; right: 12px; top: 0; height: 40px; display: inline-flex; align-items: center; color: var(--muted); pointer-events: none; }
.stk-combo-ok svg { width: 14px; height: 14px; }
.stk-combo-list {
  margin-top: 4px; max-height: 232px; overflow-y: auto; padding: 4px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.stk-combo-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 40px; padding: 7px 10px;
  border: 0; border-radius: 6px; background: none; color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.stk-combo-opt:hover, .stk-combo-opt.aktif { background: var(--hover-bg); }
.stk-combo-opt.secili { color: var(--primary-d); font-weight: 600; }
.stk-combo-opt.bos { color: var(--muted); font-style: italic; }
.stk-combo-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.stk-combo-sub { flex: 0 0 auto; font-size: 12px; color: var(--muted); font-weight: 400; white-space: nowrap; }
.stk-combo-bos { padding: 10px; font-size: 13px; color: var(--muted); }

/* Tedarikçi formu: aktif onay kutusu */
.stk-aktif-sec { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; align-self: end; }
.stk-aktif-sec input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); flex: 0 0 auto; }
.stk-aktif-sec b { display: block; font-size: 14px; color: var(--heading); }
.stk-aktif-sec small { display: block; font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------ TABLET */
@media (max-width: 1180px) {
  .stk-hareket-toolbar .stk-f-kalem, .stk-hareket-toolbar .stk-f-wo { width: 190px; }
}

/* ------------------------------------------------------------------ TELEFON (≤ 640 px; dokunma hedefi ≥ 44 px) */
@media (max-width: 640px) {
  .stk-kpis { grid-template-columns: 1fr 1fr; }
  .stk-kpis > :last-child { grid-column: 1 / -1; }
  .stk-tabs { padding: 0 6px; }
  .stk-tabs .tab { padding-left: 10px; padding-right: 10px; }
  .stk-govde { padding: 12px; }
  .stk-toolbar { gap: 8px; }
  .stk-toolbar .search-box { flex: 1 1 100%; max-width: none; }
  .stk-toolbar .stk-kategori { flex: 1 1 100%; }
  .stk-toolbar .toolbar-spacer { display: none; }
  .stk-chips { flex: 1 1 100%; }
  .stk-chip { flex: 1 1 0; justify-content: center; min-height: 44px; }
  .stk-sayi { flex: 1 1 100%; }
  .stk-hareket-toolbar .stk-f-kalem, .stk-hareket-toolbar .stk-f-wo { width: auto; flex: 1 1 100%; }
  .stk-hareket-toolbar .stk-f-tur { width: auto; flex: 1 1 100%; }
  .stk-tarih-aralik { flex: 1 1 100%; }
  .stk-tarih-aralik .stk-f-tarih { flex: 1 1 0; width: auto; }
  .stk-temizle { flex: 1 1 100%; }
  .stk-yeni-ted { flex: 1 1 100%; justify-content: center; }

  /* Kalem tablosu: Kod sütunu Ad hücresinin altına iner, Ad sütunu yatay kaydırmada sabit kalır */
  .stk-kalem-tablo .stk-col-kod { display: none; }
  .stk-alt-kod { display: block; }
  .stk-table .stk-col-ad { position: sticky; left: 0; z-index: 1; background: var(--panel); box-shadow: 1px 0 0 var(--line); min-width: 140px; max-width: 180px; }
  .stk-table thead .stk-col-ad { background: var(--surface-2); z-index: 2; }
  .data-table tr.stk-row-pasif td.stk-col-ad { background: var(--surface-2); }
  .data-table tr.stk-row-kritik td.stk-col-ad { box-shadow: inset 3px 0 0 var(--danger), 1px 0 0 var(--line); }
  .stk-table td.stk-col-ad { white-space: normal; }
  .stk-islemler { gap: 8px; }
  .stk-menu { min-width: 0; left: 12px !important; right: 12px; }
  .stk-menu-item { min-height: 52px; }
  .stk-combo-opt { min-height: 44px; }
  .stk-combo-ok { height: 44px; }
  .stk-seg-btn { padding: 8px 6px; font-size: 13.5px; gap: 6px; }
  .stk-form .field-label { white-space: normal; }
  /* Alt sayfa (bottom sheet) modalda yapışkan düğme şeridi gövdenin alt dolgusunu da örtsün (altından içerik görünmesin) */
  .stk-modal .modal-actions { bottom: -12px; padding-bottom: 12px; }
}

@media (max-width: 420px) {
  .stk-tabs .tab-count { display: none; }
}

/* Dokunmatik ekran: her genişlikte ≥ 44 px hedef */
@media (pointer: coarse) {
  .stk-chip, .stk-combo-opt, .stk-seg-btn, .stk-menu-item { min-height: 44px; }
  .stk-kalem-link { min-height: 44px; justify-content: center; }
  .stk-combo-ok { height: 44px; }
}
