/* ============================================================
   Chat — page-specific styles (client ↔ center)
   ============================================================ */

html, body { height: 100%; }
body { overflow: hidden; }

.chat-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 64px);
  background: var(--bg);
  border-top: 1px solid var(--line);
}

/* ===== LEFT RAIL ===== */
.threads-rail {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
}

.rail-head {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.rail-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.rail-title-row h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.rail-title-row .new-chat {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: var(--dark);
  color: var(--text-on-dark);
  display: grid; place-items: center;
  border: 0;
  cursor: pointer;
}
.rail-title-row .new-chat:hover { background: var(--dark-2); }

.rail-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.rail-search .ms { color: var(--text-muted); font-size: 18px; }
.rail-search input {
  flex: 1;
  border: 0; outline: 0; background: transparent;
  font-family: inherit; font-size: 13px;
  padding: 4px 0;
}

.rail-filters {
  display: flex;
  gap: 4px;
  padding: 0 4px;
}
.rail-filter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  background: transparent;
  border: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}
.rail-filter.active { background: var(--dark); color: var(--text-on-dark); }
.rail-filter:not(.active):hover { background: var(--surface-3); color: var(--text); }
.rail-filter .c {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text-2);
}
.rail-filter.active .c { background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.9); }

.threads-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.thread {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  padding: 12px 18px;
  cursor: pointer;
  position: relative;
  align-items: center;
  border-bottom: 1px solid var(--line-faint);
  transition: background 100ms ease;
}
.thread:hover { background: var(--surface-3); }
.thread.active {
  background: var(--surface);
  box-shadow: inset 3px 0 0 0 var(--signal);
}
.thread.unread .thread-name { font-weight: 700; }
.thread.unread .thread-preview { color: var(--text); }

.thread-av {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  background: var(--surface-3);
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  position: relative;
  flex-shrink: 0;
}
.thread-av.center {
  background: linear-gradient(135deg, #2a2c32 0%, #1c1e23 100%);
  color: var(--signal);
}
.thread-av.center .ms { font-size: 22px; }
.thread-av .live {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--go);
  border: 2px solid var(--surface-2);
}

.thread-body { min-width: 0; }
.thread-top-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.thread-name {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.thread-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-preview .typing {
  color: var(--go);
  font-weight: 500;
}

.thread-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.thread-badge {
  background: var(--signal);
  color: var(--signal-on);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--r-pill);
}

/* ===== MAIN PANE ===== */
.chat-pane {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  overflow: hidden;
}

.chat-pane-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.chat-head-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.chat-head-av {
  width: 42px; height: 42px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #2a2c32 0%, #1c1e23 100%);
  color: var(--signal);
  display: grid; place-items: center;
  position: relative;
}
.chat-head-av .ms { font-size: 22px; }
.chat-head-av .live {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--go);
  border: 2px solid var(--surface);
}
.chat-head-info .n {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-head-info .n .ms { font-size: 16px; color: var(--info); }
.chat-head-info .s {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-head-info .s .online {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--go);
}
.chat-head-info .s .online::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--go);
}

.chat-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.head-action {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid var(--line);
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--text-2);
  font-family: inherit;
}
.head-action:hover { background: var(--surface-3); color: var(--text); }

/* booking-bound pill in head */
.booking-pin {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  text-decoration: none;
  color: inherit;
}
.booking-pin .l { color: var(--text-muted); font-weight: 500; }
.booking-pin .v { font-family: var(--font-mono); font-weight: 600; color: var(--text); }
.booking-pin .ms { font-size: 14px; color: var(--info); }

/* ===== MESSAGES ===== */
.chat-stream {
  overflow-y: auto;
  padding: 24px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.day-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}
.day-divider::before,
.day-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.day-divider span {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.system-msg {
  align-self: center;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 5px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.system-msg .ms { font-size: 14px; color: var(--go); }

.msg {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  max-width: 70%;
}
.msg.me {
  grid-template-columns: 1fr;
  align-self: flex-end;
}
.msg-av {
  width: 32px; height: 32px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 600;
  align-self: flex-end;
}
.msg-av.center {
  background: linear-gradient(135deg, #2a2c32 0%, #1c1e23 100%);
  color: var(--signal);
}

.msg-bubbles { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.msg .who {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 14px;
}
.msg.me .who { display: none; }

.bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  position: relative;
  word-wrap: break-word;
}
.bubble:first-of-type { border-top-left-radius: 18px; border-top-right-radius: 18px; }
.msg .bubble:last-of-type { border-bottom-left-radius: 6px; }
.msg.me .bubble {
  background: var(--dark);
  color: var(--text-on-dark);
  border-color: var(--dark);
}
.msg.me .bubble:last-of-type { border-bottom-right-radius: 6px; border-bottom-left-radius: 18px; }

.bubble .when {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 4px;
}
.msg.me .bubble .when { color: rgba(247, 246, 242, 0.4); }
.bubble .when.read { color: var(--info); }
.msg.me .bubble .when .ms { font-size: 12px; vertical-align: -2px; }

/* booking card embedded */
.embed-booking {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  width: 380px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.embed-booking .b-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.embed-booking .b-id { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.embed-booking .b-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-family: var(--font-display);
}
.embed-booking .b-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.embed-booking .b-row .ms { font-size: 16px; color: var(--text-muted); }
.embed-booking .b-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.embed-booking .b-amount { font-family: var(--font-mono); font-size: 18px; font-weight: 500; }
.embed-booking .b-link { font-size: 12px; font-weight: 500; color: var(--text); }
.embed-booking .b-link .ms { font-size: 14px; vertical-align: -2px; }

/* photos */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 340px;
}
.photo {
  aspect-ratio: 1;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
}
.photo:nth-child(1) { background: linear-gradient(135deg, #d8dbe2 0%, #b9bdc8 100%); }
.photo:nth-child(2) { background: linear-gradient(135deg, #e6e2d5 0%, #d2cdba 100%); }
.photo:nth-child(3) { background: linear-gradient(135deg, #2a2c32 0%, #1c1e23 100%); }
.photo .ms { color: rgba(15,17,21,0.22); font-size: 32px; font-variation-settings: 'opsz' 32, 'wght' 300, 'FILL' 1, 'GRAD' 0; }
.photo:nth-child(3) .ms { color: rgba(247,246,242,0.3); }

/* quote / offer card from center */
.offer-card {
  background: var(--surface);
  border: 1.5px solid var(--signal);
  border-radius: var(--r-lg);
  padding: 16px;
  width: 380px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}
.offer-card::before {
  content: 'Предложение центра';
  position: absolute;
  top: -10px; left: 14px;
  background: var(--signal);
  color: var(--signal-on);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 10px;
  border-radius: var(--r-pill);
}
.offer-card .o-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 4px;
}
.offer-card .o-desc { font-size: 13px; color: var(--text-2); line-height: 1.45; }
.offer-card .o-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.offer-card .o-price {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.offer-card .o-actions { display: flex; gap: 6px; }
.offer-card .o-decline {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-2);
}
.offer-card .o-accept {
  background: var(--dark);
  color: var(--text-on-dark);
  border: 0;
  border-radius: var(--r-pill);
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* typing indicator */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}
.typing-indicator span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* ===== COMPOSER ===== */
.chat-composer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 14px 28px 16px;
}
.composer-quick {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.composer-quick .chip { font-size: 12px; padding: 4px 12px; }

.composer-box {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 6px 6px 6px 12px;
}
.composer-attach,
.composer-voice,
.composer-send {
  width: 36px; height: 36px;
  border: 0;
  border-radius: var(--r-pill);
  display: grid; place-items: center;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}
.composer-attach { background: transparent; color: var(--text-muted); }
.composer-attach:hover { background: var(--surface-3); color: var(--text); }
.composer-voice { background: transparent; color: var(--text-muted); }
.composer-voice:hover { background: var(--surface-3); color: var(--text); }
.composer-send { background: var(--dark); color: var(--text-on-dark); }
.composer-send:hover { background: var(--dark-2); }
.composer-input {
  background: transparent;
  border: 0; outline: 0;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  padding: 10px 0;
  resize: none;
  min-height: 24px;
  max-height: 100px;
  line-height: 1.4;
}
.composer-input::placeholder { color: var(--text-muted); }
