/* Yeni görünüm — tema.php ekler, sadece <html data-tema="yeni"> iken çalışır.
   Kurallar çoğunlukla :where() ile düşük öncelikli: sayfanın sınıf bazlı renkleri (ödendi, iptal vb.)
   ve satır içi style="" değerleri korunur; sadece genel görünüm (yazı, kart, tablo, buton, form) toparlanır. */

:root[data-tema="yeni"] {
  --t-bg: #f3f5f9;
  --t-kart: #ffffff;
  --t-cizgi: #e4e8ef;
  --t-cizgi-koyu: #cfd6e1;
  --t-yazi: #1e293b;
  --t-soluk: #64748b;
  --t-ana: #2563eb;
  --t-ana-koyu: #1d4ed8;
  --t-ana-acik: #eaf1ff;
  --t-kirmizi: #dc2626;
  --t-kirmizi-koyu: #b91c1c;
  --t-yesil: #16a34a;
  --t-koyu: #0f172a;
  --t-golge: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --t-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ---------- Sayfa ---------- */
:where([data-tema="yeni"]) body {
  background: var(--t-bg);
  color: var(--t-yazi);
  font-family: var(--t-font);
  -webkit-font-smoothing: antialiased;
}
:where([data-tema="yeni"]) :is(button, input, select, textarea) { font-family: var(--t-font); }

:where([data-tema="yeni"]) :is(h1, h2, h3) {
  color: var(--t-yazi);
  text-shadow: none;
  letter-spacing: -.01em;
  font-weight: 700;
}
:where([data-tema="yeni"]) h1 { font-size: clamp(20px, 2.4vw, 26px); }
:where([data-tema="yeni"]) h2 { font-size: clamp(18px, 2vw, 22px); }
:where([data-tema="yeni"]) h3 { font-size: 17px; }

[data-tema="yeni"] ::selection { background: rgba(37, 99, 235, .18); }
:where([data-tema="yeni"]) a { -webkit-tap-highlight-color: transparent; }
:where([data-tema="yeni"]) :is(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--t-ana);
  outline-offset: 2px;
}
/* Sayfaların uzun açılış animasyonları kısalsın */
[data-tema="yeni"] :where(.container, .box, .card, form) { animation-duration: .35s !important; }
@media (prefers-reduced-motion: reduce) {
  [data-tema="yeni"] * { animation: none !important; transition: none !important; }
}

/* Kartlar */
:where([data-tema="yeni"]) :is(.container, .box, .card) {
  background: var(--t-kart);
  border: 1px solid var(--t-cizgi);
  border-radius: 16px;
  box-shadow: var(--t-golge);
  box-sizing: border-box;
  max-width: 100%;
}
:where([data-tema="yeni"]) :is(.container, .box, .card) > :is(h1, h2):first-child { margin-top: 0; }
:where([data-tema="yeni"]) .table-container { border-radius: 12px; }
[data-tema="yeni"] :where(.main-content) { box-sizing: border-box; max-width: 100%; }

/* ---------- Üst menü (header.php) ---------- */
[data-tema="yeni"] .custom-header {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 1240px;
  height: auto;
  min-height: 48px;
  box-sizing: border-box;
  margin: 0;
  padding: 6px 10px 6px 18px;
  background: var(--t-koyu);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, .18);
  font-family: var(--t-font);
  font-size: 13px;
  color: #94a3b8;
  gap: 16px;
}
[data-tema="yeni"] .custom-logo .logo-link {
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .08em;
  padding: 4px 6px;
  border-radius: 8px;
}
[data-tema="yeni"] .custom-logo .logo-link:hover { background: none; box-shadow: none; }
[data-tema="yeni"] .custom-nav-menu ul { gap: 2px; }
[data-tema="yeni"] .custom-menu-item > a,
[data-tema="yeni"] .custom-menu-item:nth-child(n) > a {
  display: block;
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 9px;
}
[data-tema="yeni"] .custom-menu-item > a:hover,
[data-tema="yeni"] .custom-menu-item:hover > a {
  background: rgba(255, 255, 255, .1);
  color: #fff;
  box-shadow: none;
}
[data-tema="yeni"] .custom-menu-item:last-child > a { color: #fca5a5; }
[data-tema="yeni"] .custom-menu-item ul {
  top: 100%;
  margin-top: 0;
  padding: 6px;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--t-cizgi);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
}
/* Menü ile alt menü arasındaki boşlukta menü kapanmasın */
[data-tema="yeni"] .custom-menu-item ul::before {
  content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px;
}
[data-tema="yeni"] .custom-menu-item ul li a {
  color: var(--t-yazi);
  font-size: 14px;
  padding: 9px 12px;
  border-radius: 8px;
}
[data-tema="yeni"] .custom-menu-item ul li a:hover { background: var(--t-ana-acik); color: var(--t-ana-koyu); }
[data-tema="yeni"] .custom-main-content { display: none; }
/* Sabit menünün altında içerik için yer aç (telefonda menü gizli) */
@media (min-width: 769px) {
  [data-tema="yeni"] body:has(.custom-header) { padding-top: 78px; }
}

/* ---------- Tablolar ----------
   tema.js her tabloyu .t-kaydir kutusuna alır: geniş tablo sayfayı taşırmaz, kendi içinde yana kayar. */
:where([data-tema="yeni"]) table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
  background: var(--t-kart);
  border: 1px solid var(--t-cizgi);
  border-radius: 12px;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
[data-tema="yeni"] .t-kaydir {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin: 16px 0;
  background: var(--t-kart);
  border: 1px solid var(--t-cizgi);
  border-radius: 12px;
  scrollbar-width: thin;
}
[data-tema="yeni"] .t-kaydir > table {
  margin: 0 !important;
  border: 0;
  border-radius: 0;
  overflow: visible;
}
:where([data-tema="yeni"]) table :is(th, td) {
  border: 0 !important;
  border-bottom: 1px solid var(--t-cizgi) !important;
  padding: 10px 12px !important;
  font-size: 13.5px !important;
  line-height: 1.35;
  vertical-align: middle;
  color: var(--t-yazi);
}
:where([data-tema="yeni"]) table tr th,
:where([data-tema="yeni"]) table thead tr td {
  background: #f8fafc;
  color: var(--t-soluk);
  font-weight: 600;
  font-size: 12.5px !important;
  text-align: left;
}
:where([data-tema="yeni"]) table tr td { background: var(--t-kart); }
:where([data-tema="yeni"]) table tbody tr:nth-child(even) td { background: #fafbfd; }
:where([data-tema="yeni"]) table tbody tr:hover td { background: var(--t-ana-acik); }
:where([data-tema="yeni"]) table tr:last-child :is(td, th) { border-bottom: 0 !important; }

/* ---------- Butonlar ----------
   Öncelik: temel [data-tema] (sayfanın .button kuralını geçer) < çeşitler :root[data-tema] (ikincil, tehlikeli). */
[data-tema="yeni"] :where(button, input[type="submit"], input[type="button"], .button, .btn, .remove-button,
  .back-button, .geri-don-btn, .geri-butonu, .list-button, .logout-button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  height: auto;
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--t-ana);
  color: #fff;
  font: 600 14px/1.2 var(--t-font);
  text-decoration: none;
  text-align: center;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
[data-tema="yeni"] :where(button, input[type="submit"], input[type="button"], .button, .btn, .remove-button):hover {
  background: var(--t-ana-koyu);
  color: #fff;
}
[data-tema="yeni"] :where(button, input[type="submit"], input[type="button"], .button, .btn, .remove-button):active { transform: translateY(1px); }

/* İkincil: geri dön / vazgeç */
:root[data-tema="yeni"] :where(.back-button, .geri-don-btn, .geri-butonu, .list-button, .btn-secondary, .btn-outline-secondary, .btn-light) {
  background: #fff;
  color: var(--t-yazi);
  border-color: var(--t-cizgi-koyu);
}
:root[data-tema="yeni"] :where(.back-button, .geri-don-btn, .geri-butonu, .list-button, .btn-secondary, .btn-outline-secondary, .btn-light):hover {
  background: #f1f5f9;
  color: var(--t-yazi);
}
:root[data-tema="yeni"] :where(.geri-don-btn) { display: flex; margin-left: auto; margin-right: auto; }

/* Tehlikeli: sil / çıkış / eşleşme kaldır */
:root[data-tema="yeni"] :where(.btn-danger, .logout-button, .unlink-btn, .remove-row,
  a:is(.button, .btn, .remove-button):is([href*="delete"], [href*="_sil"], [href*="sil."], [href*="sil?"], [href*="sill"])) {
  background: #fff;
  color: var(--t-kirmizi);
  border-color: #fecaca;
}
:root[data-tema="yeni"] :where(.btn-danger, .logout-button, .unlink-btn, .remove-row,
  a:is(.button, .btn, .remove-button):is([href*="delete"], [href*="_sil"], [href*="sil."], [href*="sil?"], [href*="sill"])):hover {
  background: var(--t-kirmizi);
  color: #fff;
  border-color: var(--t-kirmizi);
}
:root[data-tema="yeni"] :where(.btn-success) { background: var(--t-yesil); }

/* Küçük butonlar (tablo içi) */
[data-tema="yeni"] table :where(button, .button, .btn, .remove-button) {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}
[data-tema="yeni"] :where(.btn-sm) { min-height: 30px; padding: 5px 10px; font-size: 13px; }
[data-tema="yeni"] :where(button, .btn, .button):disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Formlar ---------- */
:where([data-tema="yeni"]) :is(input[type="text"], input[type="number"], input[type="date"], input[type="datetime-local"],
  input[type="search"], input[type="tel"], input[type="email"], input[type="password"], input:not([type]), select, textarea, .form-control) {
  box-sizing: border-box;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--t-cizgi-koyu);
  border-radius: 10px;
  background: #fff;
  color: var(--t-yazi);
  font-size: 15px;
  box-shadow: none;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
:where([data-tema="yeni"]) textarea { min-height: 80px; }
:where([data-tema="yeni"]) :is(input, select, textarea, .form-control):focus {
  border-color: var(--t-ana);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
}
:where([data-tema="yeni"]) :is(input, textarea)::placeholder { color: #94a3b8; }
:where([data-tema="yeni"]) :is(label, .form-label, .lbll) { color: #334155; font-weight: 600; font-size: 14px; }
:where([data-tema="yeni"]) input[type="checkbox"], :where([data-tema="yeni"]) input[type="radio"] {
  accent-color: var(--t-ana); width: 17px; height: 17px;
}

/* Otomatik tamamlama listeleri */
:where([data-tema="yeni"]) :is(.autocomplete-list, .autocomplete-items, .suggestions) {
  background: #fff;
  border: 1px solid var(--t-cizgi);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .14);
  overflow: hidden;
}
:where([data-tema="yeni"]) .autocomplete-item { padding: 10px 12px; border-bottom: 1px solid var(--t-cizgi); }
:where([data-tema="yeni"]) .autocomplete-item:hover { background: var(--t-ana-acik); }

/* Sayfalama */
[data-tema="yeni"] .pagination a, [data-tema="yeni"] .pagination span {
  border-radius: 8px;
  border: 1px solid var(--t-cizgi);
  background: #fff;
  color: var(--t-yazi);
  padding: 6px 11px;
  text-decoration: none;
  font-size: 14px;
}
[data-tema="yeni"] .pagination :is(.active, .current) { background: var(--t-ana); border-color: var(--t-ana); color: #fff; }

/* Mesajlar */
:where([data-tema="yeni"]) .message { border-radius: 10px; }

/* Köşeye sabitlenmiş "Geri Dön" (rapor vb.) içeriğin üstüne binmesin */
[data-tema="yeni"] body:has(> .back-button) { padding-top: 64px; }
:root[data-tema="yeni"] body > .back-button { box-shadow: 0 4px 14px rgba(15, 23, 42, .12); z-index: 900; }

/* Hesabım rozeti (müşteri listesi, ön sipariş) */
[data-tema="yeni"] .hesabim-badge { border-radius: 999px; padding: 2px 9px; }
[data-tema="yeni"] .hesabim-tick { font-size: 12px; margin-left: 4px; }

/* ---------- Ön sipariş ---------- */
[data-tema="yeni"] .container:has(#orderTableBody) { max-width: 1180px; }
[data-tema="yeni"] #orderTableBody td { max-width: none !important; }
[data-tema="yeni"] #orderTableBody td.button-cell { white-space: nowrap; }
[data-tema="yeni"] #orderTableBody tr:last-child td { background: #f8fafc; font-weight: 600; }

/* ---------- Telefon ---------- */
@media (max-width: 768px) {
  :where([data-tema="yeni"]) body { padding-left: 12px; padding-right: 12px; }
  :where([data-tema="yeni"]) :is(.container, .box, .card) { border-radius: 14px; padding: 18px 16px; }
  /* Tablolar telefonda kendi içinde kayar: satırlar tek satır, sütun genişliği içeriğe göre */
  [data-tema="yeni"] .t-kaydir { margin: 12px 0; border-radius: 12px; }
  [data-tema="yeni"] .t-kaydir > table { width: 100% !important; min-width: 100%; }
  [data-tema="yeni"] .t-kaydir > table :is(th, td) {
    white-space: nowrap;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
  }
  [data-tema="yeni"] .t-kaydir > table td :is(button, .button, .btn) { white-space: nowrap; }
  /* Kutular ekrandan taşmasın (genişlik + iç boşluk) */
  [data-tema="yeni"] :where(body > div, body > form, body > main, form, .main-content, .container, .box, .table-container) {
    box-sizing: border-box;
    max-width: 100%;
  }
  /* Satış formlarında sabit genişlikli ürün satırları / toplam kutuları ekrana sığsın */
  [data-tema="yeni"] :where(#product-container, .form-group, .totals, .product-row, .balance-container) {
    box-sizing: border-box;
    max-width: 100%;
  }
  [data-tema="yeni"] :where(#product-container, .product-row) { flex-wrap: wrap; }
  /* Yan yana buton grupları alt satıra geçebilsin */
  [data-tema="yeni"] :where(div, form, nav):has(> :is(button, .button, .btn, a.btn) + :is(button, .button, .btn, a.btn)) {
    flex-wrap: wrap;
  }
  /* Dokunmatik: rahat basılan butonlar */
  [data-tema="yeni"] :where(button, input[type="submit"], .button, .btn) { min-height: 42px; }
  :where([data-tema="yeni"]) table :is(th, td) { padding: 8px 9px !important; font-size: 12.5px !important; }
  :where([data-tema="yeni"]) table tr th { font-size: 11.5px !important; }
  [data-tema="yeni"] table :where(button, .button, .btn, .remove-button) {
    min-height: 30px; padding: 5px 9px; font-size: 12px;
  }
  /* 16px: iPhone'da yazı kutusuna dokununca sayfa büyümesin */
  :where([data-tema="yeni"]) :is(input[type="text"], input[type="number"], input[type="search"], input[type="tel"],
    input[type="email"], input[type="password"], input:not([type]), select, textarea) { font-size: 16px; }
}

@media print {
  [data-tema="yeni"] .custom-header { display: none; }
  :where([data-tema="yeni"]) :is(.container, .box, .card, table) { box-shadow: none; }
}
