/* /settings sahifasi uchun maxsus stillar.
 * Umumiy komponentlar (modal, spinner, bulk-bar, my-listings, file-grid) —
 * /assets/css/components/ ichida alohida fayllarda. */

/* ---------- Base ---------- */
html, body {
  margin: 0;
  padding: 0;
  background: var(--rtd-bg-subtle);
  color: var(--rtd-text-primary);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }

.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.s-top {
  background: #fff;
  border-bottom: 1px solid var(--rtd-border-color);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.s-top__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  font-size: 18px;
}
.s-top__brand img { width: 28px; height: 28px; }
.s-top__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--rtd-text-secondary);
}
.s-top__back {
  margin-left: auto;
  padding: 7px 14px;
  border: 1px solid var(--rtd-border-color);
  background: #fff;
  border-radius: 8px;
  font-size: 13px;
  color: var(--rtd-text-secondary);
  text-decoration: none;
}
.s-top__back:hover { background: var(--rtd-color-gray-50); }

/* ---------- Layout ---------- */
.s-wrap {
  max-width: 1080px;
  margin: 24px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
}
/* Jadvalli tab'lar (listings / templates / favorites) — kengroq joy kerak */
.s-wrap.is-wide { max-width: min(1600px, calc(100vw - 32px)); }
.s-nav {
  background: #fff;
  border: 1px solid var(--rtd-border-color);
  border-radius: 12px;
  padding: 8px;
  height: max-content;
  position: sticky;
  top: 80px;
}
.s-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--rtd-text-secondary);
  text-decoration: none;
  font-size: 14px;
}
.s-nav a:hover {
  background: var(--rtd-color-gray-50);
  color: var(--rtd-text-primary);
}
.s-nav a.is-active {
  background: var(--rtd-color-primary-soft);
  color: var(--rtd-color-primary-700);
  font-weight: 500;
}
.s-nav a svg { width: 18px; height: 18px; }

/* ---------- Cards ---------- */
.s-card {
  background: #fff;
  border: 1px solid var(--rtd-border-color);
  border-radius: 12px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
}
.s-card__head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--rtd-border-color);
}
.s-card__head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.s-card__head--danger h2 { color: var(--rtd-color-danger); }
.s-card__head p {
  margin: 4px 0 0;
  color: var(--rtd-text-muted);
  font-size: 13px;
}
.s-card__body { padding: 18px 20px; }

/* ---------- Forma ---------- */
.row {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}
.row label {
  font-size: 13px;
  font-weight: 500;
  color: var(--rtd-text-secondary);
  margin-bottom: 6px;
}
.row input[type="text"],
.row input[type="email"],
.row input[type="tel"],
.row input[type="password"],
.row select,
.row textarea {
  padding: 9px 12px;
  border: 1px solid var(--rtd-border-color);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--rtd-text-primary);
}
.row input:focus,
.row select:focus,
.row textarea:focus {
  outline: none;
  border-color: var(--rtd-color-primary);
  box-shadow: 0 0 0 3px var(--rtd-color-primary-soft);
}
.row__hint {
  font-size: 12px;
  color: var(--rtd-text-muted);
  margin-top: 4px;
}
.row__hint--mt-sm { margin-top: 8px; }
.row__hint--mt-md { margin-top: 14px; }
.row__hint--mb    { margin-bottom: 14px; }
.row--inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.row--inline label { margin: 0; flex: 1; }
.row--inline--mt-sm { margin-top: 8px; }
.row--inline label.switch-label { cursor: pointer; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Tugmalar ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--rtd-border-color);
  background: #fff;
  color: var(--rtd-text-secondary);
  font-family: inherit;
}
.btn:hover { background: var(--rtd-color-gray-50); }
.btn--primary {
  background: var(--rtd-color-primary);
  border-color: var(--rtd-color-primary);
  color: #fff;
}
.btn--primary:hover { background: var(--rtd-color-primary-hover); }
.btn--danger {
  background: var(--rtd-color-danger);
  border-color: var(--rtd-color-danger);
  color: #fff;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn .icon-sm { width: 14px; height: 14px; }

.btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.btn-row--mt-sm { margin-top: 8px; }
.btn-row--mt-md { margin-top: 16px; }
.btn-row--mt-lg { margin-top: 18px; flex-wrap: wrap; gap: 10px; }

/* ---------- Avatar ---------- */
.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--rtd-color-primary-soft);
  color: var(--rtd-color-primary);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 700;
}

/* Profil bosh qismi (avatar + ism) */
.prof-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.prof-head__name { font-weight: 600; font-size: 15px; }
.prof-head__role { color: var(--rtd-text-muted); font-size: 13px; }

/* AutoLogin switch o'lcham fiks (row--inline ichida) — yuqori spetsifika bilan
   `.row--inline label { flex: 1 }` ni bostirish uchun */
.row--inline label.switch.switch--fixed {
  flex: 0 0 44px;
  width: 44px;
  height: 24px;
}

/* ---------- Switch ---------- */
.switch {
  position: relative;
  width: 44px;
  height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track {
  position: absolute;
  inset: 0;
  background: var(--rtd-color-gray-300);
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s;
}
.switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.switch input:checked + .switch__track { background: var(--rtd-color-primary); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }

/* ---------- Alert ---------- */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.alert.is-show { display: block; }
.alert--success { background: var(--rtd-color-success-soft); color: #1e7e34; }
.alert--error   { background: var(--rtd-color-danger-soft);  color: var(--rtd-color-danger); }

/* ---------- Stat strip ---------- */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stat-strip--mb { margin-bottom: 16px; }
.stat-strip__item {
  padding: 12px 14px;
  background: var(--rtd-color-gray-50);
  border-radius: 8px;
}
.stat-strip__num { font-size: 20px; font-weight: 700; }
.stat-strip__lbl {
  font-size: 12px;
  color: var(--rtd-text-muted);
  text-transform: uppercase;
  letter-spacing: .3px;
}

/* ---------- Gate (auth tekshiruvi paytida) ---------- */
.s-gate {
  text-align: center;
  padding: 60px 20px;
  color: var(--rtd-text-muted);
}

/* ---------- Helper textlar ---------- */
.s-muted { color: var(--rtd-text-muted); }
.s-muted-block { color: var(--rtd-text-muted); margin: 0 0 12px; }
.s-fine { color: var(--rtd-text-muted); font-size: 12px; margin-top: 10px; }
.s-empty { padding: 20px 0; color: var(--rtd-text-muted); }
.s-warning-text { color: #b58b00; }
.s-counting { color: var(--rtd-text-muted); }

/* ---------- Templates jadval (tabTemplates) ---------- */
.tpl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tpl-table thead tr {
  text-align: left;
  color: var(--rtd-text-muted);
  font-size: 12px;
  text-transform: uppercase;
}
.tpl-table th { padding: 8px 6px; font-weight: 500; }
.tpl-table__row { border-top: 1px solid var(--rtd-border-color); }
.tpl-cell { padding: 8px 6px; }
.tpl-cell--meta { color: var(--rtd-text-muted); font-size: 12px; }
.tpl-cell--center { text-align: center; }
.tpl-cell--actions { text-align: right; white-space: nowrap; }
.tpl-name {
  cursor: pointer;
  color: var(--rtd-color-primary, #007BFF);
}
.tpl-btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}
.tpl-btn-sm--danger {
  padding: 4px 8px;
  font-size: 12px;
  background: var(--rtd-color-danger, #e34b4b);
  color: #fff;
  border: 0;
}

/* Templates jadvali — mobil moslashuv */
@media (max-width: 640px) {
  #tplList { overflow-x: auto; }
  .tpl-table { font-size: 12px; min-width: 0; }
  .tpl-table th,
  .tpl-cell { padding: 6px 4px; }
  /* "rent/longterm/residential/flat" kabi uzun slash-yo'lni
     ixchamlash uchun har bo'lakda uzilishga ruxsat beramiz */
  .tpl-cell--meta {
    font-size: 11px;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  /* Действия ustuni — tugmalarni ostma-ost qilamiz */
  .tpl-cell--actions {
    white-space: normal;
    text-align: center;
  }
  .tpl-cell--actions .tpl-btn-sm,
  .tpl-cell--actions .tpl-btn-sm--danger {
    display: block;
    width: 100%;
    margin: 2px 0;
    padding: 5px 6px;
  }
  /* "Использований" ustuni — sarlavhasini qisqartiramiz */
  .tpl-table th.tpl-cell--center { font-size: 10px; }
}

/* Gate ichidagi havola */
.gate-link { color: var(--rtd-color-primary); }

/* ---------- Storage tab ---------- */
.storage-list { display: flex; flex-direction: column; gap: 10px; }
.st-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--rtd-border-color);
  border-radius: 10px;
  background: #fff;
}
.st-item__icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--rtd-color-primary-soft);
  color: var(--rtd-color-primary);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.st-item__icon svg { width: 20px; height: 20px; }
.st-item__body { flex: 1 1 auto; min-width: 0; }
.st-item__title { font-weight: 600; font-size: 14px; }
.st-item__desc {
  font-size: 12px;
  color: var(--rtd-text-muted);
  margin-top: 2px;
  word-break: break-word;
}
.st-item__meta {
  font-size: 12px;
  color: var(--rtd-text-secondary);
  margin-top: 4px;
}
.st-item__btn { flex: 0 0 auto; }
.st-item.is-empty { opacity: .6; }
.st-item.is-empty .st-item__btn { display: none; }

@media (max-width: 640px) {
  .st-item { flex-wrap: wrap; }
  .st-item__btn { width: 100%; justify-content: center; }
}

/* ---------- Responsive layout ---------- */
@media (max-width: 768px) {
  .s-wrap { grid-template-columns: 1fr; }
  .s-nav {
    position: static;
    display: flex;
    overflow-x: auto;
    padding: 6px;
  }
  .s-nav a { white-space: nowrap; }
}

/* ---------- Избранное (favorites tab) ---------- */
.fav-count { color: var(--rtd-text-muted); font-weight: 400; font-size: 14px; margin-left: 4px; }
.fav-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.fav-toolbar .btn { color: #b91c1c; }
.fav-list { display: grid; gap: 10px; }
.fav-card {
  display: flex;
  gap: 12px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--rtd-border-color);
  border-radius: 10px;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, border-color .15s;
}
.fav-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.05); border-color: #c7d2fe; }
.fav-card__main { flex: 1; min-width: 0; }
.fav-card__title { font-weight: 600; font-size: 14.5px; margin: 0 0 4px; }
.fav-card__id { color: var(--rtd-text-muted); font-weight: 500; margin-right: 4px; }
.fav-card__meta { color: var(--rtd-text-muted); font-size: 12.5px; }
.fav-card__price { font-weight: 700; font-size: 15px; color: var(--rtd-text-primary); white-space: nowrap; }
.fav-card__rm {
  border: 0; background: transparent; color: #b91c1c; font-size: 18px;
  cursor: pointer; padding: 6px 8px; border-radius: 6px;
}
.fav-card__rm:hover { background: #fee2e2; }
.fav-empty { text-align: center; padding: 32px 16px; }

@media (max-width: 640px) {
  .fav-card { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .fav-card__price { font-size: 14px; }
  .fav-card__main { flex: 1 1 100%; order: 1; }
  .fav-card__price { order: 2; }
  .fav-card__rm { order: 3; margin-left: auto; }
}

/* ---------- Promo tier (admin select / public badge) ---------- */
.my-listings__promo-cell { white-space: nowrap; }
.my-listings__promo {
  font: inherit; font-size: 12px;
  padding: 4px 6px; border: 1px solid var(--rtd-border, #cbd5e1);
  border-radius: 6px; background: #fff; cursor: pointer; min-width: 96px;
}
.my-listings__promo:hover { border-color: #94a3b8; }
.my-listings__promo:disabled { opacity: .6; cursor: wait; }
.my-listings__promo-badge {
  display: inline-block; padding: 2px 8px; font-size: 11px; font-weight: 600;
  border-radius: 999px; color: #fff; line-height: 18px;
}
.my-listings__promo-badge.promo-new     { background: #10b981; }
.my-listings__promo-badge.promo-premium { background: #8b5cf6; }
.my-listings__promo-badge.promo-vip     { background: #f59e0b; color: #1f2937; }
.my-listings__promo-badge.promo-hot     { background: #ef4444; }
