/* ══════════════════════════════════════════════════════════════════════════
   Ortak bileşenler — buton, form alanı, uyarı, tema düğmesi.
   Önek yok = ortak bileşen (kural.md §7.3).
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Buton ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 44px; padding: 0 var(--space-5);
  border: 1px solid transparent; border-radius: var(--radius-md);
  font-weight: 600; font-size: var(--text-sm);
  cursor: pointer; user-select: none;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn--primary { background: var(--color-primary); color: var(--color-text-invert); }
.btn--primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn--ghost { background: transparent; border-color: var(--color-border); color: var(--color-text); }
.btn--ghost:hover:not(:disabled) { background: var(--color-surface-2); }
.btn--block { width: 100%; }
.btn--icon { width: 40px; height: 40px; padding: 0; }

.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .btn__label { opacity: 0.8; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Form alanı ──────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field__label { font-size: var(--text-sm); font-weight: 600; color: var(--color-text); }
.field__control { position: relative; display: flex; align-items: center; }
.field__icon {
  position: absolute; left: var(--space-3); width: 18px; height: 18px;
  color: var(--color-text-muted); pointer-events: none;
}
.input {
  width: 100%; height: 46px;
  padding: 0 var(--space-4);
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.input::placeholder { color: var(--color-text-muted); opacity: 0.8; }
.input:hover { border-color: var(--color-text-muted); }
.input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 4px var(--color-focus); }
.input--with-icon { padding-left: 42px; }
.input--with-action { padding-right: 48px; }
.input[aria-invalid="true"] { border-color: var(--color-danger); }
.field__action {
  position: absolute; right: var(--space-1);
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--color-text-muted); cursor: pointer;
}
.field__action:hover { background: var(--color-surface-2); color: var(--color-text); }
.field__action svg { width: 18px; height: 18px; }
.field__error { font-size: var(--text-xs); color: var(--color-danger); min-height: 1em; }

.checkbox { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--color-primary); }

/* ── Uyarı ───────────────────────────────────────────────────────────────── */
.alert {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); border: 1px solid transparent;
  font-size: var(--text-sm);
}
.alert svg { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; }
.alert--danger  { background: var(--color-danger-soft);  color: var(--color-danger);  border-color: var(--color-danger-soft); }
.alert--success { background: var(--color-success-soft); color: var(--color-success); }
.alert--warning { background: var(--color-warning-soft); color: var(--color-warning); }

/* ── Tema düğmesi ────────────────────────────────────────────────────────── */
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.btn--danger { background: var(--color-danger); color: var(--color-text-invert); }
.btn--danger:hover:not(:disabled) { filter: brightness(0.92); }
.btn--sm { height: 32px; padding: 0 var(--space-3); font-size: var(--text-xs); }

.icon { width: 18px; height: 18px; flex: 0 0 auto; }
.spinner--lg { width: 28px; height: 28px; border-width: 3px; color: var(--color-primary); }

.input { appearance: none; }
select.input {
  padding-right: var(--space-8);
  background-image: linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%),
                    linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
/* Açılır liste tarayıcının kendi penceresidir. Bazı tarayıcılar (Chrome Linux / bazı Windows kurulumları, Safari)
   seçeneğin ZEMİNİNİ yok sayıp kendi penceresini çizer ama YAZI rengini uygular: tema renginden verilen yazı
   kendi zemininin üstüne düşer (beyaz üstüne beyaz). Sistem renkleri (Canvas / CanvasText) tarayıcının pencereyi
   çizdiği renk düzeniyle (color-scheme) her zaman eşleşir: zemin uygulansa da uygulanmasa da yazı okunur. */
select.input { color-scheme: inherit; }
select.input option,
select.input optgroup { background-color: Canvas; color: CanvasText; }
select.input option:disabled { color: GrayText; }
/* Destekleyen tarayıcıda (Chrome 135+) açılır listeyi panel kendisi çizer: tarayıcı / işletim sistemi penceresi
   yok, renkler tema değişkenlerinden. Desteklemeyen tarayıcı yukarıdaki yerel listeyi kullanır. */
@supports (appearance: base-select) {
  select.input, select.input::picker(select) { appearance: base-select; }
  select.input { display: flex; align-items: center; }
  select.input::picker-icon { display: none; } /* ok işareti background-image ile, diğer tarayıcılarla aynı */
  select.input::picker(select) {
    margin-block: var(--space-1); padding: var(--space-1);
    background: var(--color-surface); color: var(--color-text);
    border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  }
  select.input option {
    padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
    background: transparent; color: var(--color-text);
  }
  select.input option::checkmark { display: none; }
  select.input option:hover,
  select.input option:focus-visible { background: var(--color-surface-2); outline: none; }
  select.input option:checked { background: var(--color-primary-soft); color: var(--color-primary); font-weight: 600; }
  select.input option:disabled { color: var(--color-text-muted); background: transparent; }
}
select.input:disabled { opacity: 0.6; cursor: not-allowed; }
textarea.input { height: auto; min-height: 120px; padding: var(--space-3); font-family: var(--font-mono); font-size: var(--text-sm); resize: vertical; }
.input--sm { height: 36px; font-size: var(--text-sm); }
.field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ── Kart ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.card__title { font-size: var(--text-md); font-weight: 600; margin: 0; }
.card__body { padding: var(--space-5); }
.card__body--flush { padding: 0; }

/* ── Rozet ve nokta ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2); border-radius: 999px;
  font-size: var(--text-xs); font-weight: 600; white-space: nowrap;
  background: var(--color-surface-2); color: var(--color-text-muted);
}
.badge--success { background: var(--color-success-soft); color: var(--color-success); }
.badge--warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge--danger  { background: var(--color-danger-soft);  color: var(--color-danger); }
.badge--info    { background: var(--color-primary-soft); color: var(--color-primary); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.dot--on  { background: var(--color-success); box-shadow: 0 0 0 3px var(--color-success-soft); }
.dot--off { background: var(--color-border-strong); }

/* ── Tablo ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
  text-align: left; font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--color-text-muted); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--color-surface-2); }
.table__actions { display: flex; gap: var(--space-1); justify-content: flex-end; }
.table__muted { color: var(--color-text-muted); font-size: var(--text-xs); }
.mono { font-family: var(--font-mono); font-size: var(--text-xs); }

/* ── Araç çubuğu, sekme, sayfalama ───────────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.toolbar__grow { flex: 1 1 220px; }
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-border); overflow-x: auto; }
.tabs__btn {
  padding: var(--space-3) var(--space-4); border: 0; background: none; cursor: pointer;
  color: var(--color-text-muted); font-weight: 600; font-size: var(--text-sm);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs__btn:hover { color: var(--color-text); }
.tabs__btn.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.pager { display: flex; align-items: center; justify-content: center; gap: var(--space-3); padding: var(--space-4); }
.pager__info { font-size: var(--text-sm); color: var(--color-text-muted); }

/* ── Boş / yükleniyor ────────────────────────────────────────────────────── */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: var(--space-10) var(--space-4); color: var(--color-text-muted); text-align: center; }
.empty__icon { width: 36px; height: 36px; opacity: 0.6; }
.empty--error { color: var(--color-danger); }
.loading { display: flex; justify-content: center; padding: var(--space-10); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh var(--space-4) var(--space-4);
  background: var(--color-overlay); overflow-y: auto;
  animation: fade-in var(--duration) var(--ease);
}
.modal {
  width: 100%; background: var(--color-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); border: 1px solid var(--color-border);
  animation: rise var(--duration) var(--ease);
}
.modal--sm { max-width: 420px; }
.modal--md { max-width: 560px; }
.modal--lg { max-width: 820px; }
.modal__header { display: flex; justify-content: space-between; align-items: center; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); }
.modal__title { font-size: var(--text-lg); margin: 0; }
.modal__body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.modal__text { color: var(--color-text-muted); }
.modal__footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--color-border); }
.form-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ── Bildirim ────────────────────────────────────────────────────────────── */
.toast-host { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 60; display: flex; flex-direction: column; gap: var(--space-2); max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  background: var(--color-surface); border: 1px solid var(--color-border); box-shadow: var(--shadow-md);
  font-size: var(--text-sm); animation: rise var(--duration) var(--ease);
  transition: opacity 250ms, transform 250ms;
}
.toast--success .icon { color: var(--color-success); }
.toast--danger { border-color: var(--color-danger); }
.toast--danger .icon { color: var(--color-danger); }
.toast.is-leaving { opacity: 0; transform: translateX(16px); }

/* ── Anahtar (switch) ────────────────────────────────────────────────────── */
.switch { position: relative; width: 48px; height: 28px; border: 0; padding: 0; border-radius: 999px; background: var(--color-border-strong); cursor: pointer; transition: background var(--duration) var(--ease); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--color-knob); box-shadow: var(--shadow-sm); transition: transform var(--duration) var(--ease); }
.switch[aria-checked="true"] { background: var(--color-success); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.5; cursor: not-allowed; }
.switch.is-busy { opacity: 0.7; cursor: progress; }

/* ── Onay kutusu ızgarası ────────────────────────────────────────────────── */
.check-group { display: flex; flex-direction: column; gap: var(--space-2); }
.check-group__title { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }

/* ── İlerleme çubuğu ─────────────────────────────────────────────────────── */
.progress { position: relative; height: 8px; border-radius: 999px; background: var(--color-surface-2); overflow: hidden; min-width: 80px; }
.progress__bar { position: absolute; inset: 0 auto 0 0; width: var(--pct, 0%); background: var(--color-primary); border-radius: inherit; transition: width 400ms var(--ease); }
.progress__bar--success { background: var(--color-success); }
.progress__bar--danger { background: var(--color-danger); left: var(--from, 0%); }
.progress-summary { display: flex; flex-direction: column; gap: var(--space-1); min-width: 180px; }
.progress-summary__text { font-size: var(--text-xs); color: var(--color-text-muted); }
