/* ================================================================
   CARİ TAKİP SİSTEMİ - TASARIM SİSTEMİ
   Mobil öncelikli; sidebar (masaüstü) + alt sekme çubuğu (mobil)
   ================================================================ */

/* ---------- Design tokens ---------- */
:root {
  --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --color-bg: #F5F6F8;
  --color-surface: #FFFFFF;
  --color-border: #E3E7EC;
  --color-ink: #12161F;
  --color-ink-soft: #2A303C;
  --color-muted: #647084;

  --color-primary: #0F6B5C;
  --color-primary-dark: #0A4F44;
  --color-primary-soft: #E3F2EE;

  --color-success: #1F9D6F;
  --color-success-soft: #E6F6EE;
  --color-danger: #B3452C;
  --color-danger-soft: #FBEAE4;
  --color-warning: #A6740A;
  --color-warning-soft: #FBF1DC;
  --color-info: #3E6FA6;
  --color-info-soft: #EAF1F9;
  --color-neutral: #5B4B8A;
  --color-neutral-soft: #EDE9F5;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(18, 22, 31, .06);
  --shadow-md: 0 6px 20px rgba(18, 22, 31, .08);

  --sidebar-w: 252px;
  --topbar-h: 60px;
  --tabbar-h: 64px;

  /* Bootstrap 5.3 tema değişkenlerini paletimize yönlendiriyoruz
     (badge/alert/border/text utility sınıfları bunları kullanıyor) */
  --bs-body-font-family: var(--font-sans);
  --bs-body-bg: var(--color-bg);
  --bs-body-color: var(--color-ink);
  --bs-border-color: var(--color-border);
  --bs-border-radius: var(--radius-md);
  --bs-border-radius-sm: var(--radius-sm);
  --bs-border-radius-lg: var(--radius-lg);
  --bs-link-color: var(--color-primary);
  --bs-link-hover-color: var(--color-primary-dark);
  --bs-emphasis-color: var(--color-ink);

  --bs-primary: var(--color-primary);
  --bs-primary-rgb: 15, 107, 92;
  --bs-success: var(--color-success);
  --bs-success-rgb: 31, 157, 111;
  --bs-danger: var(--color-danger);
  --bs-danger-rgb: 179, 69, 44;
  --bs-warning: var(--color-warning);
  --bs-warning-rgb: 166, 116, 10;
  --bs-info: var(--color-info);
  --bs-info-rgb: 62, 111, 166;
  --bs-secondary: var(--color-muted);
  --bs-secondary-rgb: 100, 112, 132;
  --bs-dark: var(--color-ink);
  --bs-dark-rgb: 18, 22, 31;
  --bs-light: #EEF1F4;
  --bs-light-rgb: 238, 241, 244;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

* { -webkit-tap-highlight-color: transparent; }

html { scroll-padding-top: calc(var(--topbar-h) + 12px); }

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

a { color: var(--color-primary); }
a:hover { color: var(--color-primary-dark); }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -0.01em; color: var(--color-ink); }

/* Parasal/sayısal değerler: sabit genişlikli rakamlarla hizalı görünüm için mono font.
   Uygulamada tüm tutar/miktar hücreleri text-end sınıfını kullanıyor. */
.table td.text-end,
.table th.text-end,
.stat-card h3,
.fw-bold.text-success,
.fw-bold.text-danger {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ================================================================
   APP SHELL: Sidebar (masaüstü) + Topbar + İçerik + Alt sekme çubuğu
   ================================================================ */
.app-shell { min-height: 100vh; }

.app-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--color-ink);
  color: #C7CDD6;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transform: translateX(-100%);
  transition: transform .25s ease;
  padding-top: env(safe-area-inset-top, 0px);
}
.app-sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-md); }

.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 1.25rem;
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand i { color: var(--color-primary); font-size: 1.3rem; -webkit-text-stroke: .2px; }
.sidebar-brand .accent { color: #7FD9C4; }

.sidebar-close {
  margin-left: auto;
  background: none; border: 0; color: #C7CDD6; font-size: 1.3rem; line-height: 1;
  display: none;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .6rem; }
.sidebar-section-label {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: #6B7688; padding: .9rem .65rem .35rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .7rem;
  border-radius: var(--radius-sm);
  color: #C7CDD6;
  text-decoration: none;
  font-size: .92rem;
  font-weight: 600;
  margin-bottom: .15rem;
  border-left: 3px solid transparent;
}
.sidebar-link i { font-size: 1.05rem; width: 1.3rem; text-align: center; color: #8891A0; }
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.active {
  background: rgba(127, 217, 196, .12);
  color: #fff;
  border-left-color: var(--color-primary);
}
.sidebar-link.active i { color: #7FD9C4; }

.sidebar-user {
  padding: .9rem 1.1rem;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: .6rem;
  padding-bottom: calc(.9rem + env(safe-area-inset-bottom, 0px));
}
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who strong { display: block; color: #fff; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who span { font-size: .72rem; color: #8891A0; }
.sidebar-user a { color: #C7CDD6; font-size: 1.15rem; }
.sidebar-user a:hover { color: #fff; }

.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(10,12,16,.5);
  z-index: 1035; opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.sidebar-overlay.is-open { opacity: 1; pointer-events: auto; }

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

.app-topbar {
  position: sticky; top: 0; z-index: 1020;
  height: var(--topbar-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1rem;
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-toggle {
  background: none; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  width: 38px; height: 38px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-ink); font-size: 1.1rem;
}
.topbar-title { font-weight: 800; font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user-badge {
  display: flex; align-items: center; gap: .4rem;
  font-size: .85rem; color: var(--color-muted); font-weight: 600;
}
.topbar-user-badge .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--color-primary-soft); color: var(--color-primary);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem;
}

.app-content {
  flex: 1;
  padding: 1.25rem 1rem calc(1.5rem + var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  max-width: 1320px;
  width: 100%;
}

@media (min-width: 992px) {
  .app-sidebar { transform: translateX(0); }
  .app-main { margin-left: var(--sidebar-w); }
  .topbar-toggle { display: none; }
  .app-content { padding: 1.75rem 2rem 2rem; }
}

/* ---------- Alt sekme çubuğu (sadece mobil/tablet) ---------- */
.bottom-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--tabbar-h);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  z-index: 1030;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 12px rgba(18,22,31,.05);
}
.tabbar-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .15rem;
  color: var(--color-muted);
  text-decoration: none;
  font-size: .68rem;
  font-weight: 700;
  position: relative;
  border: 0; background: none;
}
.tabbar-item i { font-size: 1.25rem; }
.tabbar-item.active { color: var(--color-primary); }
.tabbar-badge {
  position: absolute; top: 2px; right: calc(50% - 20px);
  background: var(--color-danger); color: #fff;
  font-size: .6rem; font-weight: 800;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

@media (min-width: 992px) {
  .bottom-tabbar { display: none; }
}

/* ================================================================
   BİLEŞENLER
   ================================================================ */

/* Kartlar */
.card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  background: var(--color-surface);
}

/* Stat kartları - düz yüzey + sol renk şeridi (gradyan yok) */
.stat-card {
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.3rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  color: var(--color-ink);
  height: 100%;
}
.stat-card small { color: var(--color-muted); font-weight: 700; font-size: .72rem; letter-spacing: .03em; text-transform: uppercase; }
.stat-card h3 { margin: .2rem 0 0; font-weight: 800; font-size: 1.5rem; color: var(--color-ink); }

.stat-card--debt, .stat-card.borc { border-left-color: var(--color-danger); }
.stat-card--pay, .stat-card.odeme { border-left-color: var(--color-success); }
.stat-card--info, .stat-card.siparis { border-left-color: var(--color-info); }
.stat-card--warning { border-left-color: var(--color-warning); }
.stat-card--neutral { border-left-color: var(--color-neutral); }
.stat-card--brand {
  border-left-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
}
.stat-card--brand small { color: rgba(255,255,255,.75); }
.stat-card--brand h3 { color: #fff; }

/* Butonlar - Bootstrap bileşen düzeyi değişkenlerini eziyoruz (v5.3 CSS var mimarisi) */
.btn { border-radius: var(--radius-sm); font-weight: 700; font-size: .9rem; }
.btn-sm { border-radius: 7px; }

.btn-dark {
  --bs-btn-bg: var(--color-ink); --bs-btn-border-color: var(--color-ink);
  --bs-btn-hover-bg: var(--color-ink-soft); --bs-btn-hover-border-color: var(--color-ink-soft);
  --bs-btn-active-bg: var(--color-ink-soft); --bs-btn-active-border-color: var(--color-ink-soft);
  --bs-btn-disabled-bg: var(--color-ink); --bs-btn-disabled-border-color: var(--color-ink);
}
.btn-outline-dark {
  --bs-btn-color: var(--color-ink); --bs-btn-border-color: var(--color-border);
  --bs-btn-hover-bg: var(--color-ink); --bs-btn-hover-border-color: var(--color-ink);
  --bs-btn-active-bg: var(--color-ink); --bs-btn-active-border-color: var(--color-ink);
}
.btn-outline-secondary {
  --bs-btn-color: var(--color-muted); --bs-btn-border-color: var(--color-border);
  --bs-btn-hover-bg: var(--color-muted); --bs-btn-hover-border-color: var(--color-muted);
}
.btn-success {
  --bs-btn-bg: var(--color-success); --bs-btn-border-color: var(--color-success);
  --bs-btn-hover-bg: #187E5A; --bs-btn-hover-border-color: #187E5A;
  --bs-btn-active-bg: #187E5A; --bs-btn-active-border-color: #187E5A;
}
.btn-outline-success {
  --bs-btn-color: var(--color-success); --bs-btn-border-color: var(--color-success);
  --bs-btn-hover-bg: var(--color-success); --bs-btn-hover-border-color: var(--color-success);
}
.btn-outline-danger {
  --bs-btn-color: var(--color-danger); --bs-btn-border-color: var(--color-danger);
  --bs-btn-hover-bg: var(--color-danger); --bs-btn-hover-border-color: var(--color-danger);
}
.btn-outline-light { --bs-btn-color: #fff; --bs-btn-border-color: rgba(255,255,255,.4); }

/* Rozetler (durum etiketleri) zaten --bs-*-rgb üzerinden paleti alıyor */
.badge { font-weight: 700; font-size: .72rem; padding: .4em .65em; border-radius: 999px; }

/* Formlar */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--color-border);
  font-size: 16px; /* iOS'ta otomatik zoom'u engeller */
  min-height: 44px; /* dokunma hedefi */
  padding-top: .5rem; padding-bottom: .5rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 .2rem var(--color-primary-soft);
}
.form-label { font-weight: 700; font-size: .84rem; color: var(--color-ink-soft); margin-bottom: .35rem; }
.form-check-input:checked { background-color: var(--color-primary); border-color: var(--color-primary); }
.form-check-input:focus { box-shadow: 0 0 0 .2rem var(--color-primary-soft); }

/* Tablolar */
.table { font-size: .88rem; margin-bottom: 0; }
.table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--color-muted); font-weight: 700;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.table td { vertical-align: middle; border-color: var(--color-border); }
.table-hover tbody tr:hover { background: var(--color-primary-soft); }
.table-responsive { border-radius: var(--radius-md); }

/* Modallar - mobilde alttan açılan sayfa hissi */
.modal-content { border-radius: var(--radius-lg); border: none; box-shadow: var(--shadow-md); }
.modal-header, .modal-footer { border-color: var(--color-border); }
@media (max-width: 575.98px) {
  .modal.fade .modal-dialog { transform: translateY(100%); }
  .modal.show .modal-dialog { transform: translateY(0); }
  .modal-dialog { margin: 0; display: flex; align-items: flex-end; min-height: 100%; }
  .modal-content { border-bottom-left-radius: 0; border-bottom-right-radius: 0; max-height: 92vh; overflow-y: auto; }
}

/* Progress bar */
.progress { height: 8px; border-radius: 999px; background: var(--color-border); }
.progress-bar { background-color: var(--color-primary); }
.progress-bar.bg-success { background-color: var(--color-success) !important; }
.progress-bar.bg-warning { background-color: var(--color-warning) !important; }
.progress-bar.bg-danger { background-color: var(--color-danger) !important; }

/* Alert kutuları */
.alert { border-radius: var(--radius-md); border: 1px solid transparent; font-size: .9rem; }

/* Auth sayfaları (login/kurulum) için ortak kart */
.auth-card { border-radius: var(--radius-lg); border: 1px solid var(--color-border); box-shadow: var(--shadow-md); }
.auth-shell { background: var(--color-bg); min-height: 100vh; }
.auth-brand-icon { color: var(--color-primary); font-size: 2.4rem; }

/* Küçük yardımcılar */
.text-muted { color: var(--color-muted) !important; }
hr { border-color: var(--color-border); }

/* Çok küçük ekranlar için ince ayar */
@media (max-width: 420px) {
  .stat-card h3 { font-size: 1.25rem; }
  .table { font-size: .8rem; }
  .topbar-title { font-size: .95rem; }
}
