/* ============ VARIABLES ============ */
:root {
  --primary: #6c5ce7;
  --primary-light: #a29bfe;
  --primary-dark: #5a4bd1;
  --accent: #00cec9;
  --accent-glow: rgba(0, 206, 201, 0.4);
  --neon-blue: #0984e3;
  --neon-purple: #6c5ce7;
  --neon-pink: #fd79a8;
  --neon-green: #00b894;

  --bg-deep: #0a0a1a;
  --bg-main: #0f0f23;
  --bg-card: #161631;
  --bg-card-hover: #1c1c3d;
  --bg-input: #1a1a3e;
  --bg-glass: rgba(22, 22, 49, 0.7);
  --bg-glass-light: rgba(108, 92, 231, 0.08);

  --bg-message-out: linear-gradient(135deg, #6c5ce7, #a29bfe);
  --bg-message-in: linear-gradient(135deg, #1c1c3d, #252550);

  --text: #e8e8ff;
  --text-secondary: #9595c8;
  --text-muted: #5e5e8a;

  --border: rgba(108, 92, 231, 0.2);
  --border-glow: rgba(108, 92, 231, 0.5);

  --green: #00b894;
  --red: #ff6b6b;
  --yellow: #ffeaa7;
  --orange: #fdcb6e;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(108, 92, 231, 0.15);
  --shadow-glow-strong: 0 0 60px rgba(108, 92, 231, 0.25);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --radius-full: 9999px;

  --sidebar-width: 380px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ LIGHT THEME ============ */
[data-theme="light"] {
  --bg-deep: #f0f2f5;
  --bg-main: #ffffff;
  --bg-card: #f7f8fc;
  --bg-card-hover: #eef0f7;
  --bg-input: #f0f2f5;
  --bg-glass: rgba(255, 255, 255, 0.85);
  --bg-glass-light: rgba(108, 92, 231, 0.06);

  --text: #1a1a2e;
  --text-secondary: #5e5e7e;
  --text-muted: #9595b5;

  --border: rgba(108, 92, 231, 0.15);
  --border-glow: rgba(108, 92, 231, 0.35);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 30px rgba(108, 92, 231, 0.08);
  --shadow-glow-strong: 0 0 60px rgba(108, 92, 231, 0.12);
}

[data-theme="light"] .ambient-orb { opacity: 0.12; }
[data-theme="light"] .ambient-orb:nth-child(1) { background: radial-gradient(circle, #a29bfe, transparent); }
[data-theme="light"] .ambient-orb:nth-child(2) { background: radial-gradient(circle, #74b9ff, transparent); }
[data-theme="light"] .ambient-orb:nth-child(3) { background: radial-gradient(circle, #fd79a8, transparent); }
[data-theme="light"] .ambient-orb:nth-child(4) { background: radial-gradient(circle, #55efc4, transparent); }

[data-theme="light"] .input-group input {
  background: #f0f2f5;
  border: 1px solid #e0e3eb;
}

[data-theme="light"] .message.sent {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: white;
  box-shadow: 0 2px 10px rgba(108, 92, 231, 0.2);
}

[data-theme="light"] .message.received {
  background: #f0f2f5;
  border: 1px solid #e0e3eb;
  color: #1a1a2e;
}

[data-theme="light"] .call-overlay {
  background: linear-gradient(135deg, rgba(240, 242, 245, 0.95), rgba(255, 255, 255, 0.98));
}

[data-theme="light"] .call-avatar::before { border-color: var(--primary-light); }
[data-theme="light"] .call-name { color: #1a1a2e; }
[data-theme="light"] .call-status { color: #5e5e7e; }

/* ============ THEME TOGGLE BUTTON ============ */
.theme-toggle {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.theme-toggle::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent);
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--transition);
}

.theme-toggle:hover {
  background: var(--bg-card-hover);
  color: var(--primary-light);
  border-color: var(--border-glow);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.2), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle:hover::before { opacity: 1; }

.theme-toggle:active {
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }

[data-theme="light"] .theme-toggle .icon-sun { display: inline; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Smooth theme transition */
body, .sidebar, .chat-area, .auth-container,
.input-group input, .message, .chat-header,
.message-input-area, .chat-item, .icon-btn,
.theme-toggle, .btn-primary, .send-btn {
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

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

body {
  font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ============ AMBIENT BACKGROUND ============ */
.ambient-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: float 20s infinite ease-in-out;
  opacity: 0.3;
}

.ambient-orb:nth-child(1) {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #6c5ce7, transparent);
  top: -10%;
  left: -5%;
  animation-delay: 0s;
  animation-duration: 25s;
}

.ambient-orb:nth-child(2) {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, #0984e3, transparent);
  bottom: -10%;
  right: -5%;
  animation-delay: -5s;
  animation-duration: 30s;
}

.ambient-orb:nth-child(3) {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #fd79a8, transparent);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -10s;
  animation-duration: 22s;
}

.ambient-orb:nth-child(4) {
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, #00cec9, transparent);
  top: 20%;
  right: 20%;
  animation-delay: -7s;
  animation-duration: 28s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(60px, -40px) scale(1.1); }
  50% { transform: translate(-30px, 50px) scale(0.95); }
  75% { transform: translate(40px, 20px) scale(1.05); }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--primary), var(--neon-blue));
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--primary-light), var(--accent));
}

/* ============ AUTH SCREEN ============ */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  position: relative;
  z-index: 1;
}

.auth-container {
  background: var(--bg-glass);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
  width: 440px;
  max-width: 95vw;
  box-shadow: var(--shadow-lg), var(--shadow-glow-strong);
  position: relative;
  overflow: hidden;
}

.auth-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), var(--accent), var(--neon-pink), transparent);
}

.auth-logo {
  text-align: center;
  margin-bottom: 36px;
}

.auth-logo .logo-icon {
  width: 90px;
  height: 90px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  font-size: 40px;
  color: white;
  box-shadow:
    0 0 30px rgba(108, 92, 231, 0.4),
    0 0 60px rgba(108, 92, 231, 0.2),
    inset 0 -2px 6px rgba(0, 0, 0, 0.2);
  animation: logoPulse 3s infinite ease-in-out;
}

@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 30px rgba(108, 92, 231, 0.4), 0 0 60px rgba(108, 92, 231, 0.2); }
  50% { box-shadow: 0 0 40px rgba(108, 92, 231, 0.6), 0 0 80px rgba(108, 92, 231, 0.3); }
}

.auth-logo h1 {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.auth-logo p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.auth-form h2 {
  font-size: 22px;
  margin-bottom: 24px;
  text-align: center;
  color: var(--text);
}

/* ============ 3D INPUT FIELDS ============ */
.input-group {
  position: relative;
  margin-bottom: 18px;
}

.input-group i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  transition: color var(--transition);
  z-index: 2;
}

.input-group input {
  width: 100%;
  padding: 16px 16px 16px 48px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  transition: all var(--transition);
  outline: none;
  position: relative;
  z-index: 1;
}

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15), var(--shadow-glow);
}

.input-group input:focus + i,
.input-group input:focus ~ i {
  color: var(--primary-light);
}

/* ============ 3D BUTTONS ============ */
.btn-3d {
  position: relative;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  overflow: hidden;
  text-transform: none;
  letter-spacing: 0.3px;
}

.btn-3d::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: inherit;
  transition: opacity var(--transition);
  opacity: 0;
}

.btn-3d:hover::before {
  opacity: 1;
}

.btn-primary {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary), var(--neon-blue));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
  position: relative;
  transition: all var(--transition);
  box-shadow:
    0 4px 15px rgba(108, 92, 231, 0.4),
    0 1px 3px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 25px rgba(108, 92, 231, 0.5),
    0 4px 10px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow:
    0 2px 8px rgba(108, 92, 231, 0.3),
    inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-primary::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.08) 50%,
    transparent 70%
  );
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.btn-primary:hover::after {
  transform: translateX(100%);
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.auth-switch a {
  color: var(--primary-light);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition);
}

.auth-switch a:hover {
  color: var(--accent);
}

.error-message {
  color: var(--red);
  text-align: center;
  margin-top: 12px;
  font-size: 14px;
  min-height: 20px;
}

/* ============ CHAT SCREEN LAYOUT ============ */
.chat-screen {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  min-height: 64px;
  background: rgba(15, 15, 35, 0.5);
}

.current-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 16px;
}

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

/* ============ 3D ICON BUTTONS ============ */
.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  color: var(--primary-light);
  border-color: var(--border-glow);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.2), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.icon-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.icon-btn-sm {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition);
}

.icon-btn-sm:hover { color: var(--text); }

/* ============ AVATAR ============ */
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.avatar::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  z-index: -1;
  opacity: 0;
  transition: opacity var(--transition);
}

.avatar:hover::after {
  opacity: 0.5;
}

/* ============ SEARCH ============ */
.search-panel {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  gap: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.search-input-wrapper i { color: var(--text-muted); font-size: 14px; }

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

.search-results {
  max-height: 300px;
  overflow-y: auto;
}

/* ============ FRIEND REQUESTS ============ */
.friend-requests-section {
  border-bottom: 1px solid var(--border);
  background: rgba(108, 92, 231, 0.03);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 8px;
}

.section-header h4 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  font-weight: 600;
}

.badge {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.friend-request-item {
  display: flex;
  align-items: center;
  padding: 10px 18px;
  gap: 12px;
  transition: background var(--transition);
}

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

.friend-request-info { flex: 1; }
.friend-request-info .name { font-weight: 700; font-size: 15px; }
.friend-request-info .time { font-size: 12px; color: var(--text-muted); }

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

.btn-accept, .btn-reject {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-accept {
  background: linear-gradient(135deg, var(--green), #00d2a0);
  color: white;
}
.btn-accept:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 184, 148, 0.4); }
.btn-reject { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-reject:hover { background: var(--red); color: white; transform: translateY(-1px); }

/* ============ CHAT LIST ============ */
.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}

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

.chat-item.active {
  background: var(--bg-glass-light);
  border-left-color: var(--primary);
}

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

.chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.chat-item-name {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

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

.online-dot {
  width: 13px;
  height: 13px;
  background: var(--green);
  border: 2px solid var(--bg-card);
  border-radius: 50%;
  position: absolute;
  bottom: 0;
  right: 0;
  box-shadow: 0 0 8px rgba(0, 184, 148, 0.5);
}

/* ============ SEARCH RESULT ITEM ============ */
.search-result-item {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  gap: 12px;
  cursor: pointer;
  transition: background var(--transition);
}

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

.search-result-info { flex: 1; }
.search-result-info .name { font-weight: 700; font-size: 15px; }
.search-result-info .email { font-size: 12px; color: var(--text-muted); }

.btn-add-friend {
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--primary), var(--neon-blue));
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(108, 92, 231, 0.3);
}

.btn-add-friend:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.btn-add-friend:disabled {
  background: var(--text-muted);
  box-shadow: none;
  cursor: default;
  transform: none;
}

.btn-message-friend {
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--accent), var(--neon-green));
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 10px rgba(0, 206, 201, 0.3);
}

.btn-message-friend:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(0, 206, 201, 0.4);
}

/* ============ CHAT AREA ============ */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  position: relative;
  z-index: 1;
}

.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.empty-icon {
  width: 130px;
  height: 130px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 55px;
  color: white;
  margin-bottom: 10px;
  box-shadow:
    0 0 40px rgba(108, 92, 231, 0.3),
    0 0 80px rgba(108, 92, 231, 0.15);
  animation: emptyPulse 3s infinite ease-in-out;
}

@keyframes emptyPulse {
  0%, 100% { box-shadow: 0 0 40px rgba(108, 92, 231, 0.3), 0 0 80px rgba(108, 92, 231, 0.15); }
  50% { box-shadow: 0 0 60px rgba(108, 92, 231, 0.5), 0 0 100px rgba(108, 92, 231, 0.25); }
}

.encryption-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--accent);
  font-size: 13px;
  margin-top: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* ============ CHAT HEADER ============ */
.chat-header {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  min-height: 64px;
  gap: 12px;
}

.mobile-back { display: none; }

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.chat-user-info h3 { font-size: 16px; font-weight: 700; }

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

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

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

/* ============ 3D CALL BUTTONS ============ */
.btn-call {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: white;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.btn-call::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  border-radius: inherit;
}

.btn-call:hover {
  transform: translateY(-2px) scale(1.05);
}

.btn-call:active {
  transform: translateY(1px) scale(0.95);
}

.btn-call-audio {
  background: linear-gradient(135deg, var(--green), #00d2a0);
  box-shadow: 0 4px 15px rgba(0, 184, 148, 0.4);
}

.btn-call-audio:hover {
  box-shadow: 0 6px 20px rgba(0, 184, 148, 0.5);
}

.btn-call-video {
  background: linear-gradient(135deg, var(--neon-blue), var(--primary));
  box-shadow: 0 4px 15px rgba(9, 132, 227, 0.4);
}

.btn-call-video:hover {
  box-shadow: 0 6px 20px rgba(9, 132, 227, 0.5);
}

/* ============ ENCRYPTION PANEL ============ */
.encryption-panel {
  padding: 12px 18px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.encryption-badge {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  background: rgba(0, 184, 148, 0.05);
  border: 1px solid rgba(0, 184, 148, 0.15);
  border-radius: var(--radius-sm);
}

.encryption-badge i {
  font-size: 28px;
  color: var(--accent);
  margin-top: 2px;
}

.encryption-badge strong {
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
}

.encryption-badge p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.encryption-badge small {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============ MESSAGES ============ */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(0, 206, 201, 0.04) 0%, transparent 50%);
}

.message-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 60%;
  margin-bottom: 6px;
  animation: msgIn 0.3s ease-out;
}

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

.message-wrapper.sent {
  align-self: flex-end;
  align-items: flex-end;
}

.message-wrapper.received {
  align-self: flex-start;
  align-items: flex-start;
}

.message {
  padding: 10px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
  transition: all var(--transition);
}

.message.sent {
  background: linear-gradient(135deg, var(--primary), var(--neon-blue));
  color: white;
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 10px rgba(108, 92, 231, 0.3);
}

.message.received {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.message:hover {
  transform: scale(1.01);
}

.message-text {
  margin-bottom: 4px;
}

.message-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xs);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background var(--transition);
}

.message-file:hover { background: rgba(255, 255, 255, 0.12); }
.message-file i { font-size: 28px; color: var(--primary-light); }

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

.message-file-info .filename {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}

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

.message.sent .message-time {
  color: rgba(255, 255, 255, 0.6);
}

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

.message-check.read {
  color: var(--accent);
}

/* ============ MESSAGE CONTEXT MENU ============ */
.message-wrapper {
  position: relative;
}

.msg-actions {
  display: none;
  position: absolute;
  top: 0;
  gap: 4px;
  z-index: 10;
}

.message-wrapper.sent .msg-actions {
  left: -60px;
}

.message-wrapper.received .msg-actions {
  right: -60px;
}

.message-wrapper:hover .msg-actions {
  display: flex;
}

.msg-action-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all var(--transition);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.msg-action-btn:hover {
  background: var(--red);
  color: white;
  border-color: var(--red);
  transform: scale(1.1);
}

/* ============ DELETE COUNTDOWN ============ */
.delete-countdown {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.2);
  border-radius: var(--radius-xs);
  margin-top: 6px;
  font-size: 12px;
  color: var(--red);
  animation: countdownPulse 1s infinite ease-in-out;
}

@keyframes countdownPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.delete-countdown .countdown-bar {
  width: 40px;
  height: 3px;
  background: rgba(255, 107, 107, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.delete-countdown .countdown-bar-fill {
  height: 100%;
  background: var(--red);
  border-radius: 2px;
  transition: width 1s linear;
}

/* ============ DATE DIVIDER ============ */
.date-divider {
  text-align: center;
  padding: 12px 0;
}

.date-divider span {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 5px 16px;
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ============ TYPING INDICATOR ============ */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 18px 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.typing-indicator span:nth-child(1),
.typing-indicator span:nth-child(2),
.typing-indicator span:nth-child(3) {
  width: 7px;
  height: 7px;
  background: var(--primary);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

/* ============ MESSAGE INPUT ============ */
.message-input-area {
  display: flex;
  align-items: flex-end;
  padding: 14px 18px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  gap: 12px;
}

.input-wrapper {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 4px 18px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.12);
}

.input-wrapper textarea {
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  resize: none;
  outline: none;
  max-height: 120px;
  padding: 10px 0;
  font-family: inherit;
  line-height: 1.5;
}

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

.send-btn {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  transition: all var(--transition);
  flex-shrink: 0;
  box-shadow:
    0 4px 15px rgba(108, 92, 231, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.send-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow:
    0 6px 20px rgba(108, 92, 231, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.send-btn:active {
  transform: translateY(1px) scale(0.95);
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

/* ============ EMPTY STATE ============ */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state i { font-size: 40px; margin-bottom: 14px; display: block; }
.empty-state p { font-size: 16px; margin-bottom: 8px; }
.empty-state small { font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 6px; }

/* ============ CALL OVERLAY ============ */
.call-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(10, 10, 26, 0.95), rgba(15, 15, 35, 0.98));
  backdrop-filter: blur(30px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  animation: fadeIn 0.3s ease;
}

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

.call-avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  font-weight: 800;
  color: white;
  position: relative;
  animation: callAvatarPulse 2s infinite ease-in-out;
}

.call-avatar::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  animation: callRing 2s infinite ease-in-out;
}

@keyframes callAvatarPulse {
  0%, 100% { box-shadow: 0 0 30px rgba(108, 92, 231, 0.3); }
  50% { box-shadow: 0 0 60px rgba(108, 92, 231, 0.5); }
}

@keyframes callRing {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.5; }
}

.call-name {
  font-size: 24px;
  font-weight: 700;
}

.call-status {
  font-size: 14px;
  color: var(--text-secondary);
}

.call-timer {
  font-size: 18px;
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.call-video-container {
  width: 640px;
  max-width: 90vw;
  aspect-ratio: 16/9;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: none;
}

.call-video-container.active {
  display: block;
}

.call-video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.call-controls {
  display: flex;
  gap: 16px;
  margin-top: 20px;
}

.call-control-btn {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  transition: all var(--transition);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.call-control-btn:hover {
  transform: translateY(-3px) scale(1.08);
}

.call-control-btn:active {
  transform: translateY(1px) scale(0.95);
}

.call-control-btn.mute {
  background: linear-gradient(135deg, #636e72, #2d3436);
}

.call-control-btn.mute.active {
  background: linear-gradient(135deg, var(--red), #c0392b);
}

.call-control-btn.video-toggle {
  background: linear-gradient(135deg, var(--neon-blue), var(--primary));
}

.call-control-btn.video-toggle.active {
  background: linear-gradient(135deg, var(--red), #c0392b);
}

.call-control-btn.hangup {
  background: linear-gradient(135deg, var(--red), #c0392b);
  width: 64px;
  height: 64px;
  font-size: 26px;
}

.call-control-btn.hangup:hover {
  box-shadow: 0 6px 25px rgba(255, 107, 107, 0.5);
}

/* ============ FILE PREVIEW ============ */
.file-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  margin-bottom: 8px;
}

.file-preview .file-icon {
  font-size: 28px;
  color: var(--primary-light);
}

.file-preview .file-info { flex: 1; }
.file-preview .file-info .filename { font-size: 14px; font-weight: 600; }
.file-preview .file-info .filesize { font-size: 12px; color: var(--text-muted); }

.file-preview .remove-file {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 18px;
}

/* ============ LOADING SPINNER ============ */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

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

/* ============ NOTIFICATION TOAST ============ */
.toast-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  padding: 16px 24px;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-notification.success {
  background: linear-gradient(135deg, var(--green), #00d2a0);
}

.toast-notification.info {
  background: linear-gradient(135deg, var(--primary), var(--neon-blue));
}

.toast-notification.error {
  background: linear-gradient(135deg, var(--red), #c0392b);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* ============ EPHEMERAL MESSAGES ============ */
.ephemeral-wrapper {
  position: relative;
}

.ephemeral-toggle.active {
  background: linear-gradient(135deg, var(--orange), var(--red));
  color: white;
  border-color: var(--red);
  box-shadow: 0 0 15px rgba(253, 203, 110, 0.3);
}

.ephemeral-picker {
  position: absolute;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(253, 203, 110, 0.1);
  z-index: 100;
  min-width: 220px;
  overflow: hidden;
  animation: pickerIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pickerIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.ephemeral-picker-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--orange);
}

.ephemeral-options {
  padding: 6px;
}

.ephemeral-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
}

.ephemeral-option:hover {
  background: var(--bg-card-hover);
}

.ephemeral-option.selected {
  background: rgba(253, 203, 110, 0.1);
  color: var(--orange);
}

.ephemeral-time {
  width: 36px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.ephemeral-option.selected .ephemeral-time {
  background: linear-gradient(135deg, var(--orange), var(--red));
  color: white;
  border-color: transparent;
}

.ephemeral-check {
  margin-left: auto;
  display: none;
  color: var(--orange);
}

.ephemeral-option.selected .ephemeral-check {
  display: inline;
}

/* Ephemeral message styling */
.message.ephemeral {
  border-style: dashed;
  position: relative;
}

.message-wrapper.sent .message.ephemeral {
  border-color: rgba(255, 255, 255, 0.3);
}

.message-wrapper.received .message.ephemeral {
  border-color: var(--orange);
}

.ephemeral-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 4px;
}

.message-wrapper.sent .ephemeral-badge {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
}

.message-wrapper.received .ephemeral-badge {
  background: rgba(253, 203, 110, 0.15);
  color: var(--orange);
}

.ephemeral-countdown {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.ephemeral-countdown .countdown-ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ephemeral-countdown .countdown-ring svg {
  position: absolute;
  top: -2px;
  left: -2px;
  transform: rotate(-90deg);
}

.ephemeral-countdown .countdown-text {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.8;
}

.ephemeral-countdown .countdown-bar-ephemeral {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-left: 4px;
}

.ephemeral-countdown .countdown-bar-ephemeral-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 2px;
  transition: width 1s linear;
}

.message-wrapper.received .ephemeral-countdown .countdown-bar-ephemeral {
  background: rgba(253, 203, 110, 0.15);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: absolute;
    z-index: 10;
    height: 100%;
    transition: transform 0.3s;
  }

  .sidebar.hidden { transform: translateX(-100%); }

  .chat-area { width: 100%; }

  .mobile-back { display: flex; }

  .message-wrapper { max-width: 85%; }

  .msg-actions {
    display: flex !important;
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    margin-top: 4px;
  }

  .message-wrapper.sent .msg-actions {
    justify-content: flex-end;
  }

  .call-video-container {
    width: 95vw;
  }

  .theme-toggle {
    width: 38px;
    height: 38px;
    font-size: 15px;
  }

  .ephemeral-picker {
    left: -40px;
    transform: none;
    min-width: 200px;
  }
  @keyframes pickerIn {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
}
