/* =========================================================
   Cari Takip — app.css (W2)
   Tema değişkenleri (dark/light), büyük dokunma hedefleri,
   kart gölgeleri, para/durum renkleri, toast ve mobil düzen.
   ========================================================= */

:root,
[data-bs-theme="dark"] {
    --cari-bg: #0f172a;
    --cari-surface: #1e293b;
    --cari-surface-2: #273449;
    --cari-border: rgba(148, 163, 184, 0.18);
    --cari-text: #e2e8f0;
    --cari-muted: #94a3b8;
    --cari-brand: #38bdf8;
    --cari-pos: #4ade80;   /* alacak / borçlu müşteri */
    --cari-neg: #f87171;   /* borç / karşılıksız */
    --cari-warn: #fbbf24;  /* bekleyen çek / vadesi yaklaşan */
    --cari-inactive: #64748b; /* silinmiş / etkisiz kayıt */
    --cari-card-shadow: 0 10px 30px rgba(2, 6, 23, 0.45);
    --cari-radius: 0.9rem;
}

[data-bs-theme="light"] {
    --cari-bg: #f1f5f9;
    --cari-surface: #ffffff;
    --cari-surface-2: #f8fafc;
    --cari-border: rgba(15, 23, 42, 0.10);
    --cari-text: #0f172a;
    --cari-muted: #64748b;
    --cari-brand: #0369a1;
    --cari-pos: #16a34a;
    --cari-neg: #dc2626;
    --cari-warn: #b45309;
    --cari-inactive: #94a3b8;
    --cari-card-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

html {
    color-scheme: dark;
}

html[data-bs-theme="light"] {
    color-scheme: light;
}

/* ---------- Genel iskelet ---------- */
body {
    background-color: var(--cari-bg);
    color: var(--cari-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-tap-highlight-color: transparent;
    font-variant-numeric: tabular-nums;
}

.app-main {
    flex: 1 0 auto;
    width: 100%;
}

.app-footer {
    flex-shrink: 0;
}

.app-navbar {
    box-shadow: 0 2px 14px rgba(2, 6, 23, 0.25);
}

.app-navbar .navbar-brand {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

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

.card-header {
    background-color: var(--cari-surface-2);
    border-bottom: 1px solid var(--cari-border);
    font-weight: 600;
    border-radius: var(--cari-radius) var(--cari-radius) 0 0;
}

/* ---------- Büyük dokunma hedefleri (min 44px) ---------- */
.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.form-control,
.form-select {
    min-height: 46px;
    font-size: 1rem;
    border-radius: 0.6rem;
}

textarea.form-control {
    min-height: 88px;
}

.form-label {
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.input-group-text {
    min-height: 46px;
}

.nav-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.navbar-nav .nav-link {
    padding-inline: 0.9rem;
    border-radius: 0.6rem;
}

.navbar-nav .nav-link.active {
    color: var(--cari-brand);
    font-weight: 600;
}

/* ---------- Para / durum renkleri ---------- */
.text-money-pos {
    color: var(--cari-pos) !important;
}

.text-money-neg {
    color: var(--cari-neg) !important;
}

.text-money-zero {
    color: var(--cari-muted) !important;
}

/* Silinmiş / etkisiz (soft delete, karşılıksız vb.) kayıtlar */
.text-inactive {
    color: var(--cari-inactive) !important;
}

.badge-cari-pos {
    color: var(--cari-pos);
    background-color: rgba(74, 222, 128, 0.15);
}

.badge-cari-neg {
    color: var(--cari-neg);
    background-color: rgba(248, 113, 113, 0.15);
}

.badge-cari-warn {
    color: var(--cari-warn);
    background-color: rgba(251, 191, 36, 0.15);
}

.badge-cari-muted {
    color: var(--cari-muted);
    background-color: rgba(100, 116, 139, 0.20);
}

/* ---------- Tablolar ---------- */
.table {
    --bs-table-bg: transparent;
}

/* ---------- Toast (üst sağ) ---------- */
.toast-container.cari-toast {
    position: fixed;
    top: calc(0.75rem + env(safe-area-inset-top, 0px));
    right: calc(0.75rem + env(safe-area-inset-right, 0px));
    z-index: 2000;
    width: max-content;
    max-width: min(92vw, 380px);
}

/* ---------- Giriş sayfası ---------- */
.login-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

.login-logo {
    font-size: 2.4rem;
    line-height: 1;
}

.btn-login {
    font-weight: 600;
    font-size: 1.05rem;
}

.btn-toggle-password {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    transform: translateY(-50%);
    min-width: 44px;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: var(--cari-muted);
    font-size: 1.15rem;
    line-height: 1;
    border-radius: 0.6rem;
}

.btn-toggle-password:focus-visible {
    outline: 2px solid var(--cari-brand);
}

.cari-input-pass {
    padding-right: 3.2rem;
}

/* ---------- Mobil ---------- */
@media (max-width: 575.98px) {
    .app-main {
        padding-bottom: 4.5rem; /* alt içeriğin kapanmaması için boşluk */
    }

    .card {
        border-radius: 0.75rem;
    }

    .btn {
        min-height: 46px; /* küçük ekranda biraz daha büyük hedef */
    }

    .modal-dialog {
        margin: 0.5rem;
    }
}

/* =========================================================
   V2 — grup başlıkları, tablo v2, offcanvas menü,
   kategori rozetleri ve rapor yazdırma stili
   ========================================================= */

/* ---------- İl/İlçe grup başlığı (koyu şerit + CSS rozet) ---------- */
.group-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.9rem;
    border-radius: 0.55rem;
    border-left: 4px solid var(--cari-brand);
    background: linear-gradient(90deg, #1e293b 0%, #334155 100%);
    color: #e2e8f0;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Bayrak ikonu yerine CSS rozet (pin) */
.group-header::before {
    content: "📍";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background-color: rgba(56, 189, 248, 0.22);
    font-size: 0.85rem;
}

.group-header .group-count {
    margin-left: auto;
    font-size: 0.8rem;
    font-weight: 600;
    color: #cbd5e1;
}

/* ---------- Tablo v2 ---------- */
.table-v2 {
    margin-bottom: 0;
    font-size: 0.95rem;
}

.table-v2 thead th {
    background-color: var(--cari-surface-2);
    color: var(--cari-muted);
    border-bottom: 2px solid var(--cari-border);
    white-space: nowrap;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table-v2 td {
    vertical-align: middle;
}

.table-v2 .num-cell {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.table-v2 tfoot td {
    border-top: 2px solid var(--cari-border);
    font-weight: 700;
    white-space: nowrap;
}

/* Yatay taşan tablolar: yumuşak kaydırma, taşma zinciri yok */
.table-responsive.table-responsive-v2 {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

/* Navbar v2: 10 bağlantının tek satıra sığması için daraltma */
@media (min-width: 992px) {
    .app-navbar .navbar-nav .nav-link {
        padding-inline: 0.55rem;
    }

    .app-navbar .navbar-brand {
        margin-right: 1rem;
    }
}

/* ---------- Offcanvas (mobil) menü ---------- */
.app-offcanvas {
    --bs-offcanvas-width: 300px;
    --bs-offcanvas-bg: var(--cari-surface);
    --bs-offcanvas-border-color: var(--cari-border);
}

/* Büyük dokunma hedefli dikey link listesi */
.app-offcanvas .navbar-nav .nav-link {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 0.6rem 0.9rem;
    border-radius: 0.6rem;
    font-size: 1.05rem;
}

.app-offcanvas .navbar-nav .nav-link:hover {
    background-color: var(--cari-surface-2);
}

.app-offcanvas .navbar-nav .nav-link.active {
    background-color: rgba(56, 189, 248, 0.15);
    color: var(--cari-brand);
    font-weight: 600;
}

/* ---------- Kategori rozetleri ---------- */
.badge-cat {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35em 0.75em;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.4;
    background-color: var(--cari-surface-2);
    color: var(--cari-text);
    border: 1px solid var(--cari-border);
    white-space: nowrap;
}

.badge-cat-1 { background-color: rgba(56, 189, 248, 0.15); color: var(--cari-brand); border-color: transparent; }
.badge-cat-2 { background-color: rgba(74, 222, 128, 0.15); color: var(--cari-pos); border-color: transparent; }
.badge-cat-3 { background-color: rgba(251, 191, 36, 0.18); color: var(--cari-warn); border-color: transparent; }
.badge-cat-4 { background-color: rgba(248, 113, 113, 0.15); color: var(--cari-neg); border-color: transparent; }
.badge-cat-5 { background-color: rgba(167, 139, 250, 0.18); color: #a78bfa; border-color: transparent; }
.badge-cat-6 { background-color: rgba(45, 212, 191, 0.16); color: #2dd4bf; border-color: transparent; }

/* ---------- Yazdırma (report.php için) ---------- */
@media print {
    @page {
        margin: 12mm;
    }

    /* Navbar, footer, offcanvas ve etkileşim öğeleri yazılmaz */
    .app-navbar,
    .app-footer,
    .offcanvas,
    .offcanvas-backdrop,
    .toast-container,
    .btn,
    .no-print,
    .modal,
    .alert-dismissible .btn-close {
        display: none !important;
    }

    html,
    body {
        background: #fff !important;
        color: #000 !important;
        display: block;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .app-main {
        padding: 0 !important;
        max-width: 100% !important;
    }

    /* Kartlar çerçevesiz, siyah-beyaz */
    .card {
        border: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
        color: #000 !important;
        break-inside: avoid;
    }

    .card-header {
        background: #fff !important;
        color: #000 !important;
        border-bottom: 2px solid #000 !important;
        border-radius: 0 !important;
    }

    .table {
        --bs-table-bg: transparent;
        color: #000 !important;
    }

    .table th,
    .table td {
        color: #000 !important;
        border-color: #999 !important;
    }

    .table thead th {
        background: #eee !important;
        color: #000 !important;
    }

    .text-money-pos,
    .text-money-neg,
    .text-money-zero,
    .text-inactive {
        color: #000 !important;
    }

    .group-header {
        background: #eee !important;
        color: #000 !important;
        border-left-color: #000 !important;
    }

    .group-header .group-count {
        color: #333 !important;
    }

    .badge-cat,
    .badge-cari-pos,
    .badge-cari-neg,
    .badge-cari-warn,
    .badge-cari-muted {
        background: #f2f2f2 !important;
        color: #000 !important;
        border: 1px solid #999 !important;
    }

    /* Linklerin URL'lerini yazdırma */
    a[href]::after {
        content: '' !important;
    }
}

/* İlçe alt başlığı (grup tabloları arası) */
.group-subheader {
  position: sticky;
  top: 0;
  z-index: 5;
}

/* ============================ PIN KİLİT EKRANI (v2.2) ============================ */
.pin-lock {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #0f172a 0%, #1e3a8a 100%);
  color: #fff;
}
.pin-clock {
  font-size: 3.4rem;
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pin-date {
  font-size: .95rem;
  opacity: .8;
  margin-bottom: 26px;
}
.pin-brand {
  font-size: 1rem;
  opacity: .9;
  margin-bottom: 6px;
}
.pin-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 18px;
}
.pin-dots {
  display: flex;
  gap: 18px;
  margin-bottom: 10px;
}
.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .55);
  display: inline-block;
  transition: background .12s ease, transform .12s ease;
}
.pin-dot.filled {
  background: #fff;
  border-color: #fff;
  transform: scale(1.1);
}
.pin-dots.shake {
  animation: pinShake .45s ease;
}
@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
.pin-msg {
  min-height: 1.4em;
  font-size: .9rem;
  margin-bottom: 12px;
  text-align: center;
}
.pin-msg-err { color: #fca5a5; }
.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  gap: 14px;
}
.pin-key {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-size: 1.6rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s ease, transform .1s ease;
}
.pin-key:active {
  background: rgba(255, 255, 255, .28);
  transform: scale(.96);
}
.pin-key.pin-back, .pin-key.pin-ok {
  font-size: 1.25rem;
}
.pin-noscript { margin-top: 18px; max-width: 260px; }
.pin-lock .text-secondary { color: rgba(255, 255, 255, .6) !important; }
@media (max-width: 380px) {
  .pin-keypad { grid-template-columns: repeat(3, 64px); gap: 10px; }
  .pin-key { width: 64px; height: 64px; font-size: 1.4rem; }
  .pin-clock { font-size: 2.8rem; }
}

/* ============================ YAZDIRMA (v3 — rapor ekonomik baskı) ============================ */
@media print {
  @page { size: A4 portrait; margin: 8mm; }

  html, body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11px !important;
  }

  /* Uygulama kabını gizle: menü, açılır panel, alt bilgi, dönem seçici, butonlar */
  .navbar, .offcanvas, .offcanvas-backdrop, .app-footer, .modal, .modal-backdrop,
  .no-print, .btn, .dropdown, .btn-toggle-password {
    display: none !important;
  }

  /* Koyu temayı beyaza zorla */
  html[data-bs-theme='dark'], html[data-bs-theme='dark'] body,
  [data-bs-theme='dark'] body, [data-bs-theme='dark'] .card {
    background: #fff !important;
    color: #000 !important;
  }

  .container, .container-fluid {
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
  }

  /* Kartlar: ince çerçeve, gölgesiz, sıkı — bölünmesin */
  .card {
    border: 1px solid #999 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 0 6px 0 !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    background: #fff !important;
    color: #000 !important;
  }
  .card-header {
    background: #efefef !important;
    color: #000 !important;
    border-bottom: 1px solid #999 !important;
    padding: 3px 8px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
  }
  .card-body { padding: 5px 8px !important; }

  /* Rapor ızgarası: yazdırmada 2 kolon (print-grid sınıflı satırlar) */
  .print-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
  }
  .print-grid > [class*='col-'] {
    width: auto !important;
    padding: 0 !important;
    flex: initial !important;
    max-width: none !important;
  }
  .print-grid .h-100 { height: auto !important; }

  /* Tablolar kompakt ve okunur */
  .table {
    font-size: 10.5px !important;
    margin: 0 !important;
    color: #000 !important;
    --bs-table-bg: #fff !important;
    --bs-table-color: #000 !important;
  }
  .table td, .table th { padding: 2px 5px !important; }
  .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-bg: #f6f6f6 !important;
    color: #000 !important;
  }

  /* Metin/başlık ölçekleri */
  h1, .h3 { font-size: 15px !important; margin-bottom: 4px !important; }
  .h6, .fs-5, .fs-4 { font-size: 12px !important; }
  .fs-3, .fs-2 { font-size: 16px !important; }
  #rptPeriod, #rptGenerated { font-size: 10px !important; }
  .badge { font-size: 9px !important; padding: 1px 5px !important; }
  .py-4, .py-3 { padding-top: 4px !important; padding-bottom: 4px !important; }
  .mb-1, .mb-2, .mb-3, .mb-4 { margin-bottom: 4px !important; }
  .g-3 { gap: 4px !important; }
}
