/* ============================================================
   HTOS · Dashboard Styles
   Mobile-first · token-based theming (light/dark) · no Bootstrap
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  /* color primitives */
  --c-white: #ffffff;
  --brand: #2f6bff;
  --brand-600: #2459e0;
  --brand-soft: rgba(47, 107, 255, 0.12);

  /* semantic surfaces (light) */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --elevated: #ffffff;
  --border: #e7e9ef;
  --border-strong: #d8dbe4;

  /* text */
  --text: #161922;
  --text-2: #5b6172;
  --text-3: #8a90a2;

  /* status */
  --info: #2f6bff;
  --info-soft: rgba(47, 107, 255, 0.12);
  --good: #16a571;
  --good-soft: rgba(22, 165, 113, 0.14);
  --warn: #e0930b;
  --warn-soft: rgba(224, 147, 11, 0.15);
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.13);
  --neutral: #6b7280;
  --neutral-soft: rgba(107, 114, 128, 0.12);

  /* shape & motion */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.10);
  --ease: 180ms cubic-bezier(0.4, 0, 0.2, 1);

  /* layout */
  --sidebar-w: 252px;
  --topbar-h: 64px;

  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Plus Jakarta Sans", var(--font-sans);
}

[data-theme="dark"] {
  --bg: #0d0f14;
  --surface: #15181f;
  --surface-2: #1a1e27;
  --elevated: #191d26;
  --border: #242a35;
  --border-strong: #303747;

  --text: #eef0f5;
  --text-2: #a4abbb;
  --text-3: #727a8c;

  --brand-soft: rgba(47, 107, 255, 0.20);
  --info-soft: rgba(47, 107, 255, 0.20);
  --good-soft: rgba(22, 165, 113, 0.18);
  --warn-soft: rgba(224, 147, 11, 0.20);
  --danger-soft: rgba(229, 72, 77, 0.20);
  --neutral-soft: rgba(160, 171, 187, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.55);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--ease), color var(--ease);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul { list-style: none; }
select, input { font: inherit; color: inherit; }
.ti { font-size: 1.15em; line-height: 1; }

/* ============================================================
   APP SHELL  (mobile-first: single column, off-canvas sidebar)
   ============================================================ */
.app { min-height: 100vh; }

.main { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(86vw, var(--sidebar-w));
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transform: translateX(-100%);
  transition: transform var(--ease);
}
.sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 18px;
  box-shadow: var(--shadow-sm);
}
.brand__name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
}
.sidebar__close { margin-left: auto; color: var(--text-2); font-size: 20px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; }
.sidebar__close:hover { background: var(--surface-2); }

.nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 14px 10px 6px;
}
.nav__item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-weight: 500;
  transition: background var(--ease), color var(--ease);
}
.nav__item .ti { font-size: 19px; }
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav__badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--text-2);
}
.nav__badge--alert { background: var(--danger-soft); color: var(--danger); }
.nav__sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 3px 0 4px 19px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}
.nav__sub-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--ease), color var(--ease);
}
.nav__sub-item .ti { font-size: 16px; }
.nav__sub-item:hover { background: var(--surface-2); color: var(--text); }
.nav__sub-item.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav__sub-item--danger { color: var(--danger); }
.nav__sub-item--danger .ti { color: var(--danger); }
.nav__sub-item--danger:hover { background: var(--danger-soft); color: var(--danger); }
.nav__sub-item--danger.is-active { background: var(--danger-soft); color: var(--danger); }

.sidebar__foot { padding: 12px; border-top: 1px solid var(--border); }

.userchip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--r-sm);
  transition: background var(--ease);
  background: none; border: 0; font: inherit; color: inherit; text-align: left;
}
.userchip:hover { background: var(--surface-2); cursor: pointer; }
.sidebar__user { display: block; width: 100%; }
.sidebar__user .userchip { width: 100%; }
.userchip__avatar {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.userchip__meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.userchip__name { font-weight: 600; font-size: 13px; }
.userchip__role { font-size: 11px; color: var(--text-3); }
.userchip__chev { margin-left: auto; color: var(--text-3); }
.userchip--compact { padding: 0; }
.userchip--compact:hover { background: none; }

/* scrim behind off-canvas sidebar */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 18, 0.5);
  z-index: 55;
  opacity: 0;
  animation: fade var(--ease) forwards;
}
@keyframes fade { to { opacity: 1; } }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}

.iconbtn {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 20px;
  transition: background var(--ease), color var(--ease);
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn--sm { width: 32px; height: 32px; font-size: 16px; }
.iconbtn__dot {
  position: absolute; top: 9px; right: 10px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

.branch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 10px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  flex-shrink: 0;
}
.branch__select { border: none; background: none; font-weight: 600; font-size: 13px; padding-right: 4px; outline: none; }

.search { display: none; }
.search__kbd {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
}

.topbar__menu { margin-right: 2px; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }

/* ============================================================
   CONTENT
   ============================================================ */
.content {
  flex: 1;
  padding: 18px 16px calc(78px + env(safe-area-inset-bottom));
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  /* consistent vertical rhythm between stacked blocks (cards, alerts, tables…) */
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pagehead {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.pagehead__title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.pagehead__sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.pagehead__actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 13px;
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn .ti { font-size: 17px; }
.btn--primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--brand-600); }
.btn--ghost { background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.btn--ghost:hover { color: var(--text); border-color: var(--border-strong); }

/* ---------- Grids ---------- */
.grid { display: grid; gap: 14px; }
.grid--kpi { grid-template-columns: repeat(2, 1fr); }
.grid--widgets { grid-template-columns: 1fr; }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--ease), border-color var(--ease), transform var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }

/* ---------- KPI ---------- */
.kpi { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.kpi__head { display: flex; align-items: center; gap: 9px; }
.kpi__icon {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  font-size: 18px;
}
.kpi__icon--info { background: var(--info-soft); color: var(--info); }
.kpi__icon--warn { background: var(--warn-soft); color: var(--warn); }
.kpi__icon--danger { background: var(--danger-soft); color: var(--danger); }
.kpi__icon--neutral { background: var(--neutral-soft); color: var(--neutral); }
.kpi__icon--good { background: var(--good-soft); color: var(--good); }
.kpi__label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.kpi__value { font-family: var(--font-display); font-size: 30px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.kpi__value--sm { font-size: 20px; } /* tarih gibi metinsel değerler için */
.kpi__trend { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; color: var(--text-3); }
.kpi__trend .ti { font-size: 15px; }
.kpi__trend--up { color: var(--good); }
.kpi__trend--warn { color: var(--warn); }
.kpi__trend--danger { color: var(--danger); }

/* ---------- Widget ---------- */
.widget { padding: 16px; display: flex; flex-direction: column; }
.widget__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.widget__title {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display);
  font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em;
}
.widget__title .ti { font-size: 18px; color: var(--text-2); }
.widget__more { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.widget__more:hover { color: var(--brand); }
.widget__more .ti { font-size: 15px; }

/* ---------- List ---------- */
.list { display: flex; flex-direction: column; }
.list__row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 6px;
  border-radius: var(--r-sm);
  border-top: 1px solid var(--border);
  transition: background var(--ease);
}
.list__row:first-child { border-top: none; }
.list__row:hover { background: var(--surface-2); }
.list__main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.list__name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list__sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot--danger { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.dot--warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.dot--good { background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.dot--neutral { background: var(--neutral); box-shadow: 0 0 0 4px var(--neutral-soft); }

/* ---------- Tag ---------- */
.tag {
  flex-shrink: 0;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--text-2);
  white-space: nowrap;
}
.tag--danger { background: var(--danger-soft); color: var(--danger); }
.tag--warn { background: var(--warn-soft); color: var(--warn); }
.tag--good { background: var(--good-soft); color: var(--good); }

/* ---------- Bars (branch status) ---------- */
.bars { display: flex; flex-direction: column; gap: 14px; padding-top: 2px; }
.bars__row { display: grid; grid-template-columns: 64px 1fr 38px; align-items: center; gap: 10px; }
.bars__label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.bars__val { font-size: 12.5px; font-weight: 700; text-align: right; }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.bar__fill { display: block; height: 100%; width: var(--w); border-radius: 999px; }
.bar__fill--good { background: var(--good); }
.bar__fill--warn { background: var(--warn); }
.bar__fill--danger { background: var(--danger); }

/* ---------- Funnel ---------- */
.funnel { display: flex; flex-direction: column; gap: 12px; padding-top: 2px; }
.funnel__row { display: grid; grid-template-columns: 88px 1fr 42px; align-items: center; gap: 10px; }
.funnel__label { font-size: 12.5px; color: var(--text-2); }
.funnel__bar { height: 22px; border-radius: var(--r-sm); background: var(--surface-2); overflow: hidden; }
.funnel__fill { display: block; height: 100%; width: var(--w); border-radius: var(--r-sm); background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 60%, #7aa2ff)); }
.funnel__val { font-size: 13px; font-weight: 700; text-align: right; }

/* ---------- Table ---------- */
.tablewrap { overflow-x: auto; margin: 0 -6px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 11px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-2); }

/* ============================================================
   MOBILE BOTTOM TAB BAR
   ============================================================ */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 0 8px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-3);
}
.tabbar__item .ti { font-size: 21px; }
.tabbar__item.is-active { color: var(--brand); }

/* ============================================================
   RESPONSIVE  (progressive enhancement, mobile-first)
   ============================================================ */

/* Small tablets: show search, 2-col widgets */
@media (min-width: 600px) {
  .content { padding: 22px 22px 28px; }
  .search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 440px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-3);
  }
  .search__input { border: none; background: none; outline: none; flex: 1; font-size: 13px; }
  .grid--widgets { grid-template-columns: repeat(2, 1fr); }
  .widget--wide { grid-column: 1 / -1; }
  .pagehead { flex-direction: row; align-items: flex-end; justify-content: space-between; }
}

/* KPI to 4 across earlier */
@media (min-width: 760px) {
  .grid--kpi { grid-template-columns: repeat(4, 1fr); }
}

/* Desktop: pinned sidebar, no off-canvas / tabbar */
@media (min-width: 1024px) {
  .main { margin-left: var(--sidebar-w); }
  .sidebar { transform: none; box-shadow: none; }
  .sidebar__close { display: none; }
  .topbar__menu { display: none; }
  .scrim { display: none; }
  .tabbar { display: none; }
  .content { padding-bottom: 36px; }
  .grid--widgets { grid-template-columns: repeat(3, 1fr); }
  .widget--wide { grid-column: span 3; }
}

/* Large desktop: airier widget grid */
@media (min-width: 1320px) {
  .grid { gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ============================================================
   WIDTH UTILITIES  (keep markup free of inline styles)
   ============================================================ */
.w35  { --w: 35%; }
.w55  { --w: 55%; }
.w63  { --w: 63%; }
.w71  { --w: 71%; }
.w82  { --w: 82%; }
.w88  { --w: 88%; }
.w94  { --w: 94%; }
.w100 { --w: 100%; }
