/* Компоненты веб-клиента поверх токенов (фаза 12).
 *
 * Цвет берётся ТОЛЬКО из tokens.css. Ни одного шестнадцатеричного значения
 * ниже нет и быть не должно: новый цвет сначала появляется в docs/themes.md,
 * потом в токенах, и только потом здесь. Иначе «фирменный бирюзовый»
 * становится тремя разными бирюзовыми в вебе, кабинете и приложении.
 *
 * Bootstrap не подключается: панели проекта его тоже не используют, а тащить
 * 200 КБ ради сетки и кнопок, которые всё равно перекрашиваются токенами,
 * незачем. Сетка здесь — grid и flex, они есть везде (Р-095).
 */

/* --- Основа ---------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--brand-ink);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

h1, h2, h3, h4 {
  margin: 0 0 12px;
  line-height: 1.25;
  font-weight: 650;
}

h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

p { margin: 0 0 12px; }

/* Фокус виден всегда: клавиатурная навигация — это доступность, а не
   украшение. Убирать обводку ради «чистоты» значит выключить сайт для тех,
   кто не пользуется мышью */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

.wrap--wide { max-width: 1440px; }

main {
  flex: 1 0 auto;
  padding: 24px 0 48px;
}

.muted { color: var(--text2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 32px; }
.mb { margin-bottom: 16px; }
.hidden { display: none !important; }

/* --- Шапка ----------------------------------------------------------- */

.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 19px;
  color: var(--text);
  text-decoration: none;
}

.logo:hover { text-decoration: none; }

.logo__mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--gradient-brand);
  flex: none;
}

.nav {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}

.nav__link {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-weight: 500;
}

.nav__link:hover {
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.nav__link--active {
  color: var(--text);
  background: var(--surface3);
}

.header__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface3);
  object-fit: cover;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  flex: none;
}

.badge-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--error);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: inline-grid;
  place-items: center;
}

/* --- Кнопки ---------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface3);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s ease, background .15s ease;
}

.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--brand {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-brand);
}

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

.btn--quiet {
  background: transparent;
  color: var(--text2);
  padding: 8px 10px;
}

.btn--danger { background: var(--error); color: #fff; }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--block { width: 100%; }

/* --- Карточки и плашки ----------------------------------------------- */

.card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card--pad { padding: 18px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface3);
  color: var(--text2);
  font-size: 13px;
  white-space: nowrap;
}

.chip--brand { background: var(--brand-bg); color: var(--brand-ink); }

.tone {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.tone--success { background: var(--success-bg); color: var(--success-ink); }
.tone--warning { background: var(--warning-bg); color: var(--warning-ink); }
.tone--error   { background: var(--error-bg);   color: var(--error-ink); }
.tone--info    { background: var(--info-bg);    color: var(--info-ink); }
.tone--muted   { background: var(--surface3);   color: var(--text2); }

.notice {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 16px;
}

.notice--error   { background: var(--error-bg);   border-color: transparent; color: var(--error-ink); }
.notice--success { background: var(--success-bg); border-color: transparent; color: var(--success-ink); }
.notice--info    { background: var(--info-bg);    border-color: transparent; color: var(--info-ink); }

/* --- Формы ----------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 13px; color: var(--text2); font-weight: 500; }

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text);
  font: inherit;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--brand);
  outline: none;
}

.textarea { min-height: 96px; resize: vertical; }

.form-narrow {
  max-width: 420px;
  margin: 32px auto;
}

/* --- Витрина --------------------------------------------------------- */

.hero {
  padding: 44px 0 32px;
  background: var(--gradient-brand);
  color: #fff;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  margin-bottom: 28px;
}

.hero h1 { color: #fff; font-size: 34px; }
.hero p { color: rgba(255, 255, 255, .88); max-width: 620px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.tab {
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--surface3);
  color: var(--text2);
  font-weight: 550;
}

.tab:hover { text-decoration: none; }
.tab--active { background: var(--brand); color: #fff; }

.hero .tab { background: rgba(255, 255, 255, .18); color: #fff; }
.hero .tab--active { background: #fff; color: var(--brand-ink); }

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.tile { position: relative; }

.tile__photo {
  aspect-ratio: 4 / 3;
  width: 100%;
  object-fit: cover;
  background: var(--surface3);
}

.tile__body { padding: 12px 14px 14px; }
.tile__title { font-weight: 600; margin: 0 0 4px; font-size: 15px; }
.tile__meta { color: var(--text2); font-size: 13px; margin-bottom: 8px; }
.tile__price { font-weight: 650; }

.tile__fav {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--overlay);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.tile__fav[aria-pressed="true"] { background: var(--error); }

.rating { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.rating__star { color: var(--gold); }

/* --- Поиск ----------------------------------------------------------- */

.search-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.search-layout--map {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
}

.filters .field { margin: 0; min-width: 130px; }

#map {
  height: 70vh;
  min-height: 420px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  position: sticky;
  top: 84px;
}

/* --- Карточка объекта ------------------------------------------------ */

.gallery {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 6px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
  max-height: 460px;
}

.gallery img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; background: var(--surface3); }
.gallery img:first-child { grid-row: span 2; }

.listing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 32px;
  align-items: start;
}

.booking-box {
  position: sticky;
  top: 84px;
  padding: 20px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--surface2);
  box-shadow: var(--shadow-md);
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.fact { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.fact__label { font-size: 12px; color: var(--text3); }
.fact__value { font-weight: 600; }

.amenities {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}

.review { padding: 16px 0; border-top: 1px solid var(--border); }
.review__head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.review__reply {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--brand);
}

/* --- Чат ------------------------------------------------------------- */

.chat-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.dialog-list { display: flex; flex-direction: column; }

.dialog-item {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.dialog-item:hover { background: var(--surface); text-decoration: none; }
.dialog-item--active { background: var(--surface3); }

.messages {
  height: 60vh;
  min-height: 380px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
}

.bubble {
  max-width: 72%;
  padding: 9px 13px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1px solid var(--border);
  align-self: flex-start;
  word-break: break-word;
}

.bubble--mine {
  align-self: flex-end;
  background: var(--brand-bg);
  border-color: transparent;
}

.bubble--system {
  align-self: center;
  background: transparent;
  border: none;
  color: var(--text3);
  font-size: 13px;
}

.bubble__time { font-size: 11px; color: var(--text3); margin-top: 3px; }

.bubble__mask {
  font-size: 12px;
  color: var(--warning-ink);
  margin-top: 4px;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* --- Подвал ---------------------------------------------------------- */

.footer {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 28px 0;
  color: var(--text2);
  font-size: 14px;
}

.footer__cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 24px;
  margin-bottom: 20px;
}

.footer a { color: var(--text2); display: block; padding: 3px 0; }
.footer a:hover { color: var(--text); }

/* --- Адаптив: от 360 px ---------------------------------------------- */

@media (max-width: 980px) {
  .listing-layout,
  .chat-layout,
  .search-layout--map { grid-template-columns: 1fr; }
  .booking-box, #map { position: static; }
  .gallery { grid-template-columns: 1fr 1fr; max-height: none; }
  .gallery img:first-child { grid-column: span 2; }
}

@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  h1 { font-size: 24px; }
  .hero { padding: 28px 0 22px; }
  .hero h1 { font-size: 26px; }
  .nav { display: none; }
  .header__inner { height: 56px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .bubble { max-width: 88%; }
}

/* Печать: человек уносит с собой бронь, а не интерфейс */
@media print {
  .header, .footer, .booking-box, .btn { display: none !important; }
}
