/* ═══════════════════════════════════════════════════════════════
   AKÜSK CRM — base.css
   Django templates için hazırlanmış. tokens.css önce yüklenmeli.
   ═══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01', 'ss03'; /* Inter alternatif glyph: temiz "1", "I", "g" */
  font-variant-numeric: tabular-nums; /* sayı tabloları hizalanır */
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ─────────── App shell ─────────── */
.app {
  display: grid;
  grid-template-columns: var(--sb-w) 1fr;
  min-height: 100vh;
}
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.page {
  flex: 1;
  padding: 28px 40px 48px;
  width: 100%;
}

/* ─────────── Sidebar ─────────── */
.sidebar {
  background: var(--navy);
  color: #c6cde0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.sb-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sb-logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--brand);
  color: white;
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
  letter-spacing: -.5px;
}
.sb-brand-title { color: white; font-weight: 700; font-size: 15px; letter-spacing: -.3px; }
.sb-brand-sub { color: var(--ink-3); font-size: 11px; font-weight: 500; letter-spacing: .3px; }

.sb-nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.sb-nav::-webkit-scrollbar { width: 6px; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px; }

.sb-group { margin-top: 14px; }
.sb-group:first-child { margin-top: 4px; }
.sb-group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #6d7a99;
  font-weight: 600;
  padding: 6px 12px 8px;
}
.sb-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: #c6cde0;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
  transition: background .1s;
}
.sb-item:hover { background: var(--navy-2); color: white; }
.sb-item.is-active {
  background: var(--navy-3);
  color: white;
  border-left-color: var(--brand);
}
.sb-ico {
  width: 18px; text-align: center;
  color: #6d7a99; font-size: 14px;
}
.sb-item.is-active .sb-ico,
.sb-item:hover .sb-ico { color: var(--brand); }

.sb-foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.sb-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sb-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand);
  color: white;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.sb-user-meta { min-width: 0; }
.sb-user-name { color: white; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { color: #8792ae; font-size: 11px; }

/* ─────────── Topbar ─────────── */
.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 14px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-menu { display: none; }
.topbar-search { flex: 1; max-width: 480px; }
.input-search {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-family: inherit; font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input-search:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: var(--surface); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ─────────── Buttons ─────────── */
.btn-primary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px;
  font-size: 13px; font-weight: 600;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--brand);
  color: white;
}
.btn-primary:hover { background: var(--brand-deep); box-shadow: 0 6px 18px rgba(255,122,26,.35); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-2);
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--bad); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 15px;
}
.btn-icon:hover { border-color: var(--brand); color: var(--brand); }
.btn-chip {
  padding: 5px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  color: var(--ink-3);
}
.btn-chip.is-active { background: var(--ink); color: white; border-color: var(--ink); }

/* ─────────── Page header ─────────── */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-eyebrow {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--brand-deep);
  margin-bottom: 4px;
}
.page-title {
  font-size: 26px; font-weight: 700;
  letter-spacing: -.4px;
  color: var(--ink);
  margin: 0 0 4px;
  line-height: 1.2;
}
.page-sub { color: var(--ink-3); font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─────────── Cards ─────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card-pad { padding: 20px 22px; }
.card-flush { overflow: hidden; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.card-title {
  font-size: 16px; font-weight: 600;
  color: var(--ink);
  margin: 0;
}
.card-tools { display: flex; gap: 6px; }
.link-more { color: var(--brand-deep); font-size: 12px; font-weight: 600; }

/* ─────────── Metric ─────────── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.metric-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3);
}
.metric-value {
  font-family: var(--mono);
  font-size: 30px; font-weight: 600;
  color: var(--ink);
  margin-top: 6px;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
}
.metric-delta { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.metric-delta.pos { color: var(--ok); font-weight: 600; }
.metric-delta.neg { color: var(--bad); font-weight: 600; }

/* ─────────── Dashboard grid ─────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 22px;
}
.rank-list { list-style: none; padding: 0; margin: 0; }
.rank-list li {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-2);
}
.rank-list li:last-child { border-bottom: 0; }
.rank-i {
  font-family: var(--mono); font-weight: 600;
  color: var(--ink-4); font-size: 12px;
}
.rank-v { font-weight: 600; color: var(--ink-2); }
.rank-list li.empty { color: var(--ink-3); font-style: italic; display: block; text-align: center; }

/* ─────────── Filter bar ─────────── */
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-bar .input-search { flex: 1; min-width: 220px; height: 38px; }
.filter-bar .select {
  height: 38px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-family: inherit; font-size: 13px;
  color: var(--ink);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%236e7691' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  min-width: 140px;
}
.filter-bar .select:focus { border-color: var(--brand); }

/* ─────────── Form field (tekil) ─────────── */
.form-field { margin-bottom: 16px; }
.form-field label {
  display: block;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.input, .textarea, .select-field {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-family: inherit; font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 12px 14px; min-height: 100px; resize: vertical; }
.input:focus, .textarea:focus, .select-field:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.field-error { color: var(--bad); font-size: 12px; margin-top: 4px; }

/* ─────────── Table ─────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
.table thead th {
  background: var(--surface-2);
  text-align: left;
  padding: 12px 14px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}
.table tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.mono, .table th.mono { font-family: var(--mono); }
.cell-primary { font-weight: 600; color: var(--ink); }
.cell-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.empty { color: var(--ink-3); font-style: italic; text-align: center; padding: 32px; }

/* ─────────── Badges ─────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  border-radius: 999px;
  background: var(--line-2); color: var(--ink-2);
}
.badge-ok    { background: #e6f4eb; color: var(--ok); }
.badge-bad   { background: #fae4e4; color: var(--bad); }
.badge-warn  { background: #fdecd3; color: var(--warn); }
.badge-info  { background: #dfeaf7; color: var(--info); }
.badge-soft  { background: var(--brand-soft); color: var(--brand-deep); }
.badge-navy  { background: #dde3f0; color: var(--navy); }
.badge-muted { background: var(--line-2); color: var(--ink-3); }

/* ─────────── Alerts (Django messages) ─────────── */
.messages-area { padding: 12px 32px 0; display: flex; flex-direction: column; gap: 8px; }
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
}
.alert-success, .alert-info  { background: #e6f4eb; color: var(--ok); border-color: rgba(21,138,68,.2); }
.alert-warning { background: #fdecd3; color: var(--warn); border-color: rgba(217,119,6,.25); }
.alert-error, .alert-danger { background: #fae4e4; color: var(--bad); border-color: rgba(196,38,38,.25); }

/* ─────────── Pagination ─────────── */
.pagination {
  display: flex; gap: 4px; justify-content: center;
  margin-top: 20px;
}
.pagination a, .pagination span {
  min-width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px; font-weight: 500;
}
.pagination a:hover { border-color: var(--brand); color: var(--brand); }
.pagination .current { background: var(--brand); color: white; border-color: var(--brand); }

/* ─────────── A11y ─────────── */
.skip-to-content {
  position: absolute; top: 0; left: 0;
  transform: translateY(-100%);
  background: var(--brand);
  color: #fff;
  padding: 10px 18px;
  font-weight: 700;
  text-decoration: none;
  z-index: 10000;
  border-radius: 0 0 8px 0;
  transition: transform .15s ease;
}
.skip-to-content:focus {
  transform: translateY(0);
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
/* Focus visible — klavye odağı belirgin */
:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ─────────── Responsive ─────────── */
@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0;
    width: 280px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .topbar { padding: 0 16px; }
  .topbar-menu { display: grid; }
  .page { padding: 20px 16px 40px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .page-header { align-items: flex-start; }
}
@media (max-width: 520px) {
  .metric-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 22px; }
  .page-header { flex-direction: column; gap: 10px; }
  .page-actions { width: 100%; }
  .page-actions > * { flex: 1 1 auto; min-width: 0; justify-content: center; }
  .page-actions .btn-primary, .page-actions .btn-ghost, .page-actions .btn-secondary { font-size: 12.5px; padding: 8px 10px; }
  /* Tablo yatay kaydırma — taşmayı engeller */
  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
}
