/* ==========================================================================
   OkulKitap — Frontend Tasarım Sistemi v2
   Palet, tipografi ve yeniden kullanılabilir bileşenler.
   Kaynak: "OkulKitap Frontend Designs" (Claude Design) — birebir.
   ========================================================================== */

:root {
  /* Ana palet */
  --indigo: #4f46e5;
  --indigo-hover: #6d5efb;
  --violet: #7c3aed;
  --teal: #0d9488;
  --cyan: #0891b2;
  --amber: #d97706;
  --rose: #e11d48;

  /* Nötrler & yüzey */
  --ink: #171a21;          /* birincil metin */
  --fg: var(--ink);        /* birincil metin diğer adı (bazı sayfalar bunu kullanır) */
  --muted: #5b6172;        /* ikincil metin */
  --muted-2: #6b7180;
  --muted-3: #8a90a0;
  --muted-4: #9aa0b0;
  --line: #e7e9f0;         /* kenarlık */
  --line-2: #eceef5;       /* açık ayraç / arka plan */
  --surface: #ffffff;
  --surface-1: var(--surface);   /* yükseltilmiş yüzey (kart/modal) — opak beyaz */
  --surface-2: #f6f7fb;
  --surface-3: #fafbfd;
  --bg: #eceef5;

  /* Renkli yumuşak zeminler (kategori/durum) */
  --tint-indigo: #eef0ff;
  --tint-violet: #f1ebff;
  --tint-teal: #ecfdf9;
  --tint-amber: #fef3e7;
  --tint-rose: #fdeaf0;

  /* Yüzey */
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 20px;
  --shadow-sm: 0 4px 24px rgba(23, 26, 45, .05);
  --shadow-md: 0 8px 22px rgba(79, 70, 229, .28);
  --shadow-lg: 0 24px 70px rgba(23, 26, 45, .12);

  --font-sans: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--indigo); text-decoration: none; }
a:hover { color: var(--indigo-hover); }

h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: #cfd3e0; border-radius: 8px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: var(--bg); }

svg.lucide { stroke-width: 2; flex-shrink: 0; }

/* ---- Yerleşim ------------------------------------------------------------ */
.container { max-width: 1200px; margin: 0 auto; padding: 0 30px; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.spread { display: flex; align-items: center; justify-content: space-between; }

/* ---- Butonlar ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 12px;
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background .15s, box-shadow .15s, border-color .15s;
}
.btn-primary { background: var(--indigo); color: #fff; box-shadow: 0 6px 16px rgba(79, 70, 229, .25); }
.btn-primary:hover { background: var(--indigo-hover); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: #d3d7e3; color: var(--ink); }
.btn-soft { background: var(--surface-2); border-color: var(--line); color: var(--muted); }
.btn-soft:hover { color: var(--ink); }
.btn-block { width: 100%; }
.btn-lg { height: 50px; font-size: 15px; padding: 0 24px; }

/* ---- Rozetler & çipler --------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; line-height: 1;
}
.badge-indigo { background: var(--tint-indigo); color: var(--indigo); }
.badge-violet { background: var(--tint-violet); color: var(--violet); }
.badge-teal   { background: var(--tint-teal);   color: var(--teal); }
.badge-amber  { background: var(--tint-amber);  color: var(--amber); }
.badge-rose   { background: var(--tint-rose);   color: var(--rose); }
.badge-soft   { background: var(--surface-2);   color: var(--muted); }

.badge-solid-indigo { background: var(--indigo); color: #fff; }
.badge-solid-amber  { background: var(--amber);  color: #fff; }
.badge-solid-rose   { background: var(--rose);   color: #fff; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px;
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.chip .lucide { width: 13px; height: 13px; }
.chip-clear { color: var(--muted-3); font-weight: 500; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 12px; font-weight: 600; font-size: 13.5px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.pill-active { background: var(--indigo); color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(79, 70, 229, .28); }

/* ---- Kartlar ------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
/* Panel = veri-tablosu sarmalayıcısı. Dar alanda ızgara taşarsa panel YATAY KAYDIRIR
   (butonlar/hücreler panel dışına taşmaz/kırpılmaz); geniş ekranda normal görünür.
   ÖNEMLİ: sayfalarda panel'e inline `overflow:hidden` VERME — kaydırmayı öldürür, sağ sütun kırpılır. */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
/* Admin ızgara tabloları: kolonlar OTOMATİK genişlesin, içerik taşmasın.
   - Hücrelere `min-width:0` → grid item'ın varsayılan `min-width:auto` davranışı uzun
     e-posta/mono metinle kolonu şişirip satırı sayfa dışına taşırıyordu; bu engellenir.
   - Uzun metin `…` ile kırpılır (tek satır), böylece kolon içeriğe göre büzülür.
   - Taban genişlik yalnız geniş ekranda uygulanır; dar ekranda kolonlar otomatik sığar,
     gerçekten sığmazsa `.panel` yatay kaydırır (içerik panel dışına taşmaz). */
.admin-shell .panel > div[style*="grid-template-columns"] { min-width: 0; column-gap: 0; }
.admin-shell .panel > div[style*="grid-template-columns"] > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Buton/aksiyon hücreleri kırpılmasın (İşlem sütunu vb.). */
.admin-shell .panel > div[style*="grid-template-columns"] > *:has(> .btn),
.admin-shell .panel > div[style*="grid-template-columns"] > *:has(> a),
.admin-shell .panel > div[style*="grid-template-columns"] > *:has(> button) { overflow: visible; }
@media (min-width: 1120px) {
  .admin-shell .panel > div[style*="grid-template-columns"] { min-width: 760px; }
}
/* İşlem (aksiyon) sütunu = her ızgara satırının SON hücresi. Panel gerçekten sığmayıp yatay
   kayarsa bu sütun sağda sabit kalır → Sil/Düzenle butonları hiçbir genişlikte kırpılmaz.
   Sabit hücrenin altından kayan içerik görünmesin diye satıra arkaplan verilir: başlık satırı
   inline `surface-2` (inline stil kazanır), gövde satırları buradaki `surface`. Sabit hücre bu
   arkaplanı `inherit` ile devralır. Yatay taşma yoksa sticky hücre yerinde durur (görsel etki yok). */
.admin-shell .panel > div[style*="grid-template-columns"] { background: var(--surface); }
.admin-shell .panel > div[style*="grid-template-columns"] > *:last-child {
  position: sticky; right: 0; background: inherit; z-index: 2;
}

/* ---- Modal (paylaşılan) — sabit header/footer, yalnız gövde kaydırılır ------
   Yapı: .ok-modal (backdrop) > .ok-modal-card[.sm/.md/.lg/.xl] > .ok-modal-head + .ok-modal-body + .ok-modal-foot
   Kart flex-column + max-height; head/foot flex-shrink:0 (sabit), body flex:1 + overflow-y:auto (kayar). */
.ok-modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 8000; display: flex; align-items: center; justify-content: center; padding: 24px; }
.ok-modal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 64px rgba(0,0,0,.28); width: 100%; max-width: 480px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.ok-modal-card.sm { max-width: 400px; }
.ok-modal-card.md { max-width: 560px; }
.ok-modal-card.lg { max-width: 680px; }
.ok-modal-card.xl { max-width: 980px; }
.ok-modal-head { flex: 0 0 auto; padding: 18px 24px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ok-modal-head h3 { font-size: 16px; font-weight: 700; margin: 0; color: var(--ink); }
.ok-modal-body { flex: 1 1 auto; overflow-y: auto; padding: 20px 24px; }
.ok-modal-foot { flex: 0 0 auto; padding: 14px 24px; border-top: 1px solid var(--line-2); display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.section-title { font-size: 18px; font-weight: 700; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; color: var(--muted-3); letter-spacing: .02em; }
.see-all { font-size: 13px; color: var(--indigo); display: flex; align-items: center; gap: 5px; }
.see-all .lucide { width: 15px; height: 15px; }

/* ---- Ürün kartı ---------------------------------------------------------- */
.product-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; transition: box-shadow .15s, transform .15s; }
.product-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.product-cover {
  position: relative; aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(135deg, #eef0f6 0, #eef0f6 10px, #f6f7fb 10px, #f6f7fb 20px);
}
.product-cover .ph { font-family: var(--font-mono); font-size: 10px; color: #b8bcca; }
.product-cover .flag { position: absolute; top: 10px; left: 10px; color: #fff; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 20px; }
.product-body { padding: 12px; }
.product-pub { font-family: var(--font-mono); font-size: 9.5px; color: var(--muted-3); margin-bottom: 5px; text-transform: uppercase; }
.product-name { font-size: 13px; line-height: 1.35; margin-bottom: 8px; height: 36px; overflow: hidden; color: var(--ink); display: block; }
.product-price { font-size: 15px; font-weight: 700; }
.price-old { font-family: var(--font-mono); font-size: 11px; color: var(--muted-4); text-decoration: line-through; }

/* ---- Storefront kabuğu (nav + kategori çubuğu) --------------------------- */
.sf-nav {
  height: 66px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center;
  gap: 28px; padding: 0 30px; background: #fff; position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; letter-spacing: -0.02em; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand .mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--indigo), var(--violet)); display: flex; align-items: center; justify-content: center; }
.brand .mark .lucide { width: 16px; height: 16px; color: #fff; }
.brand .k { color: var(--indigo); }

.search-box {
  flex: 1; max-width: 460px; height: 42px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; display: flex; align-items: center; padding: 0 14px; gap: 9px; color: var(--muted-4); font-size: 13.5px;
}
.search-box input { border: none; background: transparent; outline: none; flex: 1; font-family: var(--font-sans); font-size: 13.5px; color: var(--ink); }
.search-box input::placeholder { color: var(--muted-4); }

.sf-nav-actions { margin-left: auto; display: flex; align-items: center; gap: 20px; font-size: 13.5px; color: var(--muted); }
.sf-nav-actions a { color: var(--muted); display: flex; align-items: center; gap: 7px; position: relative; }
.sf-nav-actions a:hover { color: var(--ink); }
.sf-nav-actions .wallet { color: var(--teal); font-weight: 600; }
.sf-nav-actions .wallet:hover { color: var(--teal); }
.cart-count { background: var(--indigo); color: #fff; font-family: var(--font-mono); font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 20px; }

.sf-cats {
  height: 48px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center;
  padding: 0 30px; gap: 22px; font-size: 13px; color: var(--muted); background: var(--surface-3);
  overflow-x: auto; scrollbar-width: none;
}
.sf-cats::-webkit-scrollbar { display: none; }
.sf-cats a { color: var(--muted); white-space: nowrap; }
.sf-cats a:hover { color: var(--ink); }
.sf-cats a.all { font-weight: 600; color: var(--indigo); display: flex; align-items: center; gap: 7px; }
.sf-cats a.active { font-weight: 600; color: var(--ink); }
.sf-cats a.promo { margin-left: auto; color: var(--rose); font-weight: 600; display: flex; align-items: center; gap: 6px; }

.sf-footer { border-top: 1px solid var(--line); background: #fff; margin-top: 60px; padding: 40px 0; color: var(--muted); font-size: 13px; }

/* ---- Breadcrumb ---------------------------------------------------------- */
.crumb { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-4); }

/* ---- Genel yardımcılar --------------------------------------------------- */
.grid { display: grid; gap: 16px; }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.icon-tile { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }

/* Blazor hata arayüzü */
#blazor-error-ui {
  color-scheme: light only;
  background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
  display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

@media (max-width: 980px) {
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .container { padding: 0 18px; }
}

/* Barkod (Code 128 satır-içi SVG) — bulunduğu kutuya sığsın. */
.ok-barcode { display: inline-block; max-width: 100%; }
.ok-barcode svg { max-width: 100%; height: auto; display: block; }

/* ---- Admin kenar çubuğu: gruplu + açılır/kapanır menü (native <details>) --------------
   Render mode gerektirmez: <details>/<summary> tarayıcıda kendiliğinden açılıp kapanır, bu yüzden
   statik SSR admin sayfalarında da çalışır. Aktif sayfayı içeren grup `open` ile açık gelir. */
.admin-navgroup { border: none; }
.admin-navgroup-sum {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; cursor: pointer;
  color: var(--ink); font-weight: 600; list-style: none;
  user-select: none;
}
/* Varsayılan disclosure üçgenini gizle (chevron kendimiz koyuyoruz). */
.admin-navgroup-sum::-webkit-details-marker { display: none; }
.admin-navgroup-sum::marker { content: ""; }
.admin-navgroup-sum:hover { background: var(--tint-indigo); }
/* Chevron: kapalıyken sağa değil aşağı bakar; açıkken 180° döner. Yumuşak geçiş. */
.admin-navgroup-chev { transition: transform .18s ease; color: var(--muted); }
.admin-navgroup[open] > .admin-navgroup-sum > .admin-navgroup-chev { transform: rotate(180deg); }

/* ==========================================================================
   RESPONSIVE — telefon & tablet uyumu (viewport meta App.razor'da mevcut).
   Sınıf-tabanlı chrome (nav/cats/footer/admin kabuğu) media query ile uyarlanır.
   Sepet/ödeme gibi sayfalar zaten flex-wrap + min-width ile doğal yığılır.
   ========================================================================== */

/* ---- Tablet ve altı (≤900px) ---- */
@media (max-width: 900px) {
  .sf-nav { gap: 14px; padding: 0 16px; }
  .sf-nav-actions { gap: 14px; }
  .sf-cats { padding: 0 16px; gap: 18px; }

  /* Admin kabuğu: 220px sabit kenar çubuğu üstte tam-genişlik şeride döner (sticky + tam yükseklik
     kalkar). Menü grupları <details> ile zaten kapalı gelir → dikeyde kompakt. İçerik altta akar.
     Inline taban stilleri geçersiz kılmak için !important şart. */
  .admin-shell { flex-direction: column; }
  .admin-aside {
    width: auto !important; height: auto !important; position: static !important;
    border-right: none !important; border-bottom: 1px solid var(--line-2);
    padding: 10px 0 !important;
  }
  .admin-topbar { padding: 0 16px !important; }
  .admin-content { padding: 18px 16px !important; }

  /* Ürün detay: galeri (sabit 320px) + bilgi iki-kolon düzeni tablette sıkışıp taşıyordu →
     alt alta yığ; galeri tam genişlik, ortalı (inline 320px'i geçersiz kıl). */
  .pd-split { flex-direction: column; gap: 24px; }
  .pd-media { width: 100% !important; max-width: 420px; margin: 0 auto; }
}

/* ---- Telefon (≤560px) ---- */
@media (max-width: 560px) {
  .container { padding: 0 14px; }

  /* Üst gezinme sarar: marka + aksiyonlar ilk satır, arama kutusu tam genişlik ikinci satıra iner. */
  .sf-nav { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .search-box { order: 3; flex-basis: 100%; max-width: none; }
  .sf-nav-actions { margin-left: auto; gap: 18px; }
  /* Kullanıcı adı metnini gizle (ikon kalır) — yer açar; sepet sayacı rozetine (.cart-count) dokunma. */
  .sf-nav-actions a span:not(.cart-count) { display: none; }

  .sf-cats { padding: 0 14px; gap: 16px; height: 44px; }

  /* Ürün ızgaraları telefonda 2 / 1 sütun. */
  .grid { gap: 12px; }
  .grid-6, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }

  /* Ürün detay yan boşluğu telefonda daralsın (inline 30px'i geçersiz kıl). Yığılma ≤900px'te. */
  .pd-split { padding-left: 14px !important; padding-right: 14px !important; }

  .sf-footer { margin-top: 40px; padding: 28px 0; }
}

/* ---- Admin içerik ızgaraları (KPI/stat kartları) — tablet & telefon ----
   Sabit repeat(3/4,1fr) kart ızgaraları dar ekranda taşıyordu. VERİ TABLOLARINA dokunma:
   onlar .panel içinde ve yatay kaymalı (ayrı kural). :not(.panel *) panel-içi ızgaraları hariç tutar. */
@media (max-width: 720px) {
  .admin-content div[style*="grid-template-columns"]:not(.panel):not(.panel *) {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
}
@media (max-width: 430px) {
  .admin-content div[style*="grid-template-columns"]:not(.panel):not(.panel *) {
    grid-template-columns: 1fr !important;
  }
}
