/* ==========================================================================
   DAVETLE DESIGN SYSTEM — COMPONENTS
   Tüm bileşenler token'lara başvurur; ham değer kullanılmaz.
   Durum önceliği: disabled > loading > active > focus > hover > default
   ========================================================================== */

/* --------------------------------------------------------------------------
   BUTTON
   Varyantlar: .btn--primary (varsayılan eylem), .btn--secondary, .btn--outline,
   .btn--ghost, .btn--danger, .btn--gold (marka vurgusu)
   Boyutlar: .btn--sm, .btn--lg (varsayılan: md)
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-height-md);
  min-height: var(--touch-target);
  padding: 0 var(--btn-padding-x-md);
  border-radius: var(--btn-radius);
  font-size: var(--btn-font-size);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  border: 1px solid transparent;
  transition: background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.btn--primary {
  background: var(--action-primary);
  color: var(--action-primary-fg);
  box-shadow: var(--shadow-xs);
}

.btn--primary:hover { background: var(--action-primary-hover); }
.btn--primary:active { background: var(--action-primary-active); }

.btn--secondary {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn--secondary:hover { background: var(--border-default); }

.btn--outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn--outline:hover {
  border-color: var(--text-tertiary);
  background: var(--bg-subtle);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn--ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn--danger {
  background: var(--status-danger);
  color: #FFFFFF;
}

.btn--danger:hover { background: var(--status-danger-strong); }

.btn--gold {
  background: var(--accent);
  color: var(--color-stone-950);
  box-shadow: var(--shadow-xs);
}

.btn--gold:hover { background: var(--accent-strong); }

.btn--sm {
  height: var(--btn-height-sm);
  padding: 0 var(--btn-padding-x-sm);
  font-size: var(--text-xs);
}

.btn--lg {
  height: var(--btn-height-lg);
  padding: 0 var(--btn-padding-x-lg);
  font-size: var(--btn-font-size-lg);
  border-radius: var(--radius-lg);
}

.btn--block {
  width: 100%;
}

/* Yükleniyor durumu: <button class="btn btn--primary is-loading"> */
.btn.is-loading {
  pointer-events: none;
  position: relative;
  color: transparent;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-full);
  color: var(--action-primary-fg);
  animation: spin 0.7s linear infinite;
}

.btn--secondary.is-loading::after,
.btn--outline.is-loading::after,
.btn--ghost.is-loading::after {
  color: var(--text-primary);
}

.btn--gold.is-loading::after {
  color: var(--color-stone-950);
}

/* İkon butonu (yalnızca ikon; aria-label zorunludur) */
.btn--icon {
  width: var(--btn-height-md);
  min-width: var(--touch-target);
  padding: 0;
}

.btn--icon.btn--sm { width: var(--btn-height-sm); }
.btn--icon.btn--lg { width: var(--btn-height-lg); }

/* --------------------------------------------------------------------------
   INPUT / FORM
   Yapı: .field > label.field__label + .input + .field__hint | .field__error
   -------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.field__label .req {
  color: var(--status-danger);
}

.field__hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.field__error {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--status-danger);
}

.input,
.select,
.textarea {
  width: 100%;
  height: var(--input-height);
  padding: 0 var(--input-padding-x);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  font-size: var(--text-base);
  color: var(--text-primary);
  transition: border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.textarea {
  height: auto;
  min-height: 6.5rem;
  padding: var(--space-3) var(--input-padding-x);
  resize: vertical;
  line-height: var(--leading-normal);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-tertiary);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--input-border-hover);
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  outline: none;
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--bg-subtle);
  color: var(--text-disabled);
  cursor: not-allowed;
}

.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea {
  border-color: var(--status-danger);
}

.field.has-error .input:focus-visible,
.field.has-error .select:focus-visible,
.field.has-error .textarea:focus-visible {
  box-shadow: 0 0 0 3px var(--status-danger-bg);
}

.select {
  appearance: none;
  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='%2378716A' 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 var(--space-3) center;
  padding-right: var(--space-10);
}

/* --------------------------------------------------------------------------
   CHECKBOX & RADIO
   -------------------------------------------------------------------------- */

.checkbox,
.radio {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  min-height: var(--touch-target);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.checkbox input[type="checkbox"],
.radio input[type="radio"] {
  appearance: none;
  flex: none;
  width: var(--checkbox-size);
  height: var(--checkbox-size);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.checkbox input[type="checkbox"] {
  border-radius: var(--checkbox-radius);
}

.radio input[type="radio"] {
  border-radius: var(--radius-full);
}

.checkbox input[type="checkbox"]:checked,
.radio input[type="radio"]:checked {
  background: var(--action-primary);
  border-color: var(--action-primary);
}

.checkbox input[type="checkbox"]:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FAF9F7' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-size: 70%;
  background-position: center;
  background-repeat: no-repeat;
}

.radio input[type="radio"]:checked {
  box-shadow: inset 0 0 0 4px var(--bg-surface);
}

.checkbox input[type="checkbox"]:disabled,
.radio input[type="radio"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   SWITCH
   Yapı: <label class="switch"><input type="checkbox" role="switch"><span class="switch__track"></span> Metin</label>
   -------------------------------------------------------------------------- */

.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  min-height: var(--touch-target);
  font-size: var(--text-sm);
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch__track {
  flex: none;
  width: var(--switch-width);
  height: var(--switch-height);
  background: var(--switch-off-bg);
  border-radius: var(--radius-full);
  position: relative;
  transition: background-color var(--duration-base) var(--ease-out);
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  translate: 0 -50%;
  width: var(--switch-thumb);
  height: var(--switch-thumb);
  background: #FFFFFF;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  transition: left var(--duration-base) var(--ease-out);
}

.switch input:checked + .switch__track {
  background: var(--switch-on-bg);
}

.switch input:checked + .switch__track::after {
  left: calc(100% - var(--switch-thumb) - 3px);
}

.switch input:focus-visible + .switch__track {
  box-shadow: 0 0 0 2px var(--ring-offset), 0 0 0 4px var(--ring-color);
}

.switch input:disabled + .switch__track {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   CARD
   Varyantlar: .card--interactive (tıklanabilir), .card--elevated
   -------------------------------------------------------------------------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}

.card__body {
  padding: var(--card-padding);
}

.card__header {
  padding: var(--card-padding) var(--card-padding) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.card__title {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-normal);
}

.card__description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.card__footer {
  padding: 0 var(--card-padding) var(--card-padding);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.card--elevated {
  border: none;
  box-shadow: var(--shadow-lg);
}

.card--interactive {
  cursor: pointer;
  transition: box-shadow var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out),
    transform var(--duration-base) var(--ease-out);
}

.card--interactive:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-default);
  transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   BADGE
   Varyantlar: --neutral (varsayılan), --gold, --success, --danger, --warning, --info, --outline
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--badge-radius);
  font-size: var(--badge-font-size);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.badge--gold { background: var(--accent-subtle); color: var(--text-brand); }
.badge--success { background: var(--status-success-bg); color: var(--status-success); }
.badge--danger { background: var(--status-danger-bg); color: var(--status-danger); }
.badge--warning { background: var(--status-warning-bg); color: var(--status-warning); }
.badge--info { background: var(--status-info-bg); color: var(--status-info); }

.badge--outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   TABS
   Yapı: .tabs > .tabs__list[role=tablist] > .tabs__tab[role=tab]
         .tabs__panel[role=tabpanel]
   JS: /js/components/tabs.js
   -------------------------------------------------------------------------- */

.tabs__list {
  display: inline-flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  max-width: 100%;
  overflow-x: auto;
}

.tabs__tab {
  padding: var(--space-2) var(--space-4);
  min-height: 2.25rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.tabs__tab:hover {
  color: var(--text-primary);
}

.tabs__tab[aria-selected="true"] {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.tabs__panel {
  padding-top: var(--space-5);
}

.tabs__panel[hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   DROPDOWN
   Yapı: .dropdown[data-dropdown] > [data-dropdown-trigger] + .dropdown__menu
   JS: /js/components/dropdown.js
   -------------------------------------------------------------------------- */

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown__menu {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  z-index: var(--z-dropdown);
  min-width: var(--dropdown-min-width);
  padding: var(--space-2);
  background: var(--dropdown-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--dropdown-radius);
  box-shadow: var(--dropdown-shadow);
  display: none;
}

.dropdown__menu--right {
  left: auto;
  right: 0;
}

.dropdown.is-open .dropdown__menu {
  display: block;
  animation: fade-up var(--duration-base) var(--ease-out);
}

.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-primary);
  text-align: left;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.dropdown__item:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.dropdown__item--danger {
  color: var(--status-danger);
}

.dropdown__item--danger:hover {
  background: var(--status-danger-bg);
  color: var(--status-danger);
}

.dropdown__divider {
  height: 1px;
  margin: var(--space-2) calc(var(--space-2) * -1);
  background: var(--border-subtle);
}

/* --------------------------------------------------------------------------
   MODAL
   Yapı: .modal[data-modal][hidden] > .modal__backdrop + .modal__panel
   JS: /js/components/modal.js
   -------------------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-4);
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  z-index: var(--z-modal-backdrop);
  background: var(--bg-backdrop);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in var(--duration-base) var(--ease-out);
}

.modal__panel {
  position: relative;
  z-index: var(--z-modal);
  width: 100%;
  max-width: var(--modal-max-width);
  max-height: calc(100dvh - var(--space-8));
  overflow-y: auto;
  background: var(--modal-bg);
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow);
  animation: slide-up var(--duration-slow) var(--ease-out);
}

@media (min-width: 640px) {
  .modal {
    align-items: center;
  }

  .modal__panel {
    animation: scale-in var(--duration-slow) var(--ease-out);
  }
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-6) 0;
}

.modal__title {
  font-family: var(--font-sans);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
}

.modal__close {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-tertiary);
  transition: background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.modal__close:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.modal__body {
  padding: var(--space-4) var(--space-6);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: 0 var(--space-6) var(--space-6);
}

/* --------------------------------------------------------------------------
   TOAST
   Kapsayıcı _Layout.cshtml içinde: #toast-region
   JS: /js/components/toast.js — App.toast.show({...})
   -------------------------------------------------------------------------- */

.toast-region {
  position: fixed;
  bottom: var(--space-4);
  left: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

@media (min-width: 640px) {
  .toast-region {
    left: auto;
    right: var(--space-6);
    bottom: var(--space-6);
    width: 22rem;
  }
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--toast-bg);
  color: var(--toast-fg);
  border-radius: var(--toast-radius);
  box-shadow: var(--toast-shadow);
  animation: slide-in-up var(--duration-slow) var(--ease-out);
}

.toast.is-leaving {
  animation: fade-out var(--duration-base) var(--ease-in) forwards;
}

.toast__icon {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.125rem;
}

.toast__icon--success { color: #4ADE80; }
.toast__icon--danger { color: #F87171; }
.toast__icon--info { color: #93C5FD; }

.toast__content {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.toast__message {
  font-size: var(--text-xs);
  opacity: 0.8;
  margin-top: 2px;
}

.toast__close {
  flex: none;
  color: inherit;
  opacity: 0.6;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: opacity var(--duration-fast) var(--ease-out);
}

.toast__close:hover {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   EMPTY STATE
   -------------------------------------------------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-4);
  padding: var(--space-16) var(--space-6);
}

.empty-state__icon {
  width: 3.5rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xl);
  background: var(--accent-muted);
  color: var(--text-brand);
}

.empty-state__title {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.empty-state__description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 28rem;
}

/* --------------------------------------------------------------------------
   LOADING — SPINNER
   -------------------------------------------------------------------------- */

.spinner {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 2.5px solid var(--border-default);
  border-top-color: var(--text-primary);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}

.spinner--sm { width: 1rem; height: 1rem; border-width: 2px; }
.spinner--lg { width: 2.25rem; height: 2.25rem; border-width: 3px; }

.spinner--gold {
  border-color: var(--accent-subtle);
  border-top-color: var(--accent-strong);
}

/* --------------------------------------------------------------------------
   SKELETON
   -------------------------------------------------------------------------- */

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--skeleton-base);
  border-radius: var(--radius-sm);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  translate: -100% 0;
  background: linear-gradient(
    90deg,
    transparent,
    var(--skeleton-highlight),
    transparent
  );
  animation: shimmer 1.6s var(--ease-in-out) infinite;
}

.skeleton--text { height: 0.875rem; }
.skeleton--title { height: 1.5rem; width: 60%; }
.skeleton--avatar { width: 2.75rem; height: 2.75rem; border-radius: var(--radius-full); }
.skeleton--thumb { aspect-ratio: 4 / 3; border-radius: var(--radius-lg); }
.skeleton--btn { height: var(--btn-height-md); width: 7rem; border-radius: var(--btn-radius); }

/* --------------------------------------------------------------------------
   ACCORDION
   Yapı (JS gerektirmez — native details/summary):
     <div class="accordion">
       <details class="accordion__item">
         <summary class="accordion__summary">
           Soru
           <svg class="accordion__icon">...</svg>
         </summary>
         <div class="accordion__content">Cevap</div>
       </details>
     </div>
   -------------------------------------------------------------------------- */

.accordion {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.accordion__item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out);
}

.accordion__item[open] {
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
}

.accordion__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: var(--touch-target);
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  list-style: none;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  transition: background-color var(--duration-fast) var(--ease-out);
}

.accordion__summary::-webkit-details-marker {
  display: none;
}

.accordion__summary:hover {
  background: var(--bg-subtle);
}

.accordion__icon {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  color: var(--text-tertiary);
  transition: transform var(--duration-base) var(--ease-out);
}

.accordion__item[open] .accordion__icon {
  transform: rotate(180deg);
}

.accordion__content {
  padding: 0 var(--space-5) var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  animation: fade-up var(--duration-base) var(--ease-out);
}

.accordion__content p {
  max-width: none;
}

/* --------------------------------------------------------------------------
   DIVIDER & YARDIMCI GÖRSEL ÖGELER
   -------------------------------------------------------------------------- */

.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-6) 0;
}

.kbd {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
}
