/* ============================================================
   Kartal Em Teknik Çatı — EMS Ana Stil Dosyası
   ============================================================ */

:root {
  --primary:        #1a3c6e;
  --primary-light:  #2d5a9e;
  --primary-dark:   #122b52;
  --secondary:      #6c757d;
  --success:        #198754;
  --warning:        #e6a817;
  --danger:         #dc3545;
  --info:           #0dcaf0;
  --bg:             #f0f2f5;
  --white:          #ffffff;
  --border:         #dee2e6;
  --text:           #212529;
  --text-muted:     #6c757d;
  --sidebar-width:  240px;
  --topbar-height:  60px;
}

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); }

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 1040;
  gap: 12px;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  width: var(--sidebar-width);
  flex-shrink: 0;
  white-space: nowrap;
}

.topbar .brand img { height: 32px; }

.topbar .search-wrap {
  flex: 1;
  max-width: 420px;
}

.topbar .search-wrap .input-group .form-control {
  border-radius: 20px 0 0 20px;
  border-color: var(--border);
  font-size: 13px;
}

.topbar .search-wrap .input-group .btn {
  border-radius: 0 20px 20px 0;
  border-color: var(--border);
  background: var(--bg);
}

.topbar .topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .btn-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  position: relative;
  transition: background .15s;
}
.topbar .btn-icon:hover { background: var(--bg); }

.topbar .btn-icon .badge-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--white);
}

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 20px;
  color: var(--primary);
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar-height));
  background: var(--primary);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1030;
  transition: transform .25s ease;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }

.sidebar .nav {
  padding: 12px 0 24px;
  flex-direction: column;
}

.sidebar .nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  padding: 16px 16px 4px;
}

.sidebar .nav-item { width: 100%; }

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,.75);
  font-size: 13.5px;
  border-radius: 0;
  transition: all .15s;
  white-space: nowrap;
}

.sidebar .nav-link i {
  font-size: 16px;
  width: 20px;
  flex-shrink: 0;
}

.sidebar .nav-link:hover {
  background: rgba(255,255,255,.1);
  color: var(--white);
}

.sidebar .nav-link.active {
  background: rgba(255,255,255,.18);
  color: var(--white);
  font-weight: 600;
}

/* ── Main Content ─────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height));
  padding: 24px;
}

/* ── Page Header ──────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.page-header .page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: none;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 18px; }

/* ── Stat Cards (Dashboard) ───────────────────────────── */
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow .15s;
}

.stat-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.08); }

.stat-card .stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-card .stat-icon.bg-primary-soft { background: #e8eef8; color: var(--primary); }
.stat-card .stat-icon.bg-success-soft { background: #e6f4ec; color: var(--success); }
.stat-card .stat-icon.bg-warning-soft { background: #fdf3dc; color: var(--warning); }
.stat-card .stat-icon.bg-danger-soft  { background: #fde8ea; color: var(--danger); }
.stat-card .stat-icon.bg-info-soft    { background: #dcf5fb; color: #0a8fa8; }
.stat-card .stat-icon.bg-purple-soft  { background: #ede8f9; color: #6f42c1; }

.stat-card .stat-body { flex: 1; min-width: 0; }
.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-card .stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.stat-card .stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Tables ───────────────────────────────────────────── */
.table-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.table { margin-bottom: 0; }

.table thead th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  background: #f8f9fa;
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  white-space: nowrap;
}

.table tbody td {
  padding: 11px 14px;
  vertical-align: middle;
  border-color: #f0f2f5;
  font-size: 13.5px;
}

.table tbody tr:hover { background: #f8f9ff; }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Buttons ──────────────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-light);
  border-color: var(--primary-light);
}

.btn-sm { font-size: 12px; padding: 4px 10px; }

/* ── Forms ────────────────────────────────────────────── */
.form-label { font-weight: 500; font-size: 13px; margin-bottom: 5px; }
.form-control, .form-select {
  font-size: 13.5px;
  border-color: var(--border);
  border-radius: 6px;
  padding: 8px 12px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,60,110,.12);
}
.form-text { font-size: 11.5px; }

/* ── Badges ───────────────────────────────────────────── */
.badge { font-weight: 500; font-size: 11px; padding: 4px 8px; }

/* ── Alert Flash ──────────────────────────────────────── */
.flash-alert {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 1055;
  min-width: 280px;
  max-width: 400px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  border-radius: 8px;
  animation: slideIn .25s ease;
}

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Item Rows (Sale/Purchase Form) ───────────────────── */
.item-row {
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  position: relative;
}

.item-row .btn-remove-row {
  position: absolute;
  top: 8px; right: 8px;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  font-size: 14px;
}

/* ── Totals Box ───────────────────────────────────────── */
.totals-box {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.totals-box .totals-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 14px;
}

.totals-box .totals-row.total-final {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 10px;
}

/* ── Detail Card (Müşteri, Ürün detay) ────────────────── */
.detail-info-item {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f2f5;
  font-size: 13.5px;
}
.detail-info-item:last-child { border-bottom: none; }
.detail-info-item .label { color: var(--text-muted); min-width: 140px; flex-shrink: 0; }
.detail-info-item .value { font-weight: 500; }

/* ── Status colors ────────────────────────────────────── */
.text-money { font-weight: 600; color: var(--primary); }
.text-debit { color: var(--danger); }
.text-credit { color: var(--success); }

/* ── Breadcrumb ───────────────────────────────────────── */
.breadcrumb { font-size: 12px; margin-bottom: 6px; }
.breadcrumb-item a { color: var(--text-muted); }
.breadcrumb-item.active { color: var(--primary); font-weight: 500; }

/* ── Footer ───────────────────────────────────────────── */
.main-footer {
  margin-left: var(--sidebar-width);
  padding: 14px 24px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--white);
  margin-top: 8px;
}

/* ── Autocomplete dropdown ────────────────────────────── */
.autocomplete-list {
  position: absolute;
  z-index: 999;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  max-height: 220px;
  overflow-y: auto;
  width: 100%;
  left: 0;
  top: calc(100% + 2px);
}

.autocomplete-list .autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid #f0f2f5;
}
.autocomplete-list .autocomplete-item:hover { background: #f0f4ff; }
.autocomplete-list .autocomplete-item:last-child { border-bottom: none; }

/* ── Login Page ───────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a3c6e 0%, #2d5a9e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand .brand-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  display: block;
}
.login-brand .brand-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Mobile Overlay ───────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1020;
}

/* ── Responsive ───────────────────────────────────────── */
/* ── Mobile & Responsive Tweaks ───────────────────────── */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0;
}

.table-card {
  width: 100%;
  overflow: hidden;
}

@media (max-width: 767.98px) {
  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    font-size: 24px;
  }

  .topbar .brand { width: auto; font-size: 15px; }
  .topbar .search-wrap { display: none; }

  .sidebar {
    transform: translateX(-100%);
    top: 0;
    height: 100vh;
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.open { display: block; }

  .main-content {
    margin-left: 0;
    padding: 12px;
    max-width: 100vw;
  }

  .main-footer {
    margin-left: 0;
    padding: 12px;
    text-align: center;
  }

  .main-footer > div {
    flex-direction: column;
    gap: 4px;
  }

  .stat-card {
    padding: 12px;
    gap: 10px;
  }

  .stat-card .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
    border-radius: 8px;
  }

  .stat-card .stat-value {
    font-size: 16px;
  }

  .stat-card .stat-label {
    font-size: 11px;
  }

  .page-header {
    margin-bottom: 14px;
  }

  .page-header h1 {
    font-size: 18px;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  /* iOS Auto-zoom önleme (font < 16px olunca safari zoom yapar) */
  .form-control, .form-select, input[type="text"], input[type="number"], input[type="date"], select, textarea {
    font-size: 16px !important;
  }

  .table thead th {
    padding: 8px 10px;
    font-size: 11px;
  }

  .table tbody td {
    padding: 8px 10px;
    font-size: 12.5px;
  }

  .item-row {
    padding: 10px;
  }

  .totals-box {
    padding: 12px;
  }

  .totals-box .totals-row.total-final {
    font-size: 16px;
  }

  .modal-dialog {
    margin: 10px;
  }
}

@media (max-width: 575.98px) {
  .main-content { padding: 10px; }
  .stat-card { padding: 10px; }
  .table tbody td, .table thead th {
    white-space: nowrap;
  }
}

/* ── Print ────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .page-actions, .btn, .no-print { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .main-footer { margin: 0; }
  body { background: white; }
  .card { border: none; box-shadow: none; }
}
