/* ═══════════════════════════════════════════════════════════════
   NexChat — WhatsApp Dark Theme
   Clean, professional dark chat UI
   ═══════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ──────────────────────────────────────────── */
:root {
  --bg-app: #111B21;
  --bg-sidebar: #111B21;
  --bg-chat: #0B141A;
  --bg-header: #202C33;
  --bg-input: #2A3942;
  --bg-incoming: #202C33;
  --bg-outgoing: #005C4B;
  --bg-hover: #202C33;
  --bg-active: #2A3942;
  --bg-modal: #111B21;
  --bg-modal-overlay: rgba(0,0,0,0.55);
  --bg-dropdown: #233138;
  --bg-search: #2A3942;
  --bg-bubble-hover: rgba(255,255,255,0.04);
  --bg-surface: #111B21;

  --text-primary: #E9EDEF;
  --text-secondary: #8696A0;
  --text-muted: #667781;
  --text-bubble: #E9EDEF;
  --text-time: rgba(255,255,255,0.45);
  --text-link: #53BDEB;

  --accent: #00A884;
  --accent-hover: #06CF9C;
  --accent-dark: #008F72;
  --accent-blue: #53BDEB;
  --accent-red: #EA4335;
  --accent-orange: #FF9F43;
  --accent-green: #3BA55C;

  --border: rgba(134,150,160,0.15);
  --border-strong: rgba(134,150,160,0.25);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
  --shadow-popup: 0 8px 24px rgba(0,0,0,0.6);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 50%;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;

  --sidebar-width: 420px;
  --header-height: 60px;
}

/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: var(--text-primary); }
input, textarea { font-family: inherit; font-size: inherit; }
img { display: block; max-width: 100%; }

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes callDotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes speakingPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent); }
  50% { box-shadow: 0 0 0 6px rgba(0,168,132,0.3); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Auth Screen ────────────────────────────────────────────── */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg-chat);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  background: var(--bg-header);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.auth-logo svg {
  width: 48px;
  height: 48px;
  fill: var(--accent);
}

.auth-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 32px;
}

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition-fast);
}

.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.auth-tab:hover {
  color: var(--text-primary);
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.auth-form.active {
  display: flex;
}

.auth-error {
  display: none;
  padding: 10px 14px;
  background: rgba(234,67,53,0.12);
  border: 1px solid rgba(234,67,53,0.3);
  border-radius: var(--radius-sm);
  color: var(--accent-red);
  font-size: 13px;
  text-align: center;
}

.auth-error.visible {
  display: block;
}

/* ─── Form Elements ──────────────────────────────────────────── */
.form-group {
  margin-bottom: 12px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

input[type=text],
input[type=password],
input[type=email],
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  width: 100%;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

input[type=text]:focus,
input[type=password]:focus,
input[type=email]:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
}

input[type=text]::placeholder,
input[type=password]::placeholder,
input[type=email]::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

.btn-primary {
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
}

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

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  padding: 8px 16px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: center;
}

.btn-secondary:hover {
  background: rgba(0,168,132,0.1);
}

/* ─── App Layout ─────────────────────────────────────────────── */
.app-container {
  display: none;
  height: 100vh;
  width: 100vw;
  position: relative;
  overflow: hidden;
}

.app-container.active {
  display: flex;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: 340px;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: relative;
  height: 100vh;
  flex-shrink: 0;
}

/* ─── Sidebar Header ─────────────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-header);
}

.sidebar-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-actions {
  display: flex;
  gap: 4px;
}

.sidebar-header-actions {
  display: flex;
  gap: 4px;
}

/* ─── Icon Button ────────────────────────────────────────────── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  transition: all 0.15s;
}

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

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ─── Search Bar ─────────────────────────────────────────────── */
.sidebar-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.search-bar {
  padding: 8px 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--bg-search);
  border-radius: 20px;
}

.search-box svg {
  width: 16px;
  height: 16px;
  fill: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-search);
  border-radius: 20px;
  padding: 0 12px;
  gap: 8px;
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 8px 0;
  font-size: 14px;
  outline: none;
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* ─── Friend Requests Banner ─────────────────────────────────── */
.friend-requests-banner {
  padding: 8px 16px;
  background: rgba(83,189,235,0.1);
  border-bottom: 1px solid rgba(83,189,235,0.2);
  font-size: 13px;
  color: var(--accent-blue);
}

.friend-request-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.friend-request-item .avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  flex-shrink: 0;
}

.friend-request-item .info {
  flex: 1;
  min-width: 0;
}

.friend-request-item .name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.friend-request-item .label {
  font-size: 12px;
  color: var(--text-secondary);
}

.friend-request-item .actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.friend-request-item .btn-accept {
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
}

.friend-request-item .btn-decline {
  padding: 6px 14px;
  background: var(--bg-input);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

/* ─── User Status Badge ──────────────────────────────────────── */
.user-status-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  flex-shrink: 0;
}

.user-status-badge.friends {
  background: rgba(0,168,132,0.15);
  color: var(--accent);
}

.user-status-badge.pending {
  background: rgba(255,159,67,0.15);
  color: var(--accent-orange);
}

/* ─── Conversation List ──────────────────────────────────────── */
.conversation-list {
  flex: 1;
  overflow-y: auto;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.conversation-item:hover {
  background: var(--bg-hover);
}

.conversation-item.active {
  background: var(--bg-active);
}

.conversation-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.online-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: #31A24C;
  border: 2px solid var(--bg-sidebar);
  position: absolute;
  bottom: 0;
  right: 0;
}

.conversation-info {
  flex: 1;
  min-width: 0;
}

.conversation-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.conversation-name {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-time {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.conversation-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.conversation-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.conversation-badge,
.unread-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ─── Friends Section ────────────────────────────────────────── */
.sidebar-section {
  display: none;
  flex-direction: column;
  height: 100%;
}

.sidebar-section.active {
  display: flex;
}

.friend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.friend-item:hover {
  background: var(--bg-hover);
}

/* ─── Chat Area ──────────────────────────────────────────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
  min-width: 0;
}

#chat-active:not(.hidden) {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#chat-active.hidden {
  display: none;
}

/* ─── Chat Empty State ───────────────────────────────────────── */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-secondary);
  text-align: center;
  padding: 40px;
}

.chat-empty svg {
  width: 80px;
  height: 80px;
  fill: var(--text-muted);
}

.chat-empty h2 {
  font-size: 28px;
  font-weight: 300;
  color: var(--text-primary);
}

.chat-empty p {
  font-size: 14px;
  max-width: 400px;
  line-height: 1.6;
}

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

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}

.chat-header-info {
  min-width: 0;
}

.chat-header-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-status {
  font-size: 13px;
  color: #8696A0;
}

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

.chat-header-actions .icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.chat-header-actions .icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ─── Messages Area ──────────────────────────────────────────── */
#messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px 60px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.incoming {
  align-self: flex-start;
}

.message-bubble {
  padding: 6px 7px 8px 9px;
  border-radius: 8px;
  position: relative;
  word-wrap: break-word;
  min-width: 80px;
}

/* ─── Message Bubble Grouping ──────────────────────────────────
   bubble-end   = first in group (top of visual stack)
   bubble-start = last in group (bottom of visual stack)
   single       = neither class, fully rounded
   Incoming (left): flatten LEFT side connecting corners
   Outgoing (right): flatten RIGHT side connecting corners
*/

/* Base backgrounds */
.message.outgoing .message-bubble {
  background: var(--bg-outgoing);
  border-radius: 8px;
}

.message.incoming .message-bubble {
  background: var(--bg-incoming);
  border-radius: 8px;
}

/* ── Outgoing groups: flatten RIGHT side ── */
.message.outgoing.bubble-end .message-bubble {
  border-bottom-right-radius: 2px;
}

.message.outgoing.bubble-start .message-bubble {
  border-top-right-radius: 2px;
}

.message.outgoing:not(.bubble-start):not(.bubble-end) .message-bubble {
  border-top-right-radius: 2px;
  border-bottom-right-radius: 2px;
}

/* ── Incoming groups: flatten LEFT side ── */
.message.incoming.bubble-end .message-bubble {
  border-bottom-left-radius: 2px;
}

.message.incoming.bubble-start .message-bubble {
  border-top-left-radius: 2px;
}

.message.incoming:not(.bubble-start):not(.bubble-end) .message-bubble {
  border-top-left-radius: 2px;
  border-bottom-left-radius: 2px;
}

.message-sender {
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 2px;
  color: var(--accent);
}

.message-text {
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-bubble);
}

.message-text .link {
  color: var(--text-link);
  text-decoration: underline;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
}

.message-time {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

.message-check {
  display: inline-flex;
  margin-left: 4px;
}

.message-check svg {
  width: 16px;
  height: 11px;
  fill: var(--text-muted);
}

.message-check.read svg {
  fill: var(--accent-blue);
}

/* ─── Message Reactions ──────────────────────────────────────── */
.message-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition-fast);
}

.reaction-chip:hover {
  border-color: var(--accent);
}

.reaction-chip .count {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ─── Message File Attachment ─────────────────────────────────── */
.message-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  margin-top: 4px;
  cursor: pointer;
}

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

.message-file svg {
  width: 24px;
  height: 24px;
  fill: var(--accent);
}

.message-file-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-file-icon svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.message-file-info {
  min-width: 0;
}

.message-file-name {
  font-size: 13px;
  color: var(--text-primary);
}

.message-file-size {
  font-size: 12px;
  color: var(--text-muted);
}

.message-image {
  margin-top: 4px;
  max-width: 330px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}

.message-image img {
  width: 100%;
  display: block;
  border-radius: 8px;
}

/* ─── Typing Indicator ───────────────────────────────────────── */
.typing-indicator {
  display: none;
  padding: 4px 16px 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.typing-indicator.active {
  display: flex;
  align-items: center;
  gap: 6px;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

/* ─── Message Input Area ─────────────────────────────────────── */
.message-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-header);
  flex-shrink: 0;
}

.input-actions {
  display: flex;
  gap: 2px;
}

#btn-attach {
  flex-shrink: 0;
  margin-bottom: 2px;
}

.input-actions .icon-btn {
  width: 36px;
  height: 36px;
}

.input-actions .icon-btn svg {
  width: 22px;
  height: 22px;
}

.message-input-wrapper {
  flex: 1;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 0;
  display: flex;
  align-items: flex-end;
  min-height: 42px;
}

.message-input {
  flex: 1;
  background: var(--bg-input);
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.45;
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 120px;
  overflow-y: auto;
}

.message-input::-webkit-resizer {
  display: none;
}

.message-input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

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

.send-btn svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

/* ─── File Preview ───────────────────────────────────────────── */
.file-preview {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-header);
  border-top: 1px solid var(--border);
}

.file-preview.active {
  display: flex;
}

.file-preview-thumb {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.file-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-preview-thumb svg {
  width: 36px;
  height: 36px;
  fill: var(--accent);
}

.file-preview-info {
  flex: 1;
  min-width: 0;
}

.file-preview-name {
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-preview-size {
  font-size: 12px;
  color: var(--text-muted);
}

.file-preview-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-preview-close:hover {
  background: var(--bg-hover);
}

.file-preview-close svg {
  width: 18px;
  height: 18px;
  fill: var(--text-secondary);
}

.file-preview-close:hover svg {
  fill: var(--text-primary);
}

/* ─── Date Divider ───────────────────────────────────────────── */
.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.date-divider::before {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
  margin-right: 12px;
}

.date-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
  margin-left: 12px;
}

.date-divider span {
  padding: 5px 12px;
  background: var(--bg-dropdown);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ─── Chat Info Panel ────────────────────────────────────────── */
.chat-info-panel {
  display: none;
  flex-direction: column;
  width: 300px;
  min-width: 300px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}

.chat-info-panel.active {
  display: flex;
}

.chat-info-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}


/* Chat info panel content (dynamic) */
.chat-info-avatar-large {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--accent); color: #fff; display: flex;
  align-items: center; justify-content: center; font-size: 32px;
  font-weight: 600; margin: 0 auto 12px;
}
.chat-info-name {
  text-align: center; font-size: 16px; font-weight: 600;
  color: var(--text-primary); margin-bottom: 4px;
}
.chat-info-type {
  text-align: center; font-size: 12px; color: var(--text-secondary);
  margin-bottom: 16px;
}
.chat-info-section {
  padding: 12px 0; border-top: 1px solid var(--border);
}
.chat-info-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  color: var(--text-secondary); margin-bottom: 8px; letter-spacing: 0.5px;
}
.chat-info-member {
  display: flex; align-items: center; gap: 10px; padding: 6px 0;
}
.chat-info-member-avatar {
  width: 32px; height: 32px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 12px;
  font-weight: 600; color: #fff; flex-shrink: 0;
}
.chat-info-member-name {
  flex: 1; font-size: 14px; color: var(--text-primary);
}
.chat-info-member-status {
  font-size: 11px; color: var(--text-secondary);
}
.chat-info-media-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
}
.chat-info-media-item {
  aspect-ratio: 1; border-radius: 4px; overflow: hidden;
  background: var(--bg-hover);
}
.chat-info-media-item img {
  width: 100%; height: 100%; object-fit: cover;
}
.chat-info-empty {
  text-align: center; padding: 16px; color: var(--text-secondary);
  font-size: 13px;
}

/* Settings color picker */
.color-picker {
  display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 0;
}
.color-dot {
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: all 0.15s;
}
.color-dot:hover { transform: scale(1.1); }
.color-dot.active { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

/* Settings login history */
.s-history-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-radius: 6px; font-size: 13px;
  color: var(--text-primary);
}
.s-history-item:nth-child(odd) {
  background: rgba(134,150,160,0.05);
}
.s-history-item .s-hi-device { color: var(--text-secondary); font-size: 12px; }
.s-history-item .s-hi-time { color: var(--text-secondary); font-size: 11px; }
.chat-info-panel-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.chat-info-content {
  padding: 12px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}

.member-item .avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  flex-shrink: 0;
}

.member-item .name {
  font-size: 14px;
  color: var(--text-primary);
}

/* ─── Screen Share Banner ────────────────────────────────────── */
.screen-share-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(0,168,132,0.15);
  border-bottom: 1px solid var(--accent-dark);
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  flex-shrink: 0;
}

.screen-share-banner.active {
  display: flex;
}

.screen-share-banner button {
  padding: 6px 16px;
  background: var(--accent-red);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

/* ─── Screen Share Overlay ───────────────────────────────────── */
.screen-share-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 500;
  flex-direction: column;
}

.screen-share-overlay.active {
  display: flex;
}

.screen-share-video-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.screen-share-video-container video {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-sm);
}

.screen-share-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-header);
}

.screen-share-controls .btn-stop {
  padding: 10px 24px;
  background: var(--accent-red);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
}

.screen-share-controls .btn-stop:hover {
  background: #D32F2F;
}

/* ─── Call Join Banner ───────────────────────────────────────── */
.call-join-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(0,168,132,0.15);
  border-bottom: 1px solid var(--accent-dark);
}

.call-join-banner.active,
.call-join-banner.visible {
  display: flex;
}

.call-join-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
}

.call-join-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.call-join-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.btn-call-join {
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

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

/* ─── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-modal-overlay);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-header);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body {
  padding: 16px 20px;
  max-height: 60vh;
  overflow-y: auto;
}

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

/* ─── Search User List (for modals) ──────────────────────────── */
.search-user-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.search-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.search-user-item:last-child {
  border-bottom: none;
}

.search-user-item:hover {
  background: var(--bg-hover);
}

.search-user-item .avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}

.search-user-item .info {
  flex: 1;
  min-width: 0;
}

.search-user-item .name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.search-user-item .username {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ─── Context Menu ───────────────────────────────────────────── */
.context-menu {
  display: none;
  position: fixed;
  background: var(--bg-dropdown);
  border-radius: var(--radius-md);
  padding: 6px 0;
  min-width: 180px;
  box-shadow: var(--shadow-popup);
  z-index: 2000;
}

.context-menu.active {
  display: block;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}

.context-menu-item:hover {
  background: var(--bg-hover);
}

.context-menu-item svg {
  width: 18px;
  height: 18px;
  fill: var(--text-secondary);
}

.context-menu-item.danger {
  color: var(--accent-red);
}

.context-menu-item.danger svg {
  fill: var(--accent-red);
}

/* ─── Toast ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-header);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  z-index: 3000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  border-left: 3px solid var(--accent);
}

.toast.active {
  opacity: 1;
}

.toast.error {
  border-left-color: var(--accent-red);
}

.call-toast {
  border-left-color: var(--accent-green);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 7.7s forwards;
  background: #1a3a2a;
  border: 1px solid #3BA55C;
  padding: 14px 24px;
  font-size: 14px;
  max-width: 420px;
}

.call-toast:hover {
  background: #1e4a34;
}

/* ─── Loading Spinner ────────────────────────────────────────── */
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

/* ─── Empty State (generic) ──────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  gap: 8px;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  fill: var(--text-muted);
  opacity: 0.5;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 14px;
}


/* ═══════════════════════════════════════════════════════════
   MESSAGE AVATARS
   ═══════════════════════════════════════════════════════════ */
.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.message.outgoing .message-row {
  justify-content: flex-end;
}
.message-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.message-avatar-spacer {
  width: 32px;
  min-width: 32px;
}
.message.outgoing .message-row .message-bubble {
  margin-left: auto;
}
.message.incoming .message-row .message-bubble {
  margin-right: auto;
}

/* ═══════════════════════════════════════════════════════════
   AVATAR EDITOR
   ═══════════════════════════════════════════════════════════ */

/* ─── Call Bar (sidebar bottom) ─────────────────────────────── */
.call-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #2C2F33;
  border-top: 2px solid var(--accent);
  flex-shrink: 0;
}

.call-bar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.call-bar-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3BA55C;
  flex-shrink: 0;
}

.call-bar-status .status-dot.disconnected {
  background: #ED4245;
}

.call-bar-status .status-text {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.call-bar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: callDotPulse 2s ease-in-out infinite;
}

.call-bar-timer {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

.call-bar-info {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.call-bar-participants {
  display: flex;
  align-items: center;
}

.call-bar-participants .call-bar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #2C2F33;
  margin-left: -8px;
  overflow: hidden;
  background: #404349;
}

.call-bar-participants .call-bar-avatar:first-child {
  margin-left: 0;
}

.call-bar-participants .call-bar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.call-bar-participants .call-bar-avatar-more {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #404349;
  border: 2px solid #2C2F33;
  margin-left: -8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}

.call-bar .disconnect-btn {
  background: #ED4245;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.call-bar .disconnect-btn:hover {
  background: #c93a3c;
}

.call-bar-leave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 12px;
  background: #ED4245;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.call-bar-leave svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.call-bar-leave:hover {
  background: #c93a3c;
}

.call-bar-status .call-timer-mini {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  margin-left: 4px;
}

/* ─── Call View (main area) ─────────────────────────────────── */
.call-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #0B141A;
  color: #fff;
}

/* ─── Call View Header ──────────────────────────────────────── */
.call-view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
}

.call-view-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.call-view-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.call-view-name {
  font-size: 18px;
  font-weight: 600;
}

.call-view-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.call-view-timer {
  margin-left: auto;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 16px;
  color: var(--accent);
}

.call-view-header .call-view-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

/* ─── Call Participants Grid ────────────────────────────────── */
/* Mobile back button */
.mobile-back { display: none; }
/* Call controls bar */
.call-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(17,27,33,0.95);
  border-top: 1px solid rgba(134,150,160,0.1);
}
.call-control-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(134,150,160,0.15);
  color: #E9EDEF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 18px;
}
.call-control-btn:hover { background: rgba(134,150,160,0.25); }
.call-control-btn.active { background: #00A884; color: #fff; }
.call-control-btn.danger { background: #EA4335; color: #fff; }
.call-control-btn.danger:hover { background: #d63626; }

.call-participants-grid {
  flex: 1;
  display: grid;
  gap: 16px;
  padding: 24px;
  place-content: center;
  overflow-y: auto;
}

.call-participants-grid[data-count="1"] {
  grid-template-columns: 1fr;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
}

.call-participants-grid[data-count="2"] {
  grid-template-columns: 1fr 1fr;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.call-participants-grid[data-count="3"],
.call-participants-grid[data-count="4"] {
  grid-template-columns: 1fr 1fr;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.call-participants-grid[data-count="5"],
.call-participants-grid[data-count="6"],
.call-participants-grid[data-count="7"],
.call-participants-grid[data-count="8"],
.call-participants-grid[data-count="9"] {
  grid-template-columns: 1fr 1fr 1fr;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

/* ─── Call Participant Card ─────────────────────────────────── */
.call-participant {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #1E1F22;
  border-radius: 16px;
  padding: 24px;
  min-height: 180px;
  width: 100%;
  max-width: 280px;
  position: relative;
  transition: box-shadow 0.2s ease;
}

.call-participant .participant-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #404349;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.call-participant .participant-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.call-participant .participant-avatar .avatar-initials {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  user-select: none;
}

.call-participant .participant-name {
  font-size: 14px;
  font-weight: 600;
  color: #E9EDEF;
}

/* ═══ SETTINGS OVERLAY ═══ */
.settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
}
.settings-overlay.active { display: flex; }

.settings-container {
  width: min(860px, 94vw);
  height: min(600px, 88vh);
  background: #111B21;
  border: 1px solid rgba(134,150,160,0.15);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(134,150,160,0.15);
  background: #1F2C34;
  flex-shrink: 0;
}
.settings-header h2 { font-size: 16px; font-weight: 600; color: #E9EDEF; margin: 0; }
.settings-body { display: flex; flex: 1; overflow: hidden; }
.settings-tabs {
  width: 180px; display: flex; flex-direction: column;
  border-right: 1px solid rgba(134,150,160,0.15); background: #1F2C34;
  padding: 8px; gap: 2px; flex-shrink: 0; overflow-y: auto;
}
.settings-tab {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: none; background: transparent; color: #8696A0; border-radius: 8px;
  cursor: pointer; font-size: 13px; text-align: left; transition: all 0.15s;
}
.settings-tab:hover { background: rgba(134,150,160,0.1); color: #E9EDEF; }
.settings-tab.active { background: rgba(0,168,132,0.12); color: #00A884; font-weight: 600; }
.settings-tab svg { width: 16px; height: 16px; flex-shrink: 0; }
.settings-content { flex: 1; overflow-y: auto; padding: 24px; }
.settings-section { display: none; }
.settings-section.active { display: block; }
.settings-section-header { margin-bottom: 20px; }
.settings-section-header h3 { font-size: 18px; font-weight: 600; color: #E9EDEF; margin: 0 0 4px 0; }
.settings-section-desc { font-size: 13px; color: #8696A0; margin: 0; }
.settings-field { margin-bottom: 14px; }
.settings-field > label { display: block; font-size: 12px; font-weight: 600; color: #8696A0; margin-bottom: 6px; }
.settings-field input[type="text"],
.settings-field input[type="password"],
.settings-field input[type="tel"],
.settings-field textarea {
  width: 100%; padding: 8px 12px; background: #111B21;
  border: 1px solid rgba(134,150,160,0.2); border-radius: 6px;
  color: #E9EDEF; font-size: 13px; outline: none; box-sizing: border-box; font-family: inherit;
}
.settings-field input:focus,
.settings-field textarea:focus { border-color: #00A884; }
.settings-field textarea { resize: vertical; min-height: 60px; }
.settings-field-hint { font-size: 11px; color: #8696A0; margin-top: 4px; }
.select-wrapper { position: relative; }
.select-wrapper select,
.settings-field select {
  width: 100%; padding: 8px 12px; background: #111B21;
  border: 1px solid rgba(134,150,160,0.2); border-radius: 6px;
  color: #E9EDEF; font-size: 13px; outline: none; box-sizing: border-box; appearance: auto;
}
.settings-group {
  margin-bottom: 16px; padding: 16px; background: rgba(134,150,160,0.05);
  border-radius: 8px; border: 1px solid rgba(134,150,160,0.08);
}
.settings-group h4 { font-size: 13px; font-weight: 600; color: #E9EDEF; margin: 0 0 12px 0; }
.settings-group-desc { font-size: 12px; color: #8696A0; margin-bottom: 12px; }
.settings-group.settings-danger { border-color: rgba(234,67,53,0.3); background: rgba(234,67,53,0.05); }
.settings-divider { height: 1px; background: rgba(134,150,160,0.1); margin: 16px 0; }
.settings-toggle { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.settings-toggle-info { flex: 1; }
.settings-toggle-label { font-size: 13px; color: #E9EDEF; display: block; }
.settings-toggle-desc { font-size: 11px; color: #8696A0; margin-top: 2px; display: block; }
.toggle-switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: rgba(134,150,160,0.3);
  border-radius: 11px; cursor: pointer; transition: 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  left: 2px; bottom: 2px; background: white; border-radius: 50%; transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: #00A884; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
.settings-save-bar { margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(134,150,160,0.1); }
.settings-content .btn-primary { padding: 8px 20px; font-size: 13px; border-radius: 6px; }
.btn-danger { padding: 8px 20px; border: none; background: #EA4335; color: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.15s; }
.btn-danger:hover { filter: brightness(1.15); }
.btn-remove-avatar { padding: 6px 14px; font-size: 12px; border: 1px solid rgba(134,150,160,0.2); background: transparent; color: #E9EDEF; border-radius: 6px; cursor: pointer; }
.btn-remove-avatar:hover { border-color: #EA4335; color: #EA4335; }
#btn-close-settings { background: transparent; color: #8696A0; padding: 6px; border-radius: 6px; }
#btn-close-settings:hover { background: rgba(134,150,160,0.1); color: #E9EDEF; }
.settings-static-value { font-size: 14px; color: #E9EDEF; padding: 6px 0; }
.settings-empty { font-size: 13px; color: #8696A0; padding: 12px 0; }
.optional { font-size: 11px; color: #8696A0; font-weight: 400; }
.settings-slider,
.slider-wrapper { width: 100%; margin: 8px 0; }
.settings-slider input[type="range"],
.slider-wrapper input[type="range"] {
  -webkit-appearance: none; width: 100%; height: 4px; border-radius: 2px;
  background: rgba(134,150,160,0.2); outline: none;
}
.settings-slider input[type="range"]::-webkit-slider-thumb,
.slider-wrapper input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #00A884; cursor: pointer; border: 2px solid #1F2C34;
}
.slider-value { font-size: 12px; color: #8696A0; text-align: right; margin-top: 2px; }
.status-options { display: flex; gap: 8px; flex-wrap: wrap; }
.status-option {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px;
  border: 1px solid rgba(134,150,160,0.2); border-radius: 8px; background: transparent;
  color: #E9EDEF; cursor: pointer; font-size: 13px; transition: all 0.15s;
}
.status-option:hover { border-color: #00A884; }
.status-option.active { border-color: #00A884; background: rgba(0,168,132,0.1); color: #00A884; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.theme-options { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-option {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 14px; border: 2px solid rgba(134,150,160,0.15); border-radius: 8px;
  cursor: pointer; transition: all 0.15s; background: transparent; color: #E9EDEF; font-size: 12px;
}
.theme-option:hover { border-color: rgba(134,150,160,0.3); }
.theme-option.active { border-color: #00A884; }
.theme-preview { width: 36px; height: 24px; border-radius: 4px; border: 1px solid rgba(134,150,160,0.2); }
.accent-color-options { display: flex; gap: 8px; flex-wrap: wrap; }
.accent-option {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: all 0.15s;
}
.accent-option:hover { transform: scale(1.15); }
.accent-option.active { border-color: #fff; box-shadow: 0 0 0 2px #00A884; }
.bg-options { display: flex; gap: 8px; flex-wrap: wrap; }
.bg-option {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 12px; border: 2px solid rgba(134,150,160,0.15); border-radius: 8px;
  cursor: pointer; transition: all 0.15s; background: transparent; color: #E9EDEF; font-size: 11px;
}
.bg-option:hover { border-color: rgba(134,150,160,0.3); }
.bg-option.active { border-color: #00A884; }
.bg-preview { width: 36px; height: 24px; border-radius: 4px; }
.login-history-list,
.session-list { max-height: 200px; overflow-y: auto; }
.avatar-current-row { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.avatar-preview-circle {
  width: 72px; height: 72px; border-radius: 50%; background: #00A884;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: #fff; overflow: hidden; flex-shrink: 0;
}
.avatar-current-actions { display: flex; gap: 8px; }
.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.color-dot {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: all 0.15s;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.active { border-color: #fff; box-shadow: 0 0 0 2px #00A884; }
@media (max-width: 768px) {
  .settings-container { flex-direction: column; height: 100vh; width: 100vw; border-radius: 0; }
  .settings-body { flex-direction: column; }
  .settings-tabs { width: 100%; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid rgba(134,150,160,0.15); }
}
/* ═══ AVATAR EDITOR — Professional Canvas ═══ */
.avatar-editor-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
}
.avatar-editor-overlay.active { display: flex; }

.avatar-editor {
  width: min(900px, 94vw);
  height: min(640px, 88vh);
  background: var(--bg-primary, #111B21);
  border: 1px solid var(--border, rgba(134,150,160,0.15));
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

/* Header */
.ae-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary, #1F2C34);
  border-bottom: 1px solid var(--border, rgba(134,150,160,0.15));
  flex-shrink: 0;
}
.ae-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #E9EDEF);
  margin: 0;
}
.ae-header-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.ae-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #8696A0);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.ae-icon-btn:hover { background: var(--hover, rgba(134,150,160,0.1)); color: var(--text-primary, #E9EDEF); }
.ae-sep { width: 1px; height: 20px; background: var(--border, rgba(134,150,160,0.15)); margin: 0 4px; }
.ae-zoom-val { font-size: 12px; color: var(--text-secondary, #8696A0); min-width: 36px; text-align: center; }
.ae-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #8696A0);
  border-radius: 6px;
  cursor: pointer;
  margin-left: 8px;
}
.ae-close-btn:hover { background: rgba(234,67,53,0.15); color: #EA4335; }

/* Body */
.ae-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Canvas Area */
.ae-canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
  background: #0B141A;
}
.ae-upload-zone {
  width: 280px;
  height: 280px;
  border: 2px dashed rgba(0,168,132,0.3);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary, #8696A0);
}
.ae-upload-zone:hover,
.ae-upload-zone.dragover {
  border-color: var(--accent, #00A884);
  background: rgba(0,168,132,0.05);
}
.ae-upload-zone p { font-size: 14px; margin: 0; color: var(--text-primary, #E9EDEF); }
.ae-upload-zone span { font-size: 12px; opacity: 0.6; }

#avatar-canvas {
  max-width: 320px;
  max-height: 320px;
  border-radius: 8px;
  background: #0B141A;
}

/* Shape Row */
.ae-shape-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}
.ae-shape-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 2px solid transparent;
  background: var(--bg-secondary, #1F2C34);
  color: var(--text-secondary, #8696A0);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.ae-shape-btn:hover { border-color: var(--border, rgba(134,150,160,0.3)); color: var(--text-primary, #E9EDEF); }
.ae-shape-btn.active { border-color: var(--accent, #00A884); color: var(--accent, #00A884); }

/* Preview Row */
.ae-preview-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  justify-content: center;
  margin-top: 8px;
}
.ae-prev-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.ae-prev-item span { font-size: 11px; color: var(--text-secondary, #8696A0); }
.ae-prev-circle {
  border-radius: 50%;
  background: #0B141A;
  border: 2px solid var(--border, rgba(134,150,160,0.15));
  overflow: hidden;
  background-size: cover;
  background-position: center;
}
/* Tools Panel */
.ae-tools {
  width: 280px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border, rgba(134,150,160,0.15));
  background: var(--bg-secondary, #1F2C34);
  overflow: hidden;
}
.ae-tabs {
  display: flex;
  border-bottom: 1px solid var(--border, rgba(134,150,160,0.15));
  flex-shrink: 0;
}
.ae-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #8696A0);
  cursor: pointer;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
}
.ae-tab:hover { color: var(--text-primary, #E9EDEF); }
.ae-tab.active { color: var(--accent, #00A884); border-bottom-color: var(--accent, #00A884); }

/* Panels */
.ae-panel { display: none; flex-direction: column; gap: 0; overflow-y: auto; flex: 1; }
.ae-panel.active { display: flex; }
.ae-section { padding: 12px 16px; border-bottom: 1px solid var(--border, rgba(134,150,160,0.1)); }
.ae-section:last-child { border-bottom: none; }
.ae-section h4 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary, #8696A0);
  margin: 0 0 10px 0;
}

/* Buttons */
.ae-btn-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ae-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid var(--border, rgba(134,150,160,0.2));
  background: var(--bg-primary, #111B21);
  color: var(--text-primary, #E9EDEF);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
  white-space: nowrap;
}
.ae-btn:hover { border-color: var(--accent, #00A884); }
.ae-btn.active { background: rgba(0,168,132,0.15); border-color: var(--accent, #00A884); color: var(--accent, #00A884); }

/* Sliders */
.ae-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.ae-slider-row label { font-size: 12px; color: var(--text-secondary, #8696A0); min-width: 70px; }
.ae-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(134,150,160,0.2);
  outline: none;
}
.ae-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent, #00A884);
  cursor: pointer;
  border: 2px solid var(--bg-secondary, #1F2C34);
}
.ae-val { font-size: 11px; color: var(--text-secondary, #8696A0); min-width: 32px; text-align: right; }

/* Filter Grid */
.ae-filter-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.ae-filter-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border: 2px solid transparent;
  background: var(--bg-primary, #111B21);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.ae-filter-btn:hover { border-color: var(--border, rgba(134,150,160,0.3)); }
.ae-filter-btn.active { border-color: var(--accent, #00A884); }
.ae-filter-btn span { font-size: 10px; color: var(--text-secondary, #8696A0); }
.ae-filter-btn.active span { color: var(--accent, #00A884); }
.ae-ft {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: var(--bg-secondary, #1F2C34);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

/* Color Row */
.ae-color-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.ae-color-row span { font-size: 12px; color: var(--text-secondary, #8696A0); }
.ae-color-row input[type="color"] {
  width: 32px;
  height: 28px;
  border: 1px solid var(--border, rgba(134,150,160,0.2));
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

/* Input */
.ae-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary, #111B21);
  border: 1px solid var(--border, rgba(134,150,160,0.2));
  border-radius: 6px;
  color: var(--text-primary, #E9EDEF);
  font-size: 13px;
  outline: none;
}
.ae-input:focus { border-color: var(--accent, #00A884); }

/* Footer */
.ae-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-secondary, #1F2C34);
  border-top: 1px solid var(--border, rgba(134,150,160,0.15));
  flex-shrink: 0;
}
.ae-export { display: flex; align-items: center; gap: 8px; }
.ae-export label { font-size: 12px; color: var(--text-secondary, #8696A0); }
.ae-export select {
  padding: 4px 8px;
  background: var(--bg-primary, #111B21);
  border: 1px solid var(--border, rgba(134,150,160,0.2));
  border-radius: 4px;
  color: var(--text-primary, #E9EDEF);
  font-size: 12px;
}
.ae-footer-actions { display: flex; gap: 8px; }
.ae-btn-secondary {
  padding: 8px 16px;
  border: 1px solid var(--border, rgba(134,150,160,0.2));
  background: transparent;
  color: var(--text-secondary, #8696A0);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.ae-btn-secondary:hover { background: var(--hover, rgba(134,150,160,0.1)); color: var(--text-primary, #E9EDEF); }
.ae-btn-primary {
  padding: 8px 20px;
  border: none;
  background: var(--accent, #00A884);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.ae-btn-primary:hover { filter: brightness(1.1); }

/* Responsive */
@media (max-width: 768px) {
  .avatar-editor { width: 100vw; height: 100vh; border-radius: 0; }
  .ae-body { flex-direction: column; }
  .ae-tools { width: 100%; max-height: 40vh; border-left: none; border-top: 1px solid var(--border); }
  .ae-canvas-area { padding: 16px; }
  .ae-upload-zone { width: 200px; height: 200px; }
}
