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

body {
  font-family: 'Segoe UI', Roboto, sans-serif;
  background: #313338;
  color: #dbdee1;
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* --- Auth --- */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: #1e1f22;
}
.auth-card {
  background: #313338;
  padding: 32px;
  border-radius: 8px;
  width: 340px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.auth-card h1 { text-align: center; margin-bottom: 20px; }
.tabs { display: flex; margin-bottom: 16px; border-radius: 6px; overflow: hidden; }
.tab-btn {
  flex: 1; padding: 8px; background: #2b2d31; color: #949ba4;
  border: none; cursor: pointer; font-weight: 600;
}
.tab-btn.active { background: #5865f2; color: white; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  background: #1e1f22; border: 1px solid #1e1f22; color: white;
  padding: 10px; border-radius: 4px; font-size: 14px;
}
.auth-form input:focus { outline: 2px solid #5865f2; }
.auth-form button {
  background: #5865f2; color: white; border: none; padding: 10px;
  border-radius: 4px; font-weight: 600; cursor: pointer; margin-top: 6px;
}
.auth-form button:hover { background: #4752c4; }
.error { color: #fa777c; font-size: 13px; min-height: 16px; }

/* --- App layout --- */
.app-screen { display: flex; height: 100vh; }

.sidebar {
  width: 280px; background: #2b2d31; display: flex; flex-direction: column;
  border-right: 1px solid #1e1f22;
}
.sidebar-header {
  display: flex; align-items: center; gap: 10px; padding: 14px;
  border-bottom: 1px solid #1e1f22;
}
.sidebar-header span { flex: 1; font-weight: 600; }
.sidebar-header button {
  background: none; border: none; color: #949ba4; font-size: 18px; cursor: pointer;
}

.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: #5865f2;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; flex-shrink: 0;
}

.add-contact { padding: 10px; position: relative; }
.add-contact input {
  width: 100%; background: #1e1f22; border: none; color: white;
  padding: 8px 10px; border-radius: 4px;
}
.search-results {
  position: absolute; left: 10px; right: 10px; top: 44px;
  background: #1e1f22; border-radius: 6px; overflow: hidden; z-index: 10;
}
.search-result-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer;
}
.search-result-item:hover { background: #313338; }

.contacts-list { flex: 1; overflow-y: auto; padding: 6px; }
.contact-item {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 6px;
  cursor: pointer; margin-bottom: 2px;
}
.contact-item:hover, .contact-item.active { background: #35373c; }
.contact-info { flex: 1; min-width: 0; }
.contact-name { font-weight: 600; font-size: 14px; }
.contact-last { font-size: 12px; color: #949ba4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #80848e;
  border: 2px solid #2b2d31; position: relative; top: 12px; left: -12px;
}
.status-dot.online { background: #23a559; }

/* --- Chat area --- */
.chat-area { flex: 1; display: flex; flex-direction: column; background: #313338; }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: #949ba4; }
.chat-active { display: flex; flex-direction: column; height: 100%; }

.chat-header {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid #1e1f22; box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}
#chat-username { font-weight: 700; }
.chat-status { font-size: 12px; color: #949ba4; }

.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.message-row { display: flex; gap: 10px; max-width: 70%; }
.message-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { background: #2b2d31; padding: 8px 12px; border-radius: 12px; font-size: 14px; word-wrap: break-word; }
.message-row.mine .bubble { background: #5865f2; color: white; }
.msg-time { font-size: 10px; color: #949ba4; margin-top: 2px; }

.typing-indicator { padding: 0 16px 6px; font-size: 12px; color: #949ba4; font-style: italic; }

.message-form { display: flex; gap: 8px; padding: 14px 16px; }
.message-form input {
  flex: 1; background: #383a40; border: none; color: white;
  padding: 10px 14px; border-radius: 8px; font-size: 14px;
}
.message-form button {
  background: #5865f2; color: white; border: none; padding: 0 18px;
  border-radius: 8px; cursor: pointer; font-weight: 600;
}
