/* ═══════════════════════════════════════════
   LAYOUT.CSS — app, sidebar, chat-area, messages-контейнер, input
   ═══════════════════════════════════════════ */

/* ═══ APP ═══ */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: var(--sidebar-width, 380px);
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.resizer {
  width: 4px;
  background: transparent;
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  z-index: 15;
}

.resizer::after {
  content: '';
  position: absolute;
  top: 0;
  left: 1px;
  width: 2px;
  height: 100%;
  background: transparent;
  transition: background 0.15s;
}

.resizer:hover::after,
.resizer.dragging::after {
  background: var(--accent);
}

.sidebar-header {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.profile-info {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-radius: 10px;
  padding: 4px;
  transition: background 0.2s;
  min-width: 0;
  flex: 1;
}

.profile-info:hover {
  background: var(--hover);
}

.profile-info > div:last-child {
  min-width: 0;
}

.profile-name-header {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-username-header {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  background: #5288c1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

.avatar-btn img,
.avatar-btn video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.search-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 20px;
  padding: 0 14px;
  min-width: 0;
}

.search-wrap svg {
  color: var(--muted);
  flex-shrink: 0;
  margin-right: 8px;
}

.search-wrap input {
  width: 100%;
  padding: 9px 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: background 0.15s;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--accent);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.chat-item {
  display: flex;
  padding: 10px 16px;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s, outline 0.1s;
  align-items: center;
  position: relative;
}

.chat-item:hover {
  background: var(--hover);
}

.chat-item.active {
  background: var(--active);
}

.chat-item.drag-target {
  background: var(--active) !important;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.chat-item .avatar-btn {
  width: 54px;
  height: 54px;
  font-size: 20px;
  cursor: default;
}

.chat-item-body {
  flex: 1;
  min-width: 0;
}

.chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.chat-item-name {
  font-weight: 500;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-item-time {
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
  margin-left: 8px;
}

.chat-item-preview {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item.active .chat-item-time,
.chat-item.active .chat-item-preview {
  color: var(--muted);
}

.empty-sidebar {
  color: var(--muted);
  text-align: center;
  padding: 40px 20px;
  font-size: 14px;
  line-height: 1.6;
}

/* ═══ CHAT AREA ═══ */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
  min-width: 0;
}

.chat-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--muted);
  gap: 12px;
}

.chat-header {
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  min-height: 60px;
  position: relative;
  z-index: 5;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.chat-header-info:hover .chat-header-name {
  color: var(--accent);
}

.chat-header-name {
  font-weight: 500;
  font-size: 15px;
  transition: color 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-status {
  font-size: 12px;
}

.status-online {
  color: var(--online);
}

.status-offline {
  color: var(--muted);
}

.selection-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.selection-count {
  font-weight: 600;
  font-size: 16px;
  color: var(--accent);
  margin-right: auto;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

/* ═══ INPUT ═══ */
.chat-input-wrap {
  padding: 12px 20px 16px;
  background: var(--sidebar);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  position: relative;
  transition: background 0.2s, outline 0.1s;
}

.chat-input-wrap.drag-target-input {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--active);
}

.chat-input {
  flex: 1;
  padding: 11px 16px;
  background: var(--bg);
  border-radius: 20px;
  color: var(--text);
  font-size: 14px;
  max-height: 120px;
  resize: none;
  line-height: 1.4;
  overflow-y: auto;
  min-width: 0;
  user-select: text;
  -webkit-user-select: text;
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--active);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  flex-shrink: 0;
  transition: transform 0.15s, background 0.15s;
}

.send-btn:hover {
  opacity: 0.9;
}

.send-btn:active {
  transform: scale(0.95);
}

.attach-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
}

.attach-btn:hover {
  background: var(--hover);
  color: var(--accent);
}

.back-btn {
  display: flex;
}