/* style.css — messenger в стиле основного сайта (dark graphite + blue accent + warm links) */

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

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

:root {
  /* Базовые поверхности — как на основном сайте */
  --bg: #1c1c1c;
  --bg-elev-1: #282828;
  --bg-elev-2: #333333;
  --bg-elev-3: #3a3a3a;

  --border: #444444;
  --border-soft: #555555;

  /* Текстовые уровни */
  --text: #e0e0e0;
  --text-soft: #c9c9c9;
  --text-muted: #b0b0b0;

  /* Ссылки — тёплый лосось как на сайте */
  --link: #ffa07a;
  --link-hover: #ff9900;
  --link-visited: #ffb08f;

  /* Action‑акцент: синий, как кнопки/фокус на сайте */
  --accent: #1e90ff;
  --accent-hover: #4e73df;
  --accent-soft: rgba(30, 144, 255, 0.16);
  --accent-ring: rgba(30, 144, 255, 0.32);

  /* Статусы */
  --success: #9ad29a;
  --danger: #ff8f8f;

  /* Пузыри сообщений */
  --bubble-me: #1f3f5c;      /* чуть светлее, чтобы читалось как action */
  --bubble-other: #333333;   /* ближе к bg-elev-2 */

  /* Архивные метки */
  --archive-bg: #435343;
  --archive-bg-soft: #4e644e;

  --shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
video,
iframe,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.page {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.container {
  width: 100%;
  padding: 18px 14px 30px;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  word-break: break-word;
  overflow-wrap: anywhere;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

a:visited {
  color: var(--link-visited);
}

a:hover,
a:focus-visible {
  color: var(--link-hover);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a.chip-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 48px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--bg-elev-2);
  color: #f0f0f0;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  font-size: 1rem;
}

a.chip-link:hover,
a.chip-link:focus-visible {
  background: #3a3a3a;
  border-color: #4e73df;
  color: #ffffff;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  background: linear-gradient(to bottom, #3a3a3a, #333333);
  border-bottom: 1px solid var(--border);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.header-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

header a,
header span {
  font-size: 0.98rem;
}

header a {
  display: inline-flex;
  align-items: center;
  min-width: 48px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid #444444;
  border-radius: 999px;
  background: #333333;
  color: #f0f0f0;
  text-decoration: none;
}

header a:hover,
header a:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #ffffff;
}

header span {
  color: var(--text-muted);
}

.errors,
.info {
  margin: 0 0 12px;
  font-size: 0.96rem;
}

.errors {
  color: var(--danger);
}

.info {
  color: var(--success);
}

form {
  margin: 12px 0;
}

input[type="text"],
input[type="password"],
textarea,
.message-input,
.message-textarea,
#message {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-elev-1);
  color: var(--text);
  font: inherit;
  font-size: 0.98rem;
  line-height: 1.45;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
  color: #8f9ab0;
}

textarea,
.message-textarea {
  min-height: 160px;
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 48px;
  min-height: 48px;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(90deg, #4e73df 0%, #1c7ed6 100%);
  color: #ffffff;
  cursor: pointer;
  font-size: 0.98rem;
  font-weight: 700;
}

button:hover,
input[type="submit"]:hover,
button:focus-visible,
input[type="submit"]:focus-visible {
  background: linear-gradient(90deg, #1c7ed6 0%, #4e73df 100%);
}

button:disabled,
input[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.dialog-list,
.users-table,
table {
  width: 100%;
  border-collapse: collapse;
}

.dialog-list {
  margin: 10px 0;
}

.users-table {
  margin: 10px 0;
}

.dialog-list th,
.users-table th {
  display: none;
}

.dialog-list tr,
.users-table tr {
  display: block;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev-1);
}

.dialog-list td,
.users-table td {
  display: block;
  padding: 4px 0;
  border: none;
  font-size: 0.96rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.dialog-list .clickable-row {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.dialog-list .clickable-row:hover {
  background: #3a3a3a;
}

.archive-cell {
  background: var(--archive-bg);
  color: #eef7ee;
  border-radius: 6px;
  padding-inline: 8px;
}

.dialog-list .clickable-row:hover .archive-cell {
  background: var(--archive-bg-soft);
}

.message {
  width: 100%;
  margin: 8px 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.98rem;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.message.me {
  background: var(--bubble-me);
  margin-left: 0;
}

.message.other {
  background: var(--bubble-other);
  margin-right: 0;
}

.message small {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

pre {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev-1);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  font: inherit;
  line-height: 1.55;
}

#chatBox pre {
  min-height: 80px;
}

.search-results {
  margin: 12px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev-1);
}

.search-results ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.search-results li {
  margin-bottom: 12px;
  line-height: 1.5;
}

.search-results li:last-child {
  margin-bottom: 0;
}

.welcome-box {
  width: calc(100% - 24px);
  max-width: 920px;
  margin: 24px auto;
  padding: 22px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--bg-elev-1);
  box-shadow: var(--shadow);
  color: var(--text);
}

.welcome-head {
  margin-bottom: 18px;
  text-align: center;
}

.welcome-head h1 {
  margin: 0 0 8px;
  font-size: 1.7rem;
  line-height: 1.2;
  color: #ffffff;
}

.welcome-head .subtitle {
  margin: 0;
  font-size: 0.96rem;
  color: var(--text-soft);
}

.welcome-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.welcome-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev-2);
}

.welcome-card h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  line-height: 1.35;
  color: #ffffff;
}

.welcome-card ul {
  margin: 0;
  padding-left: 18px;
}

.welcome-card li {
  margin: 0 0 8px;
  color: var(--text-soft);
  line-height: 1.5;
}

.welcome-card li:last-child {
  margin-bottom: 0;
}

.welcome-card strong {
  color: #ffffff;
}

footer {
  padding: 1em;
  text-align: center;
  color: #888;
  font-size: 0.9rem;
}

@media (max-width: 600px) {
  body {
    font-size: 15px;
  }

  .page {
    max-width: 100%;
  }

  .container {
    padding: 16px 12px 28px;
  }

  header {
    padding: 10px;
  }

  .header-title {
    font-size: 1rem;
  }

  header a,
  header span {
    font-size: 0.94rem;
  }

  header a {
    padding: 9px 12px;
  }

  .welcome-box {
    width: calc(100% - 24px);
    margin: 16px 12px;
    padding: 18px 16px;
    border-radius: 10px;
  }

  .welcome-head h1 {
    font-size: 1.5rem;
  }

  .welcome-head .subtitle {
    font-size: 0.94rem;
  }

  .welcome-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .welcome-card {
    padding: 14px;
  }
}

@media (max-width: 380px) {
  body {
    font-size: 14px;
    line-height: 1.6;
  }

  .container {
    padding: 14px 10px 24px;
  }

  header {
    padding: 8px;
    gap: 8px;
  }

  .header-left,
  .header-right {
    gap: 6px;
  }

  header a {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 11px;
    font-size: 0.9rem;
  }

  .header-title {
    width: 100%;
    font-size: 0.98rem;
    text-align: center;
  }

  input[type="text"],
  input[type="password"],
  textarea,
  button,
  input[type="submit"],
  a.chip-link {
    min-height: 44px;
    font-size: 0.96rem;
  }

  .dialog-list tr,
  .users-table tr,
  .message,
  .welcome-card {
    padding-left: 12px;
    padding-right: 12px;
  }

  .welcome-box {
    width: calc(100% - 16px);
    margin: 12px 8px;
    padding: 16px 12px;
    border-radius: 10px;
  }

  .welcome-head h1 {
    font-size: 1.45rem;
  }

  .welcome-card h2 {
    font-size: 0.98rem;
  }

  .welcome-card ul {
    padding-left: 16px;
  }
}

@media (min-width: 768px) {
  .dialog-list,
  .users-table {
    overflow: hidden;
    border-radius: 8px;
    background: var(--bg-elev-1);
  }

  .dialog-list th,
  .users-table th {
    display: table-cell;
    padding: 10px 12px;
    background: var(--bg-elev-2);
    color: #e0e0e0;
    font-weight: 500;
    text-align: left;
  }

  .dialog-list tr,
  .users-table tr {
    display: table-row;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
  }

  .dialog-list td,
  .users-table td {
    display: table-cell;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    font-size: 0.95rem;
    vertical-align: top;
  }

  .message {
    max-width: 82%;
  }

  .message.me {
    margin-left: auto;
  }

  .message.other {
    margin-right: auto;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }

  header,
  footer,
  .no-print {
    display: none !important;
  }

  a {
    color: #000;
    text-decoration: none;
  }
}

.export-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;

  display: inline-flex;
  align-items: center;
  min-width: 48px;
  min-height: 48px;
  padding: 10px 14px;

  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #f0f0f0 !important;
  text-decoration: none;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.export-btn:hover,
.export-btn:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #ffffff !important;
}
