/* Pllato Chat — стили */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-0: #0e0e12;
  --bg-1: #16161d;
  --bg-2: #1f1f2a;
  --bg-3: #27273a;
  --border: rgba(255, 255, 255, 0.08);
  --text-1: #f0eefc;
  --text-2: #c5c2db;
  --text-3: #9896b0;
  --accent: #a87fff;
  --accent-2: #7c5cfc;
  --success: #3fd88e;
  --danger: #f05975;
  --warn: #f5c14b;
  
  --header-h: 60px;
  --sidebar-w: 280px;
  
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Manrope, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;
}

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

.accent { color: var(--accent); }

/* ============ LOGIN ============ */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}

.login-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}

.login-card h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.login-subtitle {
  color: var(--text-3);
  margin-bottom: 24px;
  font-size: 14px;
}

.login-error {
  background: rgba(240, 89, 117, 0.1);
  border: 1px solid rgba(240, 89, 117, 0.3);
  color: var(--danger);
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 12px;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.15s, background 0.15s;
}

.btn-primary {
  background: var(--accent-2);
  color: white;
  width: 100%;
}

.btn-primary:hover { background: var(--accent); }

.btn-secondary {
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg-2); }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-2);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--bg-3);
  color: var(--text-1);
}

/* ============ APP LAYOUT ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ============ SIDEBAR ============ */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-1);
  z-index: 5;
}

.logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sidebar-user {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-2);
}

.sidebar-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-weight: 600;
  color: var(--text-1);
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child { border-bottom: none; }

.sidebar-section-title {
  padding: 0 16px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
}

.channels-list {
  display: flex;
  flex-direction: column;
}

.channel-item {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}

.channel-item:hover { background: var(--bg-2); }
.channel-item.active { background: var(--bg-3); }

.channel-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  color: var(--text-2);
}

.channel-item.active .channel-icon { color: var(--accent); }

.channel-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}

.channel-unread {
  background: var(--accent-2);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.channel-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ============ MAIN ============ */
.main {
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  overflow: hidden;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-3);
  gap: 12px;
}

.chat-empty-icon { font-size: 48px; opacity: 0.5; }

.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  flex-shrink: 0;
  background: var(--bg-1);
}

.chat-header-info { flex: 1; min-width: 0; }
.chat-title { font-weight: 600; font-size: 16px; }
.chat-subtitle { font-size: 12px; color: var(--text-3); }

.online-count {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.online-count::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.messages-loading {
  text-align: center;
  color: var(--text-3);
  padding: 20px;
  font-size: 13px;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message {
  display: flex;
  gap: 12px;
  padding: 6px 0;
}

.message + .message { margin-top: 0; }

.message.grouped {
  padding-top: 0;
  margin-top: -4px;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.message.grouped .message-avatar { visibility: hidden; height: 0; }

.message-body { flex: 1; min-width: 0; }

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.message-author { font-weight: 600; font-size: 14px; }
.message-time { font-size: 11px; color: var(--text-3); }

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-1);
  font-size: 14px;
}

.message-day-divider {
  text-align: center;
  margin: 16px 0;
  position: relative;
  font-size: 12px;
  color: var(--text-3);
}

.message-day-divider::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--border);
  z-index: 0;
}

.message-day-divider span {
  background: var(--bg-0);
  padding: 0 12px;
  position: relative;
  z-index: 1;
}

/* ============ COMPOSER ============ */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
  flex-shrink: 0;
}

.message-input {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-1);
  padding: 10px 14px;
  font-size: 14px;
  resize: none;
  max-height: 200px;
  outline: none;
  transition: border-color 0.15s;
}

.message-input:focus { border-color: var(--accent-2); }

.send-btn {
  background: var(--accent-2);
  color: white;
  border: none;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 16px;
  flex-shrink: 0;
}

.send-btn:hover { background: var(--accent); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

.modal-header h2 { font-size: 16px; font-weight: 700; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.modal-footer .btn { flex: 0 1 auto; min-width: 100px; padding: 10px 20px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-1);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus { border-color: var(--accent-2); }

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.radio:hover { background: var(--bg-3); }

.radio input { margin-top: 2px; }

/* ============ MOBILE ============ */
.mobile-only { display: none; }

@media (max-width: 768px) {
  :root { --sidebar-w: 100%; }
  
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 100%;
  }
  
  .sidebar {
    grid-column: 1;
    grid-row: 1;
    z-index: 10;
  }
  
  .main {
    grid-column: 1;
    grid-row: 1;
    z-index: 5;
    display: none;
  }
  
  .app.in-chat .sidebar { display: none; }
  .app.in-chat .main { display: flex; }
  
  .mobile-only { display: inline-flex; }
}
