/* ==========================================================================
   GHOSTWIRE CYBERNETIC ZERO-KNOWLEDGE MESSENGER DESIGN SYSTEM
   Theme: Stealth Glassmorphism, Deep Obsidian Void, Neon Cyan & Emerald Glow
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Outfit:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Color Palette */
  --bg-dark: #06080d;
  --bg-primary: #0a0d14;
  --bg-secondary: #0f1420;
  --bg-tertiary: #151b2a;
  --bg-glass: rgba(15, 20, 32, 0.75);
  --bg-glass-card: rgba(21, 27, 42, 0.65);
  --bg-glass-input: rgba(10, 13, 20, 0.7);

  /* Accents */
  --cyan: #00f0ff;
  --cyan-glow: rgba(0, 240, 255, 0.35);
  --cyan-subtle: rgba(0, 240, 255, 0.1);
  --emerald: #00ff9d;
  --emerald-glow: rgba(0, 255, 157, 0.35);
  --purple: #9d4edd;
  --purple-glow: rgba(157, 78, 221, 0.35);
  --crimson: #ff3366;
  --crimson-glow: rgba(255, 51, 102, 0.35);
  --amber: #ffb703;

  /* Typography & Lines */
  --text-main: #f0f4fc;
  --text-secondary: #8e9bb0;
  --text-muted: #566378;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 240, 255, 0.25);
  --border-active: #00f0ff;

  /* Transitions & Shadows */
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 25px rgba(0, 240, 255, 0.2);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 9999px;

  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  --blur-glass: blur(16px);
}

/* CSS Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.5;
  user-select: none;
}

input, textarea, button {
  font-family: inherit;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--cyan);
}

/* Background Cyber Grid Effect */
.cyber-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 20%, rgba(0, 240, 255, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(157, 78, 221, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(0, 255, 157, 0.03) 0%, transparent 50%),
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 100% 100%, 48px 48px, 48px 48px;
}

/* App Wrapper */
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 1;
  display: flex;
  overflow: hidden;
}

/* Authentication / Passphrase Unlock Screen */
.auth-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: radial-gradient(circle at center, rgba(14, 18, 30, 0.95), #06080d 85%);
  backdrop-filter: var(--blur-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.4s ease;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-glass-card);
  border: 1px solid var(--border-glow);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 240, 255, 0.12);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  backdrop-filter: var(--blur-glass);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--emerald), var(--purple));
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  background: var(--cyan-subtle);
  border: 1px solid rgba(0, 240, 255, 0.3);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--cyan);
  margin-bottom: 20px;
  text-transform: uppercase;
}

.brand-badge .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
  animation: pulse 1.8s infinite;
}

.auth-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-main);
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.4;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

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

.auth-input {
  width: 100%;
  padding: 13px 16px;
  background: var(--bg-glass-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 14.5px;
  outline: none;
  transition: var(--transition-fast);
}

.auth-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--cyan), #00b4d8);
  color: #06090f;
  font-weight: 700;
  font-size: 14.5px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 18px rgba(0, 240, 255, 0.35);
  margin-top: 8px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0, 240, 255, 0.5);
  filter: brightness(1.08);
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: var(--radius-md);
}

.auth-tab-btn {
  flex: 1;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.auth-tab-btn.active {
  background: var(--bg-glass-card);
  color: var(--cyan);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Main Application Shell */
.app-shell {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 380px;
  min-width: 320px;
  height: 100%;
  background: var(--bg-glass);
  backdrop-filter: var(--blur-glass);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: transform var(--transition-smooth);
}

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

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-radius: var(--radius-md);
  padding: 4px 8px 4px 4px;
  transition: var(--transition-fast);
}

.user-profile-badge:hover {
  background: rgba(255, 255, 255, 0.05);
}

.avatar-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1.5px solid var(--cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
  flex-shrink: 0;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.status-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--emerald);
  border: 2px solid var(--bg-primary);
  box-shadow: 0 0 6px var(--emerald);
}

.user-meta {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.user-id-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  background: rgba(0, 240, 255, 0.1);
  border-color: var(--cyan);
  color: var(--cyan);
  transform: translateY(-1px);
}

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

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

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  background: var(--bg-glass-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-main);
  font-size: 13.5px;
  outline: none;
  transition: var(--transition-fast);
}

.search-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.15);
}

/* Contacts List */
.contacts-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid transparent;
}

.contact-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.contact-item.active {
  background: rgba(0, 240, 255, 0.08);
  border-color: rgba(0, 240, 255, 0.25);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

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

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

.contact-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

.unread-badge {
  background: var(--cyan);
  color: #06090f;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  box-shadow: 0 0 8px var(--cyan);
}

/* Chat Main View */
.chat-container {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
  z-index: 5;
}

.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-icon-shield {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--cyan-subtle);
  border: 1px solid rgba(0, 240, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cyan);
  margin-bottom: 20px;
  box-shadow: var(--shadow-glow);
}

.chat-header {
  height: 72px;
  padding: 0 24px;
  background: var(--bg-glass);
  backdrop-filter: var(--blur-glass);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 8;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chat-title-group {
  display: flex;
  flex-direction: column;
}

.chat-partner-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.chat-security-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--emerald);
  font-family: var(--font-mono);
}

.chat-call-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.call-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.call-btn:hover {
  background: rgba(0, 240, 255, 0.12);
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.2);
}

.call-btn.video-btn:hover {
  background: rgba(0, 255, 157, 0.12);
  border-color: var(--emerald);
  color: var(--emerald);
  box-shadow: 0 0 14px rgba(0, 255, 157, 0.2);
}

/* Chat Messages Scroll Area */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
}

.date-badge {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Chat Input Bar */
.chat-input-bar {
  padding: 14px 24px;
  background: var(--bg-glass);
  backdrop-filter: var(--blur-glass);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 8;
  position: relative;
}

.input-box-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.message-input {
  width: 100%;
  padding: 12px 18px;
  background: var(--bg-glass-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  color: var(--text-main);
  font-size: 14.5px;
  outline: none;
  transition: var(--transition-fast);
}

.message-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.15);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), #00b4d8);
  border: none;
  color: #06090f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.35);
  flex-shrink: 0;
}

.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.55);
}

/* Mobile Back Button */
.mobile-back-btn {
  display: none;
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.9); }
}

@keyframes ringPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 157, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 20px rgba(0, 255, 157, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 157, 0); }
}

/* Responsive Rules */
@media (max-width: 820px) {
  .sidebar {
    width: 100%;
    position: absolute;
    inset: 0;
  }
  .sidebar.hidden-mobile {
    transform: translateX(-100%);
  }
  .chat-container {
    width: 100%;
    position: absolute;
    inset: 0;
  }
  .mobile-back-btn {
    display: flex;
    margin-right: 8px;
  }
}
