/* ==========================================================================
   COMPONENTS.CSS — Ortak bileşen kütüphanesi (site + panel ortak kullanır)
   Bkz. docs/PLAN-01-TASARIM.md §2.4
   ========================================================================== */

/* ---------------------------------------------------------------------- *
 * BUTONLAR
 * ---------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  font-family: var(--font-base); font-weight: var(--fw-semibold); font-size: var(--fs-sm);
  border: 1px solid transparent; border-radius: var(--radius-style);
  padding: 11px 20px; cursor: pointer; white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  text-decoration: none; line-height: 1;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

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

.btn-ghost { background: transparent; border-color: transparent; color: var(--secondary); }
.btn-ghost:hover { background: var(--bg-soft); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--white); }
.btn-danger:hover { background: #B91C1C; border-color: #B91C1C; }

.btn-sm { padding: 7px 14px; font-size: var(--fs-xs); }
.btn-lg { padding: 15px 28px; font-size: var(--fs-base); }
.btn-block { display: flex; width: 100%; }
.btn-icon { padding: 10px; }

.btn .spinner { display: none; }
.btn.is-loading { color: transparent; position: relative; pointer-events: none; }
.btn.is-loading .spinner {
  display: block; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%;
  animation: spin .6s linear infinite;
}
.btn-outline.is-loading .spinner, .btn-ghost.is-loading .spinner {
  border-color: rgba(0,0,0,.15); border-top-color: var(--primary);
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--bg); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-muted); }
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn.is-active { color: var(--danger); border-color: var(--danger); }

/* ---------------------------------------------------------------------- *
 * İKON
 * ---------------------------------------------------------------------- */
.icon { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }

/* ---------------------------------------------------------------------- *
 * LOGO ROZETİ (site header + panel sidebar ortak kullanır)
 * ---------------------------------------------------------------------- */
.brand__mark { width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: var(--fs-lg); flex-shrink: 0; }

/* ---------------------------------------------------------------------- *
 * GRID YARDIMCILARI (site + panel ortak kullanır)
 * ---------------------------------------------------------------------- */
.grid { display: grid; gap: var(--sp-6); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1024px) { .grid-6 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-6 { grid-template-columns: repeat(2, 1fr); } .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------------- *
 * ROZET / ETİKET
 * ---------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  padding: 5px 12px; border-radius: var(--radius-pill); line-height: 1;
}
.badge-sale   { background: var(--accent-light); color: var(--accent); }
.badge-rent   { background: var(--accent-rent-light); color: var(--accent-rent); }
.badge-devren { background: var(--accent-devren-light); color: var(--accent-devren); }
.badge-new    { background: var(--info-light); color: var(--info); }
.badge-hot    { background: var(--danger-light); color: var(--danger); }
.badge-price-drop { background: var(--warning-light); color: var(--warning); }
.badge-neutral { background: var(--bg-soft); color: var(--text-muted); }
.badge-active  { background: var(--success-light); color: var(--success); }
.badge-passive { background: var(--bg-soft); color: var(--text-faint); }
.badge-pending { background: var(--warning-light); color: var(--warning); }
.badge-sold    { background: #EDEDED; color: var(--text-muted); }

/* ---------------------------------------------------------------------- *
 * İLAN KARTI
 * ---------------------------------------------------------------------- */
.listing-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md);
  overflow: hidden; box-shadow: var(--shadow-card); transition: box-shadow var(--transition-base), transform var(--transition-base);
  display: flex; flex-direction: column; height: 100%;
}
.listing-card:hover { box-shadow: var(--shadow-pop); transform: translateY(-2px); }

.listing-card__media { position: relative; aspect-ratio: 4 / 3; background: var(--bg-soft); overflow: hidden; }
.listing-card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--transition-base); }
.listing-card:hover .listing-card__media img { transform: scale(1.04); }

.listing-card__badges { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.listing-card__corner { position: absolute; top: 12px; right: 12px; }

.listing-card__fav {
  position: absolute; bottom: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.92); border: none; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted); box-shadow: var(--shadow-card);
}
.listing-card__fav:hover { color: var(--danger); }
.listing-card__fav.is-active { color: var(--danger); }
.listing-card__fav.is-active .icon { fill: currentColor; }

.listing-card__photo-count {
  position: absolute; bottom: 12px; left: 12px; background: rgba(20,32,46,.72); color: #fff;
  font-size: var(--fs-xs); padding: 4px 9px; border-radius: var(--radius-pill); display: flex; align-items: center; gap: 4px;
}

.listing-card__body { padding: var(--sp-4); display: flex; flex-direction: column; gap: 8px; flex: 1; }
.listing-card__price { font-size: var(--fs-xl); }
.listing-card__price small { font-size: var(--fs-xs); font-weight: var(--fw-regular); color: var(--text-muted); }
.listing-card__title { font-size: var(--fs-base); font-weight: var(--fw-medium); color: var(--text); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.listing-card__location { display: flex; align-items: center; gap: 5px; font-size: var(--fs-sm); color: var(--text-muted); }

.listing-card__specs { display: flex; flex-wrap: wrap; gap: 14px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }
.listing-card__spec { display: flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--text-muted); }
.listing-card__spec .icon { color: var(--text-faint); }

/* Liste görünümü (yatay kart) */
.listing-card--row { flex-direction: row; }
.listing-card--row .listing-card__media { width: 260px; flex-shrink: 0; aspect-ratio: auto; }
.listing-card--row .listing-card__body { flex: 1; }
@media (max-width: 768px) {
  .listing-card--row { flex-direction: column; }
  .listing-card--row .listing-card__media { width: 100%; aspect-ratio: 4/3; }
}

/* ---------------------------------------------------------------------- *
 * FORM ELEMANLARI
 * ---------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field__label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--secondary); }
.field__label .req { color: var(--danger); }
.field__hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field__error { font-size: var(--fs-xs); color: var(--danger); }

.input, .select, .textarea {
  width: 100%; font-family: var(--font-base); font-size: var(--fs-sm); color: var(--text);
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 11px 14px; transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.input.has-error, .select.has-error, .textarea.has-error { border-color: var(--danger); }
.textarea { resize: vertical; min-height: 110px; }

.select {
  appearance: none; -webkit-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='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px;
}

.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.input-icon .input { padding-left: 40px; }

.checkbox, .radio { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); cursor: pointer; user-select: none; }
.checkbox input, .radio input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }

.chip-check {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill); font-size: var(--fs-sm); cursor: pointer; user-select: none;
  transition: all var(--transition-fast); background: var(--bg);
}
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check:has(input:checked) { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }

.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-md); padding: var(--sp-8);
  text-align: center; color: var(--text-muted); cursor: pointer; transition: border-color var(--transition-fast), background var(--transition-fast);
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--primary); background: var(--primary-light); }

/* Fiyat / m² aralık slider */
.range-slider { position: relative; height: 4px; background: var(--border); border-radius: 2px; margin: 24px 4px 8px; }
.range-slider__track { position: absolute; height: 4px; background: var(--primary); border-radius: 2px; }
.range-slider input[type="range"] {
  position: absolute; top: -8px; width: 100%; height: 20px; background: transparent; appearance: none; pointer-events: none; margin: 0;
}
.range-slider input[type="range"]::-webkit-slider-thumb {
  appearance: none; pointer-events: all; width: 18px; height: 18px; border-radius: 50%;
  background: var(--white); border: 3px solid var(--primary); cursor: pointer; box-shadow: var(--shadow-card);
}

/* ---------------------------------------------------------------------- *
 * MODAL / DRAWER
 * ---------------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(20,32,46,.55); z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity var(--transition-base);
}
.overlay.is-open { opacity: 1; pointer-events: all; }

.modal {
  position: fixed; z-index: 201; background: var(--bg); border-radius: var(--radius-lg);
  top: 50%; left: 50%; transform: translate(-50%, -48%); width: min(560px, calc(100vw - 32px));
  max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-pop);
  opacity: 0; pointer-events: none; transition: opacity var(--transition-base), transform var(--transition-base);
}
.modal.is-open { opacity: 1; pointer-events: all; transform: translate(-50%, -50%); }
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-6); border-bottom: 1px solid var(--border); }
.modal__body { padding: var(--sp-6); }
.modal__close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; }

@media (max-width: 768px) {
  .modal {
    top: auto; bottom: 0; left: 0; transform: translateY(100%);
    width: 100%; max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .modal.is-open { transform: translateY(0); }
}

/* ---------------------------------------------------------------------- *
 * TOAST
 * ---------------------------------------------------------------------- */
.toast-stack { position: fixed; top: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; width: min(340px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; background: var(--bg); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop); padding: 14px 16px; border-left: 4px solid var(--info);
  animation: toast-in .25s ease;
}
.toast-success { border-color: var(--success); }
.toast-error { border-color: var(--danger); }
.toast-warning { border-color: var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }

/* ---------------------------------------------------------------------- *
 * SEKME (TABS)
 * ---------------------------------------------------------------------- */
.tabs { display: flex; gap: var(--sp-2); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs__item {
  padding: 12px 4px; margin-right: 24px; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-muted);
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; background: none; border-top: none; border-left: none; border-right: none;
}
.tabs__item.is-active { color: var(--primary); border-color: var(--primary); }

[data-tab-panel-group] { display: none; }
[data-tab-panel-group].is-active { display: block; }

/* ---------------------------------------------------------------------- *
 * BREADCRUMB
 * ---------------------------------------------------------------------- */
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: var(--fs-sm); color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb__sep { color: var(--text-faint); }

/* ---------------------------------------------------------------------- *
 * SAYFALAMA
 * ---------------------------------------------------------------------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; }
.pagination a, .pagination span {
  min-width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); font-size: var(--fs-sm); color: var(--text); border: 1px solid transparent;
}
.pagination a:hover { background: var(--bg-soft); }
.pagination .is-current { background: var(--primary); color: var(--white); font-weight: var(--fw-semibold); }
.pagination .is-disabled { color: var(--text-faint); pointer-events: none; }

/* ---------------------------------------------------------------------- *
 * AKORDEON
 * ---------------------------------------------------------------------- */
.accordion__item { border-bottom: 1px solid var(--border); }
.accordion__trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: none; border: none; text-align: left; padding: 16px 2px; font-weight: var(--fw-medium); font-size: var(--fs-sm);
  cursor: pointer; color: var(--secondary);
}
.accordion__trigger .icon { transition: transform var(--transition-fast); color: var(--text-muted); }
.accordion__item.is-open .accordion__trigger .icon { transform: rotate(180deg); }
.accordion__panel { max-height: 0; overflow: hidden; transition: max-height var(--transition-base); }
.accordion__item.is-open .accordion__panel { max-height: 800px; }
.accordion__panel-inner { padding: 0 2px 16px; color: var(--text-muted); font-size: var(--fs-sm); }

/* ---------------------------------------------------------------------- *
 * BOŞ DURUM
 * ---------------------------------------------------------------------- */
.empty-state { text-align: center; padding: var(--sp-16) var(--sp-4); color: var(--text-muted); }
.empty-state svg { width: 96px; height: 96px; margin: 0 auto var(--sp-4); color: var(--border-strong); }
.empty-state h3 { color: var(--secondary); margin-bottom: 6px; }
.empty-state p { max-width: 360px; margin: 0 auto var(--sp-6); }

/* ---------------------------------------------------------------------- *
 * SKELETON
 * ---------------------------------------------------------------------- */
.skeleton { background: linear-gradient(90deg, var(--bg-soft) 25%, #ECEEF1 37%, var(--bg-soft) 63%); background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-card { border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); }
.skeleton-card .skeleton-media { aspect-ratio: 4/3; border-radius: 0; }
.skeleton-card .skeleton-line { height: 14px; margin: 12px 16px; }
.skeleton-card .skeleton-line.w-60 { width: 60%; }
.skeleton-card .skeleton-line.w-40 { width: 40%; }

/* ---------------------------------------------------------------------- *
 * KART / PANEL (genel amaçlı beyaz kutu)
 * ---------------------------------------------------------------------- */
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
.card__header { padding: var(--sp-4) var(--sp-6); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card__body { padding: var(--sp-6); }

/* ---------------------------------------------------------------------- *
 * TABLO (panel ekranlarında ortak)
 * ---------------------------------------------------------------------- */
.table-scroll { overflow-x: auto; max-width: 100%; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table th { text-align: left; padding: 12px 16px; color: var(--text-muted); font-weight: var(--fw-medium); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:hover td { background: var(--bg-soft); }

/* ---------------------------------------------------------------------- *
 * TOGGLE SWITCH (aktif/pasif)
 * ---------------------------------------------------------------------- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track { position: absolute; inset: 0; background: var(--border-strong); border-radius: var(--radius-pill); transition: background var(--transition-fast); cursor: pointer; }
.switch__track::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: var(--white); border-radius: 50%; transition: transform var(--transition-fast); }
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::before { transform: translateX(18px); }

/* ---------------------------------------------------------------------- *
 * STAT KARTI (panel dashboard)
 * ---------------------------------------------------------------------- */
.stat-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--sp-6); display: flex; flex-direction: column; gap: 6px; }
.stat-card__top { display: flex; align-items: center; justify-content: space-between; }
.stat-card__icon { width: 40px; height: 40px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; background: var(--primary-light); color: var(--primary); }
.stat-card__value { font-size: var(--fs-3xl); font-weight: var(--fw-bold); color: var(--secondary); }
.stat-card__label { font-size: var(--fs-sm); color: var(--text-muted); }
.stat-card__delta { font-size: var(--fs-xs); font-weight: var(--fw-medium); display: inline-flex; align-items: center; gap: 3px; }
.stat-card__delta.is-up { color: var(--success); }
.stat-card__delta.is-down { color: var(--danger); }
