/* ═══ Floakly Layout ═══ */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  background: var(--bg-page);
  color: var(--text-primary);
  overflow: visible;
}

/* ── Shell ── */
#app {
  display: flex;
  flex-direction: row;
  height: 100vh;
  overflow: visible;
}

/* ═══ SIDEBAR 60px ═══ */
.sidebar {
  width: 60px;
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  flex-shrink: 0;
  gap: 4px;
  overflow: visible;
}

.sb-logo {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
  cursor: pointer;
  text-decoration: none;
}
.sb-logo-letter {
  font-size: 22px; font-weight: 700;
  color: var(--primary);
  font-style: italic;
}

.sb-nav {
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  flex: 1;
  overflow: visible;
}

.sb-nav-item {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  position: relative;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
}
.sb-nav-item:hover {
  background: var(--bg-conv-hover);
  color: var(--text-primary);
}
.sb-nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

.sb-badge {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-sidebar);
}

.sb-bottom {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  margin-top: auto;
}

.sb-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border: none;
  font-family: var(--font-sans);
}
.sb-user-avatar img {
  width: 100%; height: 100%;
  border-radius: 50%; object-fit: cover;
}

/* ═══ CONV PANEL 280px ═══ */
.conv-panel {
  width: 280px;
  height: 100vh;
  background: var(--bg-conv-panel);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: visible;
}

.conv-header {
  padding: 16px 14px 10px;
  flex-shrink: 0;
}
.conv-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px;
}

.conv-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-search);
  border-radius: var(--radius-search);
  padding: 10px 14px;
}
.conv-search-icon {
  font-size: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.conv-search-input {
  border: none;
  background: transparent;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  outline: none;
  flex: 1;
  font-family: var(--font-sans);
}
.conv-search-input::placeholder { color: var(--text-muted); }

.conv-tabs {
  display: flex;
  padding: 8px 14px 0;
  gap: 0;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.conv-tab {
  font-size: 13px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-sans);
  margin-bottom: -0.5px;
  transition: all 0.12s;
}
.conv-tab:hover { color: var(--text-primary); }
.conv-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.conv-list::-webkit-scrollbar { width: 4px; }
.conv-list::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 2px; }

/* ── Conv Item ── */
.conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 0.5px solid var(--border-light);
  transition: background 0.1s;
  user-select: none;
}
.conv-item:hover   { background: var(--bg-conv-hover); }
.conv-item.active  { background: var(--bg-conv-active); }
.conv-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.conv-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
}
.conv-avatar img {
  width: 100%; height: 100%;
  border-radius: 50%; object-fit: cover;
}

.av-blue    { background: #3b82f6; }
.av-purple  { background: #8b5cf6; }
.av-green   { background: #10b981; }
.av-yellow  { background: #f59e0b; }
.av-red     { background: #ef4444; }
.av-pink    { background: #ec4899; }
.av-teal    { background: #14b8a6; }
.av-orange  { background: #f97316; }
.av-indigo  { background: #6366f1; }

.conv-online-dot {
  position: absolute;
  bottom: 1px; right: 1px;
  width: 11px; height: 11px;
  background: var(--online);
  border-radius: 50%;
  border: 2px solid var(--bg-conv-panel);
  display: none;
}
.conv-item.online .conv-online-dot { display: block; }

.conv-info {
  flex: 1;
  min-width: 0;
}
.conv-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: visible;
  text-overflow: ellipsis;
}
.conv-last {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: visible;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.conv-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.conv-unread {
  min-width: 20px; height: 20px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  font-size: 11px; font-weight: 600;
  display: none;
  align-items: center; justify-content: center;
  padding: 0 5px;
}
.conv-item.has-unread .conv-unread { display: flex; }

.conv-placeholder {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
  font-size: 13px; color: var(--text-muted);
  text-align: center;
}

/* ═══ CHAT AREA ═══ */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: visible;
  background: var(--bg-chat);
  position: relative;
}

/* ── Chat Header ── */
.chat-header {
  height: 64px;
  padding: 0 16px;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--bg-chat);
}

.chat-header-identity {
  display: flex; align-items: center; gap: 10px;
}
.chat-header-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.chat-header-name {
  font-size: 15px; font-weight: 600;
  color: var(--text-primary);
}
.chat-header-status {
  font-size: 12px;
  display: flex; align-items: center; gap: 5px;
  margin-top: 1px;
}
.chat-header-status.online  { color: var(--online); }
.chat-header-status.offline { color: var(--text-muted); }
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%; flex-shrink: 0;
}
.chat-header-status.online  .status-dot { background: var(--online); }
.chat-header-status.offline .status-dot { background: var(--offline); }

.chat-header-actions {
  display: flex; align-items: center; gap: 8px;
}
.chat-action-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.12s;
}
.chat-action-btn:hover { background: var(--bg-conv-hover); }

.btn-back {
  display: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  align-items: center; justify-content: center;
  margin-right: 8px;
}
.btn-back:hover { background: var(--bg-conv-hover); }

/* ── Chat Messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 2px; }

.chat-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; gap: 12px;
  color: var(--text-muted);
}
.chat-placeholder .placeholder-icon { opacity: 0.25; }
.chat-placeholder .placeholder-icon svg { width: 64px; height: 64px; }

/* ── Scroll to bottom ── */
.scroll-to-bottom {
  position: absolute;
  bottom: 76px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #fff;
  border: 0.5px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: none;
  align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 16px; color: var(--text-secondary);
  z-index: 10;
}
.scroll-to-bottom.visible { display: flex; }

/* ── Chat Composer ── */
.chat-composer {
  height: 64px;
  padding: 0 12px;
  border-top: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-chat);
  flex-shrink: 0;
}

.composer-attach-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none; background: transparent;
  color: var(--text-secondary);
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s;
}
.composer-attach-btn:hover { color: var(--primary); }

.composer-input {
  flex: 1;
  height: 40px;
  background: var(--bg-composer);
  border: none;
  border-radius: var(--radius-composer);
  padding: 0 16px;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
}
.composer-input:focus { background: #f3f4f6; }
.composer-input::placeholder { color: var(--text-muted); }

.composer-send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.12s, transform 0.1s;
}
.composer-send-btn:hover:not(:disabled) { opacity: 0.88; }
.composer-send-btn:active:not(:disabled) { transform: scale(0.95); }
.composer-send-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

/* ── Resizer ── */
.resizer {
  width: 4px; cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  transition: background 0.15s;
}
.resizer:hover { background: var(--primary-light); }

/* ── Responsive ── */
@media (max-width: 1023px) {
  .conv-panel { width: 240px; }
}
@media (max-width: 767px) {
  .sidebar    { display: none; }
  .conv-panel { width: 100%; border-right: none; }
  .chat-area  { display: none; }
  .chat-open .conv-panel { display: none; }
  .chat-open .chat-area  { display: flex; width: 100%; }
  .btn-back { display: flex; }
}

/* ── Login screen (preserved) ── */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; background: var(--bg-page);
}
.login-card {
  background: #fff;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-card);
  padding: 32px;
  width: 360px;
  max-width: 90vw;
  text-align: center;
}
.login-card h1 { font-size: 24px; font-weight: 700; margin: 12px 0 4px; color: var(--text-primary); }
.login-card .muted { color: var(--text-secondary); font-size: 13px; margin-bottom: 20px; }
.login-card input {
  width: 100%; padding: 10px 14px; margin-bottom: 10px;
  border: 0.5px solid var(--border); border-radius: 8px;
  font-size: var(--font-size-base); font-family: var(--font-sans);
  outline: none; background: var(--bg-page);
}
.login-card input:focus { border-color: var(--primary); }
.login-card button {
  width: 100%; padding: 10px; margin-top: 6px;
  border-radius: 8px; border: none; cursor: pointer;
  font-size: var(--font-size-base); font-family: var(--font-sans);
  font-weight: 500; transition: opacity 0.12s;
}
.login-card button:hover { opacity: 0.88; }
#login-btn {
  background: var(--primary); color: #fff;
}
.btn-login-signup {
  background: transparent; color: var(--primary);
  border: 0.5px solid var(--border) !important;
}
.error { color: var(--danger); font-size: 13px; }
.hidden { display: none !important; }

.form-select-login {
  width: 100%; padding: 10px 14px; margin-bottom: 10px;
  border: 0.5px solid var(--border); border-radius: 8px;
  font-size: var(--font-size-base); font-family: var(--font-sans);
  outline: none; background: var(--bg-page); color: var(--text-primary);
}

/* Language selector in conv-header */
.lang-select {
  font-size: 12px; padding: 4px 8px;
  border-radius: 6px;
  border: 0.5px solid var(--border);
  background: var(--bg-page); color: var(--text-primary);
  margin-left: auto; font-family: var(--font-sans);
  cursor: pointer;
}
.lang-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--online);
  flex-shrink: 0;
}
