﻿:root {
  --bg: #0e1017;
  --card: #161a27;
  --accent: #2f6cf6;
  --accent-2: #49c6e5;
  --text: #e9edf1;
  --muted: #9aa4b2;
  --danger: #ff6b6b;
  --border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

body.messenger {
  font-family: "Plus Jakarta Sans", sans-serif;
}

.bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(47, 108, 246, 0.2), transparent 45%),
    radial-gradient(circle at 80% 10%, rgba(73, 198, 229, 0.2), transparent 50%),
    linear-gradient(140deg, #0b0d13 0%, #0f1320 60%, #14192a 100%);
  z-index: -1;
}

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.shell-wide {
  max-width: 1400px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.hero-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-btn {
  width: 40px;
  height: 40px;
  font-size: 16px;
}

.hero h1 {
  margin: 0;
  font-size: 36px;
}

.hero p {
  margin: 6px 0 0;
  color: var(--muted);
}

.status {
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 14px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.user-menu {
  position: relative;
}

.avatar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: none;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(130deg, var(--accent), #7cc4ff);
  color: #0b1220;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

.caret {
  font-size: 14px;
}

.menu-panel {
  position: absolute;
  right: 0;
  top: 46px;
  min-width: 180px;
  background: #111726;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.chat-settings {
  position: relative;
}

.chat-settings .menu-panel {
  top: 42px;
}

.menu-item {
  width: 100%;
  background: transparent;
  color: var(--text);
  border: none;
  padding: 8px 10px;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 0;
}

.member-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
}

.menu-item.danger {
  color: var(--danger);
  background: rgba(255, 107, 107, 0.12);
}

.menu-item.danger:hover {
  background: rgba(255, 107, 107, 0.22);
}

.friends-btn {
  position: relative;
}

.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ff4d4d;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border: 2px solid #111726;
}

.auth {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.page {
  max-width: 420px;
  margin: 0 auto;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

@media (max-width: 900px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--card);
  padding: 18px;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card h2 {
  margin: 0 0 6px;
}

input, button {
  font-family: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
}

input {
  background: #0f1420;
  color: var(--text);
  border-color: #20263a;
}

button {
  background: linear-gradient(120deg, var(--accent), #7cc4ff);
  color: #0b1220;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

button.secondary {
  background: #20263a;
  color: var(--text);
}

button.danger {
  background: var(--danger);
  color: #1b1b1b;
}

.link {
  color: var(--accent-2);
  text-decoration: none;
}

.pill {
  border-radius: 999px;
  padding: 8px 16px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.messenger-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: stretch;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.list-column {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  padding-right: 4px;
}

.panel {
  background: var(--card);
  padding: 14px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border);
}

.panel h3, .panel h4 {
  margin: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sticky {
  position: sticky;
  top: 0;
  z-index: 1;
}

.search-row {
  display: flex;
  gap: 10px;
}

.chip-row {
  display: flex;
  gap: 8px;
}

.chip {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 6px 12px;
  border: none;
  color: var(--text);
  cursor: pointer;
}

.chip.active {
  background: rgba(47, 108, 246, 0.35);
  color: #d7e6ff;
}

.list-panel {
  flex: 1;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow: auto;
}

.item {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-item {
  border: none;
  width: 100%;
  text-align: left;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  cursor: pointer;
  color: var(--text);
}

.chat-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.chat-item.active {
  background: rgba(47, 108, 246, 0.35);
  box-shadow: 0 0 0 1px rgba(47, 108, 246, 0.4) inset;
}

.friend-result {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
}

.friend-result .actions {
  justify-self: end;
}

.friend-result .chat-meta {
  gap: 0;
}

.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.chat-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-title {
  font-weight: 700;
}

.chat-preview {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-section-title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 8px 4px 0;
}

.chat-shell {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 18px;
  border: 1px solid var(--border);
  min-height: 680px;
  overflow: hidden;
  max-height: 1200px;
  transition: max-height 0.35s ease;
}

.chat-shell.empty {
  min-height: unset;
  height: auto;
  max-height: 90px;
}

.chat-column {
  height: 100%;
}

.list-column .panel {
  flex: 1;
  min-height: 680px;
  height: 100%;
}

.chat-header {
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.chat-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header h3 {
  margin: 0;
}

.chat-actions {
  display: flex;
  gap: 8px;
}

.chat-body {
  padding: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(18, 22, 36, 0.6), rgba(18, 22, 36, 0.95));
  max-height: 1000px;
  transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.25s ease;
}

.chat-body.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

.msg {
  max-width: 60%;
  padding: 8px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  position: relative;
  width: fit-content;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.msg-sender {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.msg.has-sender {
  margin-top: 18px;
}

.msg.has-sender .msg-sender {
  position: absolute;
  top: -16px;
  left: 12px;
  margin: 0;
}

.msg img.msg-image {
  max-width: 240px;
  max-height: 240px;
  border-radius: 12px;
  display: block;
}

.msg-file {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  text-decoration: none;
  color: var(--text);
}

.msg-file-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.msg-file-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-file-meta strong {
  font-size: 14px;
}

.msg-file-meta em {
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}

.msg.with-avatar {
  margin-left: 48px;
}

.chat-body.direct-room .msg:not(.me) {
  margin-left: 48px;
}

.chat-body.group-room .msg:not(.me) {
  margin-left: 48px;
}

.msg-avatar {
  position: absolute;
  left: -44px;
  bottom: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
}

.msg.me {
  margin-left: auto;
  background: rgba(47, 108, 246, 0.4);
}

.msg::after {
  content: attr(data-time);
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.15s ease;
  white-space: nowrap;
  pointer-events: none;
}

.msg.me::after {
  right: calc(100% + 10px);
}

.msg:not(.me)::after {
  left: calc(100% + 10px);
}

.msg:hover::after {
  opacity: 1;
}

.chat-input {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: rgba(15, 20, 32, 0.9);
  max-height: 120px;
  transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.25s ease;
}

.chat-input.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  border-top: none;
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.input-row input {
  flex: 1;
}

.attachment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

.attachment-pill span {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-pill button {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

.row {
  display: flex;
  gap: 10px;
}

.info-card {
  display: flex;
  gap: 12px;
  align-items: center;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
}

.info-actions {
  display: flex;
  gap: 8px;
}

.file-link-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-list,
.link-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item,
.link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}

.file-item em {
  font-style: normal;
  color: var(--muted);
  margin-left: auto;
  font-size: 12px;
}

.file-item:hover,
.link-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.file-item span,
.link-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 14, 0.6);
  display: grid;
  place-items: center;
  z-index: 50;
}

.modal-card {
  width: min(520px, 92vw);
  background: #111726;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.call-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.select-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.select-item input {
  margin: 0;
}
.split {
  display: flex;
  gap: 8px;
}

.hidden {
  display: none;
}

@media (max-width: 1100px) {
  .messenger-layout {
    grid-template-columns: 1fr;
  }
  .info-column {
    display: none;
  }
  .chat-shell {
    min-height: 520px;
  }
}
