/* =========================
   HEYDUDE — style.css (v3)
   SVG icons, smooth animations, fully responsive
========================= */

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

:root {
  --bg:           #0d1117;
  --card:         #161b22;
  --sidebar:      #13181f;
  --border:       #21262d;

  --primary:      #ff4757;
  --primary-dark: #c0392b;
  --primary-glow: rgba(255, 71, 87, 0.22);

  --green:        #2ecc71;
  --text:         #e6edf3;
  --text-light:   #8b949e;
  --text-muted:   #484f58;

  --message-bg:   #1c2128;
  --message-own:  #1a6b3a;

  --shadow:       0 16px 40px rgba(0,0,0,.4);
  --shadow-sm:    0 4px 12px rgba(0,0,0,.25);
  --radius:       14px;
  --radius-lg:    20px;

  --vh:           1vh; /* set by JS for mobile viewport fix */
  --transition:   0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --bounce:       0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="light"] {
  --bg:           #f0f2f5;
  --card:         #ffffff;
  --sidebar:      #ffffff;
  --border:       #e3e5e8;
  --primary:      #ff4757;
  --green:        #25d366;
  --text:         #1c1e21;
  --text-light:   #65676b;
  --text-muted:   #b0b3b8;
  --message-bg:   #eef0f2;
  --message-own:  #d8f5e0;
  --shadow:       0 4px 20px rgba(0,0,0,.08);
}

[data-theme="light"] .message-wrap.sent .message { color: #1c1e21; }
[data-theme="light"] .sidebar { border-right: 1px solid var(--border); }

html, body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

body {
  height: calc(var(--vh, 1vh) * 100);
  transition: background var(--transition), color var(--transition);
}

/* SVG icon defaults */
svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: block;
}

button { font-family: inherit; }

/* =========================
   SCREENS
========================= */

.screen { width: 100%; height: calc(var(--vh, 1vh) * 100); display: none; }
.screen.active { display: flex; }

/* =========================
   SPLASH
========================= */

.splash-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

.splash-logo-wrap {
  position: relative;
  width: 90px;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.splash-logo-wrap img {
  width: 80px; height: 80px;
  border-radius: 22px;
  position: relative;
  z-index: 1;
  animation: splashBounce 0.7s cubic-bezier(0.34,1.56,0.64,1) both;
}

.splash-ring {
  position: absolute;
  inset: -8px;
  border-radius: 30px;
  border: 2px solid var(--primary);
  animation: splashRing 1.8s ease infinite;
}
.splash-ring-2 { animation-delay: 0.6s; }

@keyframes splashBounce {
  0% { transform: scale(0.4); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes splashRing {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.5); opacity: 0; }
}

.splash-screen h1 {
  font-size: 30px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #ff6b81);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  animation: fadeUp 0.5s 0.15s ease both;
}
.splash-screen p { color: var(--text-light); animation: fadeUp 0.5s 0.25s ease both; }

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

.dot-anim { display: inline-block; animation: dotBlink 1.4s steps(4, end) infinite; width: 1.2em; overflow: hidden; }
@keyframes dotBlink {
  0% { width: 0; } 100% { width: 1.2em; }
}

/* =========================
   AUTH
========================= */

#auth-screen {
  justify-content: center; align-items: center;
  background: var(--bg);
  position: relative; overflow: hidden;
  padding: 16px;
}

.auth-bg-orbs { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.12; animation: orbFloat 9s ease-in-out infinite; }
.orb1 { width: 380px; height: 380px; background: var(--primary); top: -100px; left: -100px; }
.orb2 { width: 280px; height: 280px; background: #6c5ce7; bottom: -80px; right: -80px; animation-delay: -3s; }
.orb3 { width: 220px; height: 220px; background: var(--green); top: 50%; left: 60%; animation-delay: -5s; }

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(20px, -20px); }
  66% { transform: translate(-15px, 15px); }
}

.auth-card {
  width: 100%; max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  position: relative; z-index: 1;
  animation: cardIn 0.4s var(--bounce) both;
  max-height: calc(var(--vh, 1vh) * 100 - 32px);
  overflow-y: auto;
}

@keyframes cardIn {
  from { transform: translateY(24px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.auth-header { text-align: center; margin-bottom: 24px; }

.auth-logo-wrap {
  display: inline-flex; padding: 4px; border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), #ff6b81);
  margin-bottom: 14px;
  box-shadow: 0 8px 24px var(--primary-glow);
}
.auth-logo-wrap img { width: 60px; height: 60px; border-radius: 18px; display: block; }

.auth-header h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.auth-header p { color: var(--text-light); margin-top: 6px; font-size: 13px; }

.auth-tabs { display: flex; background: var(--bg); border-radius: 14px; margin-bottom: 22px; padding: 4px; gap: 4px; }

.tab {
  flex: 1; border: none; background: none; color: var(--text-light);
  padding: 11px; border-radius: 11px; cursor: pointer;
  font-weight: 600; font-size: 14px; transition: all var(--transition);
}
.tab.active { background: var(--primary); color: white; box-shadow: 0 4px 12px var(--primary-glow); }

.input-group { margin-bottom: 14px; }
.input-group label { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.6px; }

.input-wrap { position: relative; display: flex; align-items: center; }

.input-icon {
  position: absolute; left: 14px; width: 16px; height: 16px;
  color: var(--text-light); pointer-events: none; z-index: 1;
}

.input-wrap input {
  width: 100%; padding: 13px 14px 13px 42px;
  border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--bg); color: var(--text);
  font-size: 14px; font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-wrap input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-glow); }

.toggle-pw {
  position: absolute; right: 10px; background: none; border: none; cursor: pointer;
  color: var(--text-light); opacity: 0.7; transition: opacity var(--transition);
  padding: 6px; border-radius: 8px; display: flex; align-items: center;
}
.toggle-pw:hover { opacity: 1; }
.toggle-pw svg { width: 17px; height: 17px; }

.primary-btn {
  width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #ff6b81);
  color: white; cursor: pointer; font-weight: 700; font-size: 15px;
  letter-spacing: 0.3px; transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 6px 20px var(--primary-glow); margin-top: 6px;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 28px var(--primary-glow); }
.primary-btn:active { transform: scale(0.98); }
.primary-btn:disabled { opacity: 0.7; cursor: default; transform: none; }

.error-box {
  display: none; margin-bottom: 14px;
  background: rgba(255, 71, 87, 0.1); border: 1px solid rgba(255, 71, 87, 0.28);
  color: #ff7676; padding: 11px 14px; border-radius: 10px; font-size: 13px; line-height: 1.5;
}

.hidden { display: none !important; }

/* =========================
   APP LAYOUT
========================= */

#app-screen { display: flex; overflow: hidden; }

/* =========================
   ICON BUTTONS — universal
========================= */

.icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-light);
  padding: 8px 12px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13px; font-weight: 500; transition: all var(--transition);
  white-space: nowrap;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-glow); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 16px; height: 16px; }

.icon-btn-sm { padding: 8px; border-radius: 9px; }
.icon-btn-sm svg { width: 18px; height: 18px; }

.btn-label { display: inline; }

/* =========================
   SIDEBAR
========================= */

.sidebar {
  width: 340px; min-width: 340px; max-width: 340px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: background var(--transition);
}

.sidebar-top {
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; gap: 8px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; }
.brand h3 { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* =========================
   SEARCH
========================= */

.search-box { padding: 12px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }

.search-input-wrap { position: relative; display: flex; align-items: center; }

.search-icon, .search-icon-inline {
  position: absolute; left: 12px; width: 15px; height: 15px;
  color: var(--text-light); pointer-events: none;
}

.search-icon-inline { position: static; margin-right: 8px; flex-shrink: 0; }

.search-box input {
  width: 100%; padding: 10px 36px 10px 36px; border-radius: 12px;
  border: 1.5px solid transparent; background: var(--bg); color: var(--text);
  font-size: 13px; transition: border-color var(--transition); font-family: inherit;
}
.search-box input:focus { outline: none; border-color: var(--primary); }

.search-clear {
  position: absolute; right: 8px; background: none; border: none; cursor: pointer;
  color: var(--text-light); padding: 4px; border-radius: 6px; transition: color var(--transition);
  display: flex; align-items: center;
}
.search-clear:hover { color: var(--primary); }
.search-clear svg { width: 13px; height: 13px; }

.search-results { margin-top: 8px; max-height: 280px; overflow-y: auto; border-radius: 12px; }

.search-user { padding: 9px 10px; border-radius: 10px; transition: background var(--transition); animation: fadeSlideIn 0.2s ease both; }
.search-user:hover { background: rgba(255,255,255,0.04); }

.search-user-inner { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.search-user-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.search-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 16px; flex-shrink: 0;
}

.search-empty { padding: 20px; color: var(--text-light); font-size: 13px; text-align: center; }

.add-btn {
  background: var(--primary); border: none; border-radius: 8px; color: white;
  padding: 7px 13px; cursor: pointer; font-size: 12px; font-weight: 600;
  white-space: nowrap; transition: all var(--transition); flex-shrink: 0;
}
.add-btn:hover { background: var(--primary-dark); transform: scale(1.04); }
.add-btn:disabled { background: var(--text-muted); cursor: default; transform: none; }

.online-text { color: var(--green); }
.offline-text { color: var(--text-light); }

.req-actions { display: flex; gap: 6px; flex-shrink: 0; }

.accept-btn, .reject-btn {
  border: none; border-radius: 8px; padding: 7px 11px; cursor: pointer;
  font-weight: 700; transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.accept-btn { background: var(--green); color: white; }
.reject-btn { background: var(--border); color: var(--text-light); }
.accept-btn:hover { transform: scale(1.06); }
.reject-btn:hover { background: #444; }
.accept-btn svg, .reject-btn svg { width: 14px; height: 14px; }

/* =========================
   SECTION TITLES
========================= */

.section-title {
  padding: 10px 16px 5px; color: var(--text-light); font-size: 11px;
  text-transform: uppercase; letter-spacing: 1px; font-weight: 700;
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
}

.badge {
  background: var(--primary); color: white; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px; min-width: 20px; text-align: center;
}

/* =========================
   LISTS
========================= */

.request-list { max-height: 180px; overflow-y: auto; flex-shrink: 0; }
.chat-list { flex: 1; overflow-y: auto; min-height: 0; }

.chat-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  cursor: pointer; transition: background var(--transition); position: relative;
  animation: fadeSlideIn 0.25s ease both;
}
@keyframes fadeSlideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }

.chat-item:hover { background: rgba(255,255,255,0.04); }
.chat-item.active { background: rgba(255, 71, 87, 0.08); border-right: 3px solid var(--primary); }

.chat-avatar {
  width: 46px; height: 46px; border-radius: 50%; background: var(--primary);
  display: flex; justify-content: center; align-items: center;
  font-weight: 700; font-size: 18px; flex-shrink: 0; position: relative;
}

.chat-info { flex: 1; overflow: hidden; min-width: 0; }
.chat-info h4 { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; gap: 6px; }
.chat-preview { color: var(--text-light); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }

.chat-time-badge { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.chat-time { color: var(--text-muted); font-size: 11px; }

.online-dot {
  width: 10px; height: 10px; background: var(--green); border-radius: 50%;
  flex-shrink: 0; box-shadow: 0 0 6px var(--green); transition: opacity 0.3s, background 0.3s;
}

/* =========================
   PROFILE
========================= */

.profile-area {
  padding: 12px 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}

.profile-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0; box-shadow: 0 0 0 2px var(--primary-glow);
}

.profile-info { flex: 1; min-width: 0; }
.profile-info h4 { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-info span { font-size: 12px; }
.status-online { color: var(--green); }

/* =========================
   CHAT PANEL
========================= */

.chat-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; min-width: 0; }

.chat-header {
  height: 68px; min-height: 68px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 16px; flex-shrink: 0;
  background: var(--card); gap: 10px;
}

.chat-user { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.chat-user-info { min-width: 0; overflow: hidden; }
.chat-user-info h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-avatar-wrap { position: relative; flex-shrink: 0; }

.online-dot-sm {
  width: 10px; height: 10px; border-radius: 50%; background: var(--green);
  border: 2px solid var(--card); position: absolute; bottom: 1px; right: 1px;
  box-shadow: 0 0 5px var(--green); transition: background 0.3s;
}

.chat-header .chat-avatar { width: 42px; height: 42px; font-size: 16px; }

#chat-name { font-size: 15px; font-weight: 700; }
#chat-status { font-size: 12px; margin-top: 1px; display: block; color: var(--text-light); }

.chat-header-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Message search bar */
.msg-search-bar {
  padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center; flex-shrink: 0;
}
.msg-search-bar input {
  flex: 1; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); padding: 8px 12px;
  font-size: 13px; font-family: inherit;
}
.msg-search-bar input:focus { outline: none; border-color: var(--primary); }

/* =========================
   WELCOME
========================= */

.welcome-screen {
  flex: 1; display: flex; justify-content: center; align-items: center;
  flex-direction: column; text-align: center; gap: 14px; color: var(--text-light); padding: 20px;
}

.welcome-animation { position: relative; width: 100px; height: 100px; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.welcome-circles { position: absolute; inset: -20px; }

.wc { position: absolute; border-radius: 50%; border: 1.5px solid var(--primary); opacity: 0; animation: welcomePulse 3s ease-in-out infinite; }
.wc1 { inset: 0; animation-delay: 0s; }
.wc2 { inset: -10px; animation-delay: 1s; }
.wc3 { inset: -20px; animation-delay: 2s; }

@keyframes welcomePulse {
  0% { opacity: 0; transform: scale(0.8); }
  50% { opacity: 0.3; }
  100% { opacity: 0; transform: scale(1.2); }
}

.welcome-screen img { width: 72px; height: 72px; border-radius: 20px; position: relative; z-index: 1; }
.welcome-screen h2 { color: var(--text); font-size: 22px; font-weight: 800; }
.welcome-screen p { font-size: 14px; max-width: 280px; }

/* =========================
   CHAT CONTAINER
========================= */

.chat-container { display: flex; flex-direction: column; flex: 1; overflow: hidden; min-height: 0; position: relative; }

.load-more-wrap { display: flex; justify-content: center; padding: 12px; }
.load-more-btn {
  background: var(--card); border: 1px solid var(--border); color: var(--text-light);
  padding: 8px 20px; border-radius: 20px; cursor: pointer; font-size: 12px;
  font-family: inherit; transition: all var(--transition);
}
.load-more-btn:hover { border-color: var(--primary); color: var(--primary); }

/* =========================
   MESSAGES
========================= */

.messages {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 4px;
  overscroll-behavior: contain;
  contain: layout style;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.date-separator {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  color: var(--text-muted); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.date-separator::before, .date-separator::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Message wrapper — GPU-promoted, animates from correct corner */
.message-wrap {
  display: flex; flex-direction: column; max-width: 70%; position: relative;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.message-wrap.sent {
  align-self: flex-end; align-items: flex-end;
  transform-origin: bottom right;
  animation: msgInSent var(--bounce) both;
}

.message-wrap.received {
  align-self: flex-start; align-items: flex-start;
  transform-origin: bottom left;
  animation: msgInReceived var(--bounce) both;
}

@keyframes msgInSent {
  0%   { opacity: 0; transform: translateY(10px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes msgInReceived {
  0%   { opacity: 0; transform: translateY(10px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.reply-context {
  background: rgba(255,255,255,0.07); border-left: 3px solid var(--primary);
  border-radius: 6px; padding: 6px 10px; margin-bottom: 4px; font-size: 12px;
  color: var(--text-light); max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; cursor: pointer;
}

.message {
  padding: 10px 14px; border-radius: 18px; word-wrap: break-word;
  overflow-wrap: break-word; line-height: 1.5; font-size: 14px;
  position: relative; cursor: pointer; user-select: text;
  transition: filter 0.15s; max-width: 100%;
}
.message:hover { filter: brightness(1.08); }

.message.msg-highlight { animation: highlightFlash 1.5s ease forwards; }
@keyframes highlightFlash {
  0%, 70% { box-shadow: 0 0 0 2px var(--primary); }
  100% { box-shadow: none; }
}

.message-wrap.msg-search-match .message { outline: 2px solid var(--primary); outline-offset: 2px; }

.message-wrap.received .message { background: var(--message-bg); border-bottom-left-radius: 4px; }
.message-wrap.sent .message { background: var(--message-own); color: var(--text); border-bottom-right-radius: 4px; }

/* Telegram-style: media messages get zero padding, timestamp overlays the image */
.message:has(.msg-image),
.message:has(.msg-gif),
.message.has-media {
  padding: 3px;
}

.message:has(.msg-image) .msg-time,
.message:has(.msg-gif) .msg-time,
.message.has-media .msg-time {
  position: absolute;
  bottom: 8px;
  right: 10px;
  background: rgba(0,0,0,0.45);
  color: #fff;
  padding: 2px 7px;
  border-radius: 10px;
  opacity: 1;
  backdrop-filter: blur(2px);
}

.message:has(.msg-image) .msg-time .msg-tick.read,
.message:has(.msg-gif) .msg-time .msg-tick.read,
.message.has-media .msg-time .msg-tick.read {
  color: #4fc3f7;
}

/* Media messages */
.msg-image {
  max-width: min(260px, 60vw); max-height: 320px; border-radius: 14px;
  object-fit: cover; cursor: pointer; display: block; transition: transform var(--transition);
}
.msg-image:hover { transform: scale(1.02); }

.msg-video { max-width: min(280px, 65vw); border-radius: 14px; display: block; }

.msg-file {
  display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.06);
  border-radius: 12px; padding: 12px 14px; min-width: 180px; max-width: 260px;
  cursor: pointer; text-decoration: none; color: var(--text); transition: background var(--transition);
}
.msg-file:hover { background: rgba(255,255,255,0.1); }
.msg-file-icon { flex-shrink: 0; width: 30px; height: 30px; color: var(--primary); display: flex; align-items: center; justify-content: center; }
.msg-file-icon svg { width: 26px; height: 26px; }
.msg-file-info { overflow: hidden; min-width: 0; }
.msg-file-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.msg-file-size { font-size: 11px; color: var(--text-light); margin-top: 2px; }

.msg-gif { max-width: min(260px, 60vw); border-radius: 14px; display: block; cursor: pointer; }

/* Timestamps */
.msg-time { display: block; margin-top: 4px; opacity: 0.55; font-size: 11px; padding: 0 4px; display: flex; align-items: center; gap: 4px; }
.msg-tick { display: flex; align-items: center; }
.msg-tick svg { width: 13px; height: 13px; }
.msg-tick.read { color: #4fc3f7; opacity: 1; }

/* Reactions */
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.msg-reaction {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 2px 7px; font-size: 13px; cursor: pointer; transition: all var(--transition);
  display: flex; align-items: center; gap: 3px;
}
.msg-reaction:hover { border-color: var(--primary); transform: scale(1.1); }
.msg-reaction span { font-size: 11px; color: var(--text-light); }

/* Upload progress */
.upload-progress-wrap { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; min-width: 180px; max-width: 240px; }
.upload-progress-header { display: flex; align-items: center; gap: 8px; }
.upload-progress-header svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--primary); }
.upload-progress-bar { height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; }
.upload-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--primary), #ff6b81);
  border-radius: 4px; transition: width 0.25s ease; width: 0%;
}
.upload-label { font-size: 12px; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* =========================
   TYPING INDICATOR
========================= */

.typing-indicator { padding: 6px 20px 4px; display: flex; align-items: center; gap: 8px; color: var(--text-light); font-size: 12px; flex-shrink: 0; }
.typing-dots { display: flex; gap: 4px; align-items: center; }
.typing-dots span { width: 6px; height: 6px; background: var(--text-light); border-radius: 50%; animation: typingDot 1.4s ease infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* =========================
   REPLY PREVIEW
========================= */

.reply-preview {
  display: grid;
  grid-template-rows: 1fr;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
  transition: grid-template-rows 0.18s ease, padding 0.18s ease, opacity 0.18s ease;
}

.reply-preview.collapsed {
  display: grid; /* override global .hidden so transition can run */
  grid-template-rows: 0fr;
  padding-top: 0; padding-bottom: 0;
  border-top-color: transparent;
  opacity: 0;
  pointer-events: none;
}

.reply-preview > * { min-height: 0; overflow: hidden; }
.reply-preview-row { display: flex; align-items: center; gap: 10px; min-width: 0; }

.reply-bar { width: 3px; height: 36px; background: var(--primary); border-radius: 4px; flex-shrink: 0; }
.reply-content { flex: 1; overflow: hidden; min-width: 0; }
.reply-label { font-size: 11px; color: var(--primary); font-weight: 600; display: block; margin-bottom: 2px; }
#reply-text { font-size: 13px; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* =========================
   ATTACHMENT PREVIEW (before send)
========================= */

.attach-preview {
  display: grid;
  grid-template-rows: 1fr;
  padding: 10px 14px;
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
  transition: grid-template-rows 0.18s ease, padding 0.18s ease, opacity 0.18s ease;
}

.attach-preview.collapsed {
  display: grid;
  grid-template-rows: 0fr;
  padding-top: 0; padding-bottom: 0;
  border-top-color: transparent;
  opacity: 0;
  pointer-events: none;
}

.attach-preview > * { min-height: 0; overflow: hidden; }
.attach-preview-inner { display: flex; align-items: center; gap: 12px; }

.attach-thumb {
  width: 52px; height: 52px; border-radius: 10px; flex-shrink: 0;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  overflow: hidden; color: var(--primary); border: 1px solid var(--border);
}
.attach-thumb img, .attach-thumb video { width: 100%; height: 100%; object-fit: cover; }
.attach-thumb svg { width: 26px; height: 26px; }

.attach-info { flex: 1; min-width: 0; }
.attach-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-size { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* =========================
   MESSAGE INPUT
========================= */

.message-input {
  display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px;
  border-top: 1px solid var(--border); flex-shrink: 0; background: var(--card);
}

.input-action-btn {
  background: none; border: none; cursor: pointer; padding: 9px; border-radius: 11px;
  transition: all var(--transition); color: var(--text-light); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.input-action-btn:hover { background: rgba(255,255,255,0.06); color: var(--primary); transform: scale(1.08); }
.input-action-btn:active { transform: scale(0.92); }
.input-action-btn svg { width: 22px; height: 22px; }

.gif-action-btn.active, .input-action-btn.active { color: var(--primary); background: var(--primary-glow); }

.textarea-wrap { flex: 1; position: relative; min-width: 0; }

.message-input textarea {
  width: 100%; resize: none; min-height: 42px; max-height: 120px;
  border: 1.5px solid var(--border); border-radius: 14px; background: var(--bg);
  color: var(--text); padding: 11px 14px; font-size: 14px; font-family: inherit;
  transition: border-color var(--transition); line-height: 1.45;
  overflow-y: auto; display: block;
}
.message-input textarea:focus { outline: none; border-color: var(--primary); }
.message-input textarea::-webkit-scrollbar { width: 3px; }
.message-input textarea::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.send-btn {
  width: 44px; height: 44px; border: none; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #ff6b81); color: white;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s var(--bounce), box-shadow 0.15s ease;
  flex-shrink: 0; box-shadow: 0 4px 14px var(--primary-glow); position: relative; overflow: hidden;
}
.send-btn svg { width: 19px; height: 19px; position: relative; z-index: 1; }
.send-btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px var(--primary-glow); }
.send-btn:active { transform: scale(0.9); }
.send-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.send-btn::after {
  content: ''; position: absolute; inset: 0; border-radius: 14px; background: white;
  opacity: 0; transform: scale(0); transition: transform 0.35s ease, opacity 0.35s ease;
}
.send-btn:active::after { transform: scale(2.5); opacity: 0.18; transition: 0s; }

/* "Sent" pulse animation triggered via JS */
.send-btn.pulse { animation: sendPulse 0.35s ease; }
@keyframes sendPulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.82) rotate(-8deg); }
  70%  { transform: scale(1.12) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}

/* =========================
   EMOJI PICKER
========================= */

.emoji-picker {
  position: fixed; width: 340px; height: 360px; max-height: 60vh;
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); z-index: 1000; display: flex; flex-direction: column;
  overflow: hidden; animation: popIn 0.2s var(--bounce);
}

@keyframes popIn {
  from { transform: scale(0.9) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.emoji-picker-header { padding: 10px; border-bottom: 1px solid var(--border); }
.emoji-cats { display: flex; gap: 2px; margin-bottom: 8px; }
.emoji-cat {
  flex: 1; background: none; border: none; font-size: 17px; padding: 7px;
  border-radius: 8px; cursor: pointer; transition: background var(--transition);
  line-height: 1; color: var(--text-light);
}
.emoji-cat svg { width: 17px; height: 17px; margin: 0 auto; }
.emoji-cat:hover { background: rgba(255,255,255,0.07); }
.emoji-cat.active { background: var(--primary-glow); color: var(--primary); }

.emoji-search-wrap { display: flex; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; }
.emoji-search-wrap:focus-within { border-color: var(--primary); }
.emoji-search-wrap svg { width: 14px; height: 14px; color: var(--text-light); }
.emoji-search-input {
  width: 100%; padding: 8px 8px; border: none; background: transparent;
  color: var(--text); font-size: 13px; font-family: inherit;
}
.emoji-search-input:focus { outline: none; }

.emoji-grid {
  flex: 1; overflow-y: auto; padding: 8px; display: grid;
  grid-template-columns: repeat(8, 1fr); gap: 2px; align-content: start;
}
.emoji-grid::-webkit-scrollbar { width: 3px; }
.emoji-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.emoji-btn-item {
  background: none; border: none; font-size: 22px; width: 36px; height: 36px;
  border-radius: 8px; cursor: pointer; transition: all 0.12s var(--bounce);
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.emoji-btn-item:hover { background: rgba(255,255,255,0.08); transform: scale(1.25); }

.emoji-section-label {
  grid-column: 1 / -1; font-size: 11px; font-weight: 700; color: var(--text-light);
  padding: 4px 2px; text-transform: uppercase; letter-spacing: 0.5px;
}

/* =========================
   GIF PICKER
========================= */

.gif-picker {
  position: fixed; width: 360px; height: 400px; max-height: 65vh;
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); z-index: 1000; display: flex; flex-direction: column;
  overflow: hidden; animation: popIn 0.2s var(--bounce);
}

.gif-header { padding: 10px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; background: var(--bg); border-radius: 10px; margin: 8px; }
.gif-header svg { width: 15px; height: 15px; color: var(--text-light); flex-shrink: 0; }
.gif-search-input { flex: 1; padding: 8px 0; border: none; background: transparent; color: var(--text); font-size: 13px; font-family: inherit; }
.gif-search-input:focus { outline: none; }

.gif-grid {
  flex: 1; overflow-y: auto; padding: 0 8px 8px; display: grid;
  grid-template-columns: repeat(2, 1fr); gap: 6px; align-content: start;
}
.gif-grid::-webkit-scrollbar { width: 3px; }
.gif-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.gif-placeholder, .gif-loading {
  grid-column: 1 / -1; color: var(--text-light); font-size: 13px; text-align: center; padding: 40px 12px; line-height: 1.6;
}

.gif-item { border-radius: 10px; overflow: hidden; cursor: pointer; transition: transform var(--transition); aspect-ratio: 16/9; background: var(--bg); }
.gif-item:hover { transform: scale(1.03); }
.gif-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

.gif-footer {
  text-align: center; font-size: 10px; color: var(--text-muted);
  padding: 6px; border-top: 1px solid var(--border); letter-spacing: 1px; text-transform: uppercase;
}

/* =========================
   CONTEXT MENU
========================= */

.context-menu {
  position: fixed; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 2000;
  min-width: 170px; animation: popIn 0.15s var(--bounce);
}
.context-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; color: var(--text); padding: 9px 12px;
  border-radius: 8px; font-size: 13px; font-family: inherit; cursor: pointer; transition: background var(--transition);
}
.context-menu button svg { width: 16px; height: 16px; flex-shrink: 0; }
.context-menu button:hover { background: rgba(255,255,255,0.06); }
.context-menu button.danger { color: var(--primary); }
.context-menu button.danger:hover { background: var(--primary-glow); }

/* =========================
   REACTION POPUP
========================= */

.reaction-popup {
  position: fixed; background: var(--card); border: 1px solid var(--border);
  border-radius: 30px; box-shadow: var(--shadow); padding: 6px 10px; z-index: 2100;
  display: flex; gap: 4px; animation: popIn 0.15s var(--bounce);
}
.reaction-btn { background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px; border-radius: 50%; transition: all 0.15s var(--bounce); line-height: 1; }
.reaction-btn:hover { transform: scale(1.35) translateY(-2px); }

/* =========================
   LIGHTBOX
========================= */

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 9000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; animation: fadeIn 0.2s ease; backdrop-filter: blur(8px); padding: 16px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.lightbox-close {
  position: absolute; top: 16px; right: 16px; background: rgba(255,255,255,0.1);
  border: none; color: white; width: 40px; height: 40px; border-radius: 50%;
  cursor: pointer; transition: background var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); }

#lightbox-img { max-width: 90vw; max-height: 78vh; border-radius: 12px; object-fit: contain; animation: popIn 0.25s var(--bounce); }

.lightbox-download {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: white;
  padding: 9px 22px; border-radius: 20px; text-decoration: none; font-size: 13px;
  transition: background var(--transition); display: flex; align-items: center; gap: 8px;
}
.lightbox-download svg { width: 15px; height: 15px; }
.lightbox-download:hover { background: rgba(255,255,255,0.18); }

/* =========================
   CALL MODAL
========================= */

.call-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 8000;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(12px); animation: fadeIn 0.3s ease; padding: 16px;
}
.call-modal-inner {
  background: var(--card); border: 1px solid var(--border); border-radius: 24px;
  padding: 36px 32px; text-align: center; box-shadow: var(--shadow);
  animation: popIn 0.3s var(--bounce); max-width: 320px; width: 100%;
}

.call-ring-wrap { position: relative; display: inline-flex; margin-bottom: 16px; }
.call-avatar {
  width: 80px; height: 80px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 32px;
  font-weight: 700; position: relative; z-index: 1;
}
.call-ring-wrap::before, .call-ring-wrap::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--primary); animation: callRing 1.8s ease-out infinite;
}
.call-ring-wrap::after { animation-delay: 0.6s; }
@keyframes callRing {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.8); opacity: 0; }
}

.call-modal-inner h3 { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
#call-status-text { color: var(--text-light); font-size: 14px; margin-bottom: 28px; }
.call-actions { display: flex; justify-content: center; gap: 16px; }

.call-btn {
  width: 60px; height: 60px; border: none; border-radius: 50%; cursor: pointer;
  transition: all var(--transition); display: flex; align-items: center; justify-content: center; color: white;
}
.call-btn svg { width: 24px; height: 24px; }
.call-end { background: var(--primary); }
.call-end:hover { transform: scale(1.1); }

/* =========================
   DRAG & DROP OVERLAY
========================= */

.drop-overlay {
  position: absolute; inset: 0; background: rgba(13,17,23,0.85);
  backdrop-filter: blur(4px); z-index: 50; display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--primary); border-radius: 12px; margin: 8px; animation: fadeIn 0.15s ease;
  pointer-events: none;
}
.drop-overlay-inner { text-align: center; color: var(--primary); }
.drop-overlay-inner svg { width: 48px; height: 48px; margin: 0 auto 10px; }
.drop-overlay-inner p { font-size: 15px; font-weight: 700; }

/* =========================
   TOAST
========================= */

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 11px 22px; border-radius: 30px; opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s; font-size: 13px; font-weight: 500;
  white-space: nowrap; z-index: 9999; box-shadow: var(--shadow-sm);
  max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =========================
   SCROLLBARS
========================= */

.chat-list::-webkit-scrollbar, .request-list::-webkit-scrollbar, .search-results::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-thumb, .request-list::-webkit-scrollbar-thumb, .search-results::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* =========================
   MOBILE BACK BUTTON
========================= */

.mobile-back-btn {
  background: transparent; border: none; color: var(--text-light); cursor: pointer;
  padding: 6px; border-radius: 8px; transition: color var(--transition);
  display: none; align-items: center; justify-content: center; flex-shrink: 0;
}
.mobile-back-btn:hover { color: var(--text); }
.mobile-back-btn svg { width: 22px; height: 22px; }

/* =========================================================
   RESPONSIVE — TABLET
========================================================= */

@media (max-width: 1024px) {
  .sidebar { width: 300px; min-width: 300px; max-width: 300px; }
}

/* =========================================================
   RESPONSIVE — MOBILE
========================================================= */

@media (max-width: 768px) {
  .sidebar { width: 100%; min-width: 100%; max-width: 100%; }
  .chat-panel { display: none; }

  .chat-panel.mobile-open {
    display: flex; position: fixed; inset: 0; z-index: 1000; background: var(--bg);
    height: calc(var(--vh, 1vh) * 100);
  }

  .mobile-back-btn { display: flex; }
  .message-wrap { max-width: 85%; }

  /* Smaller icons on mobile to reduce clutter */
  .icon-btn .btn-label { display: none; }
  .icon-btn { padding: 9px; }

  /* Floating pickers become bottom sheets on mobile */
  .emoji-picker, .gif-picker {
    left: 0 !important; right: 0; bottom: 0 !important; top: auto !important;
    width: 100% !important; max-width: 100%;
    border-radius: 18px 18px 0 0; height: 50vh; max-height: 50vh;
    animation: sheetUp 0.25s var(--bounce);
  }

  @keyframes sheetUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  .chat-header { padding: 0 10px; height: 60px; min-height: 60px; }
  .chat-header .chat-avatar { width: 38px; height: 38px; font-size: 14px; }
  #chat-name { font-size: 14px; }
  #chat-status { font-size: 11px; }

  .messages { padding: 12px 12px; }
  .message-input { padding: 8px; gap: 4px; }
  .input-action-btn { padding: 7px; }
  .input-action-btn svg { width: 20px; height: 20px; }
  .send-btn { width: 40px; height: 40px; }

  .msg-image, .msg-gif { max-width: 70vw; }
  .msg-video { max-width: 75vw; }

  .auth-card { padding: 24px 20px; border-radius: 20px; }
}

@media (max-width: 380px) {
  .sidebar-top { padding: 12px 14px; }
  .brand h3 { font-size: 14px; }
  .search-box { padding: 10px 12px; }
  .profile-area { padding: 10px 12px; }
}

/* Landscape mobile — shrink vertical paddings */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  .chat-header { height: 52px; min-height: 52px; }
  .message-input { padding: 6px 10px; }
  .auth-card { padding: 18px; max-height: 92vh; }
}
