/* Bileşenler: buton, kart, form, rozet, uyarı, tablo, boş durum, modal, toast, iskelet */

/* ---------- Butonlar ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 40px; padding: 0 var(--s-4);
  font: inherit; font-weight: 700; font-size: var(--fs-md); line-height: 1;
  color: var(--btn-fg); background: var(--btn-bg); border: 1px solid var(--btn-bd);
  border-radius: var(--r-md); cursor: pointer; user-select: none; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
  position: relative; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--n-400); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn .ico { width: 18px; height: 18px; }
.btn--primary { --btn-bg: var(--primary); --btn-fg: var(--primary-text); --btn-bd: var(--primary); box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, var(--sh-1); }
.btn--primary:hover { --btn-bg: var(--primary-hover); --btn-bd: var(--primary-hover); }
.btn--secondary { --btn-bg: var(--primary-soft); --btn-fg: var(--primary); --btn-bd: transparent; }
.btn--secondary:hover { --btn-bd: var(--brand-200); }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-2); }
.btn--ghost:hover { --btn-bg: var(--bg-sunken); color: var(--text); }
.btn--danger { --btn-bg: var(--bad-600); --btn-fg: #fff; --btn-bd: var(--bad-600); }
.btn--danger:hover { --btn-bg: var(--bad-700); --btn-bd: var(--bad-700); }
.btn--danger-soft { --btn-bg: var(--bad-50); --btn-fg: var(--bad-700); --btn-bd: transparent; }
.btn--danger-soft:hover { --btn-bd: var(--bad-100); }
.btn--success { --btn-bg: var(--ok-600); --btn-fg: #fff; --btn-bd: var(--ok-600); }
.btn--success:hover { --btn-bg: var(--ok-700); --btn-bd: var(--ok-700); }
.btn--warning { --btn-bg: var(--warn-50); --btn-fg: var(--warn-700); --btn-bd: var(--warn-100); }
.btn--sm { min-height: 32px; padding: 0 var(--s-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn--sm .ico { width: 16px; height: 16px; }
.btn--lg { min-height: 48px; padding: 0 var(--s-6); font-size: var(--fs-lg); border-radius: var(--r-lg); }
.btn--icon { padding: 0; width: 40px; }
.btn--icon.btn--sm { width: 32px; }
.btn--block { width: 100%; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--btn-fg) transparent var(--btn-fg) transparent;
  animation: spin .7s linear infinite; opacity: .9;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; gap: var(--s-2); flex-wrap: wrap; }
form.inline { display: inline; margin: 0; }

/* ---------- Kart ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.card__head h2, .card__head h3 { margin: 0; font-size: var(--fs-lg); display: flex; align-items: center; gap: var(--s-2); }
.card__body { padding: var(--s-5); }
.card__foot { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); display: flex; gap: var(--s-2); justify-content: flex-end; flex-wrap: wrap; }
.card--flush .card__body { padding: 0; }
.card--pad { padding: var(--s-5); }
@media (max-width: 720px) { .card__body, .card--pad { padding: var(--s-4); } .card__head { padding: var(--s-3) var(--s-4); } }

/* ---------- Form ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4) var(--s-5); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 700; font-size: var(--fs-sm); color: var(--text); }
.field .req::after { content: " *"; color: var(--bad-600); }
.hint { font-size: var(--fs-xs); color: var(--text-3); }
.field-error { font-size: var(--fs-xs); color: var(--bad-700); font-weight: 600; display: none; }
.field.has-error .field-error { display: block; }
.field.has-error .input, .field.has-error .select { border-color: var(--bad-600); }
.input, .select, .textarea, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: 9px 12px;
  font: inherit; font-size: var(--fs-md); color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea, textarea.input { min-height: 88px; resize: vertical; line-height: 1.45; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover { border-color: var(--n-400); }
.input:focus, .select:focus, .textarea:focus, select.input:focus, textarea.input:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--focus); }
.select, select.input { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378746c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group .btn { border-radius: 0 var(--r-md) var(--r-md) 0; margin-left: -1px; }
.input-icon { position: relative; }
.input-icon .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 38px; }
.check { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; margin-top: var(--s-5); }

/* Anahtar (switch) */
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 42px; height: 24px; border-radius: 999px; background: var(--n-300); position: relative; transition: background var(--dur) var(--ease); flex: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); transition: transform var(--dur) var(--ease); }
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--focus); }

/* Seçilebilir kart (izin/şube kutuları) */
.option-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-2); }
.option { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); border: 1px solid var(--line-strong); border-radius: var(--r-md); cursor: pointer; background: var(--surface); font-weight: 600; transition: border-color var(--dur), background var(--dur); }
.option:hover { border-color: var(--n-400); }
.option input { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }
.option:has(input:checked) { border-color: var(--brand-400); background: var(--primary-soft); }
.option .ico { color: var(--text-3); }

/* ---------- Rozet / çip ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 700; background: var(--bg-sunken); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge--plain::before { display: none; }
.badge--ok { background: var(--ok-50); color: var(--ok-700); }
.badge--warn { background: var(--warn-50); color: var(--warn-700); }
.badge--bad { background: var(--bad-50); color: var(--bad-700); }
.badge--info { background: var(--info-50); color: var(--info-700); }
.badge--brand { background: var(--primary-soft); color: var(--primary); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--r-full); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font-weight: 700; font-size: var(--fs-sm); white-space: nowrap; cursor: pointer; }
.chip:hover { text-decoration: none; color: var(--text); border-color: var(--n-400); }
.chip.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chips { display: flex; gap: var(--s-2); overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

/* ---------- Uyarı ---------- */
.alert { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); border: 1px solid transparent; font-weight: 600; margin-bottom: var(--s-4); }
.alert .ico { margin-top: 1px; }
.alert--ok { background: var(--ok-50); border-color: var(--ok-100); color: var(--ok-700); }
.alert--warn { background: var(--warn-50); border-color: var(--warn-100); color: var(--warn-700); }
.alert--bad { background: var(--bad-50); border-color: var(--bad-100); color: var(--bad-700); }
.alert--info { background: var(--info-50); border-color: var(--info-100); color: var(--info-700); }

/* ---------- Tablo (mobilde kart) ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-md); }
.table th { text-align: left; font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: var(--s-3) var(--s-4); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .t-right { text-align: right; }
.table .t-actions { text-align: right; white-space: nowrap; }
.table .t-actions .btn-group { justify-content: flex-end; flex-wrap: nowrap; }
.thumb { width: 44px; height: 44px; border-radius: var(--r-md); object-fit: cover; border: 1px solid var(--line); background: var(--bg-sunken); display: inline-flex; align-items: center; justify-content: center; color: var(--text-3); vertical-align: middle; }
.cell-title { font-weight: 700; color: var(--text); }
.cell-sub { font-size: var(--fs-xs); color: var(--text-3); }
@media (max-width: 760px) {
  .table--cards thead { display: none; }
  .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
  .table--cards tr { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); margin: 0 0 var(--s-3); padding: var(--s-2) var(--s-4); box-shadow: var(--sh-1); }
  .table--cards td { border: 0; padding: 7px 0; display: flex; justify-content: space-between; gap: var(--s-4); text-align: right; }
  .table--cards td::before { content: attr(data-label); font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); text-align: left; flex: none; }
  .table--cards td[data-label=""]::before { display: none; }
  .table--cards td.t-actions { justify-content: flex-start; border-top: 1px solid var(--line); margin-top: var(--s-2); padding-top: var(--s-3); }
  .table--cards td.t-actions .btn-group { flex-wrap: wrap; justify-content: flex-start; }
  .table--cards tbody tr:hover td { background: none; }
  .card--flush .table--cards { padding: var(--s-3); }
}

/* ---------- Boş durum ---------- */
.empty { text-align: center; padding: var(--s-10) var(--s-5); color: var(--text-2); }
.empty__icon { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; margin-bottom: var(--s-3); }
.empty__icon .ico { width: 26px; height: 26px; }
.empty h3 { color: var(--text); margin-bottom: var(--s-1); }
.empty p { max-width: 420px; margin: 0 auto var(--s-4); }

/* ---------- KPI ---------- */
.stat { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); }
.stat__label { display: flex; align-items: center; gap: var(--s-2); color: var(--text-2); font-weight: 700; font-size: var(--fs-sm); }
.stat__icon { width: 34px; height: 34px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; }
.stat__value { font-size: var(--fs-3xl); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat__meta { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; }

/* ---------- Araç çubuğu ---------- */
.toolbar { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--s-4); }
.toolbar .input, .toolbar .select { width: auto; min-width: 180px; }
.toolbar__grow { flex: 1; }
@media (max-width: 720px) { .toolbar .input, .toolbar .select { flex: 1 1 100%; min-width: 0; } }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: var(--s-5); overflow-x: auto; }
.tab { padding: var(--s-3) var(--s-4); font-weight: 700; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { text-decoration: none; color: var(--text); }
.tab.is-active { color: var(--primary); border-color: var(--primary); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 120; display: none; align-items: center; justify-content: center; padding: var(--s-4); }
.modal.is-open { display: flex; }
.modal__scrim { position: absolute; inset: 0; background: rgba(15, 14, 12, .5); animation: fade var(--dur) var(--ease); }
.modal__box { position: relative; width: min(480px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3); animation: pop 180ms var(--ease); }
.modal__box--wide { width: min(640px, 100%); }
.modal__head { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-5) var(--s-5) 0; }
.modal__head h2 { font-size: var(--fs-xl); margin: 0; }
.modal__body { padding: var(--s-3) var(--s-5) var(--s-5); color: var(--text-2); white-space: pre-line; }
.modal__foot { display: flex; gap: var(--s-2); justify-content: flex-end; padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line); }
.modal__icon { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--bad-50); color: var(--bad-600); }
.modal__icon--info { background: var(--primary-soft); color: var(--primary); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 130; right: var(--s-5); bottom: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--s-3); min-width: 260px; max-width: 420px; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--n-900); color: #fff; box-shadow: var(--sh-3); font-weight: 600; animation: pop 200ms var(--ease); }
.toast--ok .ico { color: #7ad69c; } .toast--bad .ico { color: #f29a94; } .toast--warn .ico { color: #f2c06b; }
:root[data-theme="dark"] .toast { background: #2a2c31; }
@media (max-width: 1023px) { .toasts { left: var(--s-4); right: var(--s-4); bottom: calc(var(--bottomnav-h) + var(--s-4) + env(safe-area-inset-bottom)); } .toast { max-width: none; } }

/* ---------- İskelet ---------- */
.skeleton { background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--line) 50%, var(--bg-sunken) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; border-radius: var(--r-sm); min-height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Sayfalama ---------- */
.pager { display: flex; gap: var(--s-1); align-items: center; justify-content: center; margin-top: var(--s-4); }
.pager a, .pager span { min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-md); font-weight: 700; color: var(--text-2); border: 1px solid var(--line); background: var(--surface); }
.pager .is-active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }

/* Liste satırı (kart içi) */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: var(--s-2) var(--s-5); }
.kv dt { color: var(--text-3); font-weight: 700; font-size: var(--fs-sm); }
.kv dd { margin: 0; font-weight: 600; }
.print-only, .report-print-head { display: none; }

/* Dosya seçici: tarayıcı dilinden bağımsız, sade görünüm (alan adı ve davranış aynı) */
.filepick { position: relative; display: flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: 6px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); background: var(--surface); cursor: pointer; }
.filepick input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.filepick:hover { border-color: var(--primary); }
.filepick:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.filepick__name { min-width: 0; color: var(--text-3); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filepick.is-picked .filepick__name { color: var(--text); font-weight: 600; }
