/* Portalchat — тёмная (графит) и светлая темы */

:root,
[data-theme="dark"] {
  --bg-page: #141414;
  --bg-surface: #1c1c1e;
  --bg-elevated: #2a2a2c;
  --bg-input: #2a2a2c;
  --text-primary: #e8e8ec;
  --text-secondary: #a8a8b0;
  --text-muted: #6b6b73;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #c9a227;
  --accent-hover: #dbb42e;
  --accent-soft: rgba(201, 162, 39, 0.15);
  --bubble-user: #3a3a3d;
  --bubble-assistant: #242426;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --header-bg: rgba(20, 20, 20, 0.94);
}

[data-theme="light"] {
  --bg-page: #f4f4f6;
  --bg-surface: #ffffff;
  --bg-elevated: #eef0f3;
  --bg-input: #ffffff;
  --text-primary: #1a1a1e;
  --text-secondary: #4a4a52;
  --text-muted: #6b6b73;
  --border: rgba(0, 0, 0, 0.1);
  --accent: #9a7b1a;
  --accent-hover: #7d6315;
  --accent-soft: rgba(154, 123, 26, 0.12);
  --bubble-user: #e8ecf2;
  --bubble-assistant: #ffffff;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --header-bg: rgba(255, 255, 255, 0.94);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body.chat-body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  min-height: 56px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.chat-header__left,
.chat-header__right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chat-header__center {
  flex: 1;
  text-align: center;
  min-width: 0;
}

.chat-logo {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.chat-logo span {
  color: var(--accent);
}

.chat-header__badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.chat-config-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  max-width: 100%;
}

.chat-config-warning {
  font-size: 0.85rem;
  color: var(--accent);
}

.chat-user {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.chat-link {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
}

.chat-link:hover {
  color: var(--accent);
}

.chat-link--btn {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.chat-logout-form {
  display: inline;
  margin: 0;
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle__icon {
  font-size: 1.1rem;
  line-height: 1;
}

[data-theme="dark"] .theme-toggle__icon--light {
  display: none;
}

[data-theme="light"] .theme-toggle__icon--dark {
  display: none;
}

/* Layout */
.chat-main {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: calc(100vh - 56px);
  max-width: 1400px;
  margin: 0 auto;
}

.chat-sidebar {
  padding: 20px 16px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.chat-sidebar__title {
  margin: 0 0 8px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.chat-sidebar__hint {
  margin: 0 0 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chat-sidebar__hint a {
  color: var(--accent);
}

.chat-config-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
}

.chat-config-list__item {
  padding: 8px 10px;
  margin-bottom: 4px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-radius: 4px;
  border: 1px solid transparent;
}

.chat-config-list__item.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(201, 162, 39, 0.25);
}

.chat-sidebar__tariff {
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.chat-sidebar__tariff-name {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
}

.chat-sidebar__tariff-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Chat panel */
.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-page);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.chat-message {
  margin-bottom: 16px;
  max-width: 720px;
}

.chat-message__bubble {
  padding: 14px 18px;
  background: var(--bubble-assistant);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.chat-message__bubble p {
  margin: 0 0 10px;
}

.chat-message__bubble p:last-child {
  margin-bottom: 0;
}

.chat-message__emph {
  font-weight: 600;
  color: var(--text-primary, #e8eaed);
}

.chat-message__step {
  margin: 0 0 8px;
  padding-left: 4px;
  line-height: 1.5;
}

.chat-message__step--bullet {
  padding-left: 12px;
}

.chat-message__note {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chat-composer {
  display: flex;
  gap: 12px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

.chat-composer__input {
  flex: 1;
  resize: vertical;
  min-height: 48px;
  max-height: 160px;
  padding: 12px 14px;
  font: inherit;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.chat-composer__input:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-composer__input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-composer__send {
  align-self: flex-end;
  padding: 12px 20px;
  font: inherit;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.8rem;
  color: #141414;
  background: var(--accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-composer__send:hover:not(:disabled) {
  background: var(--accent-hover);
}

.chat-composer__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .chat-main {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 56px);
  }

  .chat-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 200px;
  }

  .chat-header__center {
    display: none;
  }
}

.chat-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.chat-gate__card {
  max-width: 420px;
  width: 100%;
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
}

.chat-gate__title {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
}

.chat-gate__lead {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.chat-gate__btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.chat-gate__btn:hover {
  background: var(--accent-hover);
}

.chat-gate__hint {
  margin: 1rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}
