:root { --sidebar-w: 248px; --sidebar-w-mini: 74px; }

body { background: #f4f6f9; }

/* ===== Sidebar (modern) ===== */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  min-height: 100vh;
  max-height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  /* tema_renk verilmemişse şık koyu degrade */
  background: linear-gradient(180deg, #0f172a 0%, #18233b 100%) !important;
  transition: width .2s ease, flex-basis .2s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sidebar::-webkit-scrollbar { width: 7px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.28); }

.sidebar-brand { font-size: 1.2rem; padding-bottom: .85rem; border-bottom: 1px solid rgba(255,255,255,.09); }

.sidebar .nav-link {
  display: flex; align-items: center; gap: .65rem;
  color: rgba(255,255,255,.74);
  border-radius: .55rem;
  padding: .52rem .7rem;
  font-size: .9rem; font-weight: 500;
  white-space: nowrap; overflow: hidden;
  position: relative;
  transition: background .14s, color .14s, padding .2s;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,.09); color: #fff; }
.sidebar .nav-link.active {
  background: rgba(255,255,255,.16);
  color: #fff; font-weight: 600;
  box-shadow: inset 3px 0 0 #fff;
}
.sidebar .nav-link i { width: 1.3rem; text-align: center; font-size: 1.02rem; flex: 0 0 auto; }

/* Açılır-kapanır grup başlığı */
.sidebar-grup-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: none; border: 0;
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
  color: rgba(255,255,255,.42); padding: .8rem .7rem .35rem; margin-top: .2rem;
  cursor: pointer; transition: color .14s;
}
.sidebar-grup-btn:hover { color: rgba(255,255,255,.75); }
.sidebar-grup-btn .chev { transition: transform .15s; font-size: .75rem; }
.sidebar-grup-btn[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.sidebar-baslik {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em;
  color: rgba(255,255,255,.42); padding: .8rem .7rem .25rem; margin-top: .2rem;
}

/* Grup başlığındaki ikon yalnız mini modda görünür (geniş modda metin başlık) */
.sidebar-grup-btn .grup-sol { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.sidebar-grup-btn .grup-ikon { display: none; font-size: 1.05rem; }
.sidebar-grup { position: relative; }

/* ===== Daraltılmış (mini) mod — sadece masaüstü ===== */
@media (min-width: 992px) {
  .sidebar-collapsed .sidebar { width: var(--sidebar-w-mini); flex-basis: var(--sidebar-w-mini); padding-left: .55rem !important; padding-right: .55rem !important; overflow: visible; }
  .sidebar-collapsed .sidebar-brand { font-size: 1.5rem; }
  .sidebar-collapsed .sidebar-brand .small,
  .sidebar-collapsed .sidebar-brand strong { display: none; }
  .sidebar-collapsed .sidebar-brand img { width: 44px !important; }

  /* Tek başına üst linkler (Panel) → yalnız ikon */
  .sidebar-collapsed .sidebar > ul .nav-link { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; font-size: 0; }
  .sidebar-collapsed .sidebar > ul .nav-link i { font-size: 1.2rem; width: 100%; }

  /* Grup başlıkları → yalnız ikon, ortalı */
  .sidebar-collapsed .sidebar-grup-btn { justify-content: center; padding: .62rem 0; margin-top: .15rem; border-radius: .55rem; }
  .sidebar-collapsed .sidebar-grup-btn:hover { background: rgba(255,255,255,.09); }
  .sidebar-collapsed .sidebar-grup-btn .grup-ad,
  .sidebar-collapsed .sidebar-grup-btn .chev { display: none; }
  .sidebar-collapsed .sidebar-grup-btn .grup-ikon { display: inline-block; font-size: 1.25rem; color: rgba(255,255,255,.82); }
  .sidebar-collapsed .sidebar-grup:hover .sidebar-grup-btn .grup-ikon { color: #fff; }

  /* Alt menü → varsayılan gizli; grup üstüne gelince sağda flyout */
  .sidebar-collapsed .sidebar-grup > .collapse {
    display: block !important; height: auto !important;
    position: absolute; left: 100%; top: -2px; margin-left: 10px;
    width: 232px; background: #1b2638; border: 1px solid rgba(255,255,255,.08);
    border-radius: 12px; padding: 8px; box-shadow: 0 14px 38px rgba(0,0,0,.4);
    opacity: 0; visibility: hidden; transform: translateX(-6px);
    transition: opacity .14s ease, transform .14s ease, visibility .14s;
    z-index: 1060; max-height: 86vh; overflow-y: auto;
  }
  /* fareyle ikon→flyout arası boşlukta kopmasın */
  .sidebar-collapsed .sidebar-grup > .collapse::before { content: ""; position: absolute; left: -12px; top: 0; width: 12px; height: 100%; }
  .sidebar-collapsed .sidebar-grup:hover > .collapse { opacity: 1; visibility: visible; transform: none; }
  /* flyout başlığı (grup adı) */
  .sidebar-collapsed .sidebar-grup > .collapse::after { }
  /* flyout içindeki linkler tam metinle */
  .sidebar-collapsed .sidebar-grup > .collapse .nav-link { font-size: .875rem; justify-content: flex-start; gap: .6rem; padding: .5rem .7rem; }
  .sidebar-collapsed .sidebar-grup > .collapse .nav-link i { font-size: 1rem; width: 1.25rem; }
}

.content { min-height: 100vh; min-width: 0; }  /* min-width:0 → geniş tablolar sidebar'ı kaplamaz, kendi içinde kayar */
.content main { min-width: 0; }
/* Chart.js canvas'ları konteynerini aşıp sidebar'ı kaplamasın */
canvas { max-width: 100% !important; }
.row > [class*="col"] { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; }

.stat-card { transition: transform .1s; }
.stat-card:hover { transform: translateY(-2px); }

/* Login / blank */
.blank-body { background: linear-gradient(135deg, #1e3c72, #2a5298); }
.login-wrap { min-height: 100vh; }
.login-card { width: 380px; max-width: 92vw; }

/* Döküman / wiring */
.wiring-diagram {
  background: #0d1117;
  color: #58d68d;
  padding: 1rem;
  border-radius: .5rem;
  font-size: .8rem;
  line-height: 1.3;
  overflow-x: auto;
}
.doc-section {
  border-left: 4px solid var(--bs-primary);
  padding-left: .5rem;
  margin-top: 1.25rem;
}
.pinout-table code { color: #d63384; }
.doc-steps li { margin-bottom: .35rem; }

/* Print / PDF */
@media print {
  .sidebar, .topbar, .d-print-none { display: none !important; }
  body, .blank-body { background: #fff !important; }
  .content, main { padding: 0 !important; }
  .doc-page { max-width: 100%; }
  .wiring-diagram { background: #f4f4f4; color: #111; border: 1px solid #ccc; }
  .card { border: none !important; }
  a[href]:after { content: ""; }
}

.doc-page { max-width: 820px; margin: 0 auto; }

/* Mobil: off-canvas sidebar + hamburger */
.sidebar-overlay { display: none; }
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 1045;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 2px 0 14px rgba(0,0,0,.35);
  }
  body.sidebar-open .sidebar { transform: none; }
  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1040;
  }
  body:not(.sidebar-open) .sidebar-overlay { display: none; }
  body.sidebar-open .sidebar-overlay { display: block; }
  .content main { padding: 1rem !important; }
  .topbar h5 { font-size: 1rem; max-width: 55vw; }
}

/* Puantaj */
.puantaj-wrap { overflow-x: auto; }
.puantaj { font-size: .8rem; }
.puantaj th, .puantaj td { vertical-align: middle; min-width: 30px; }
.puantaj .sticky-col {
  position: sticky; left: 0; z-index: 2;
  background: #fff; min-width: 150px; box-shadow: 1px 0 0 #dee2e6;
}
.puantaj thead .sticky-col { z-index: 3; background: #f8f9fa; }
.puantaj td.hs, .puantaj th.hs { background: #f1f3f5; }
.pz {
  display: inline-block; min-width: 22px; padding: 1px 4px; border-radius: 4px;
  font-weight: 600; font-size: .72rem; line-height: 1.3;
}
.pz-cal  { background: #d1e7dd; color: #0f5132; }
.pz-yok  { background: #f8d7da; color: #842029; }
.pz-izin { background: #cfe2ff; color: #084298; }
.pz-rt   { background: #e2e3e5; color: #41464b; }
.pz-ht   { background: #f8f9fa; color: #adb5bd; }
.pz-gec  { background: #fff3cd; color: #997404; }
@media print {
  .puantaj { font-size: .65rem; }
  .puantaj .sticky-col { position: static; box-shadow: none; }
}
