/* Vibro High-End Design System */
:root {
  --bg-main: #09090b;
  --bg-surface: #121214;
  --bg-card: #18181b;
  --bg-hover: #27272a;
  --border-subtle: #27272a;
  --border-focus: #3f3f46;

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-cyan: #38bdf8;
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;

  --online-green: #10b981;
  --star-gold: #f59e0b;
  --danger-red: #ef4444;

  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-stack);
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
}

#app {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Sidebar Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  z-index: 150;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.drawer-backdrop.active {
  display: block;
  opacity: 1;
}

.drawer {
  position: fixed;
  top: 0;
  left: -320px;
  width: 320px;
  height: 100%;
  background: #121216;
  border-right: 1px solid var(--border-subtle);
  z-index: 160;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
}
.drawer.open {
  transform: translateX(320px);
}

.drawer-header {
  padding: 24px 20px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.08) 100%);
  border-bottom: 1px solid var(--border-subtle);
}
.drawer-profile {
  display: flex;
  align-items: center;
  gap: 14px;
}
.drawer-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  object-fit: cover;
}
.drawer-user-info h3 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.drawer-user-info p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.drawer-menu {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}
.drawer-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.drawer-item:hover {
  background: var(--bg-hover);
}
.drawer-item.danger {
  color: #f87171;
}
.drawer-item.danger:hover {
  background: rgba(239, 68, 68, 0.12);
}
.drawer-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--muted);
}
.drawer-item:hover svg {
  color: var(--text-main);
}
.drawer-item.danger svg {
  color: #f87171;
}

/* Sidebar */
.sidebar {
  width: 360px;
  min-width: 300px;
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

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

.brand-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-badge svg {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.4));
}

.brand-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

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

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

/* Search Bar */
.search-box {
  padding: 10px 14px;
  position: relative;
}

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

.search-input:focus {
  border-color: var(--primary);
}

.search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

/* Folders / Tabs */
.chat-tabs {
  display: flex;
  padding: 4px 12px;
  gap: 6px;
  border-bottom: 1px solid var(--border-subtle);
}
.chat-tab {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.chat-tab:hover {
  color: var(--text-main);
}
.chat-tab.active {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}

/* Chat & User List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  margin-bottom: 2px;
}

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

.chat-item.active {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.avatar-wrapper {
  position: relative;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
}

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  background: var(--online-green);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
}

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

.chat-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

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

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

.chat-sub-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.unread-badge {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

/* User Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.my-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.my-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stars-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--star-gold);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.stars-pill:hover {
  transform: scale(1.04);
}

/* Main Chat Area */
.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  position: relative;
}

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

.empty-state svg {
  width: 72px;
  height: 72px;
  margin-bottom: 16px;
  opacity: 0.4;
}

/* Active Chat Top Bar */
.chat-topbar {
  padding: 12px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-name {
  font-size: 15px;
  font-weight: 600;
}

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

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

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

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

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 75%;
}

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

.message-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  position: relative;
  word-break: break-word;
}

.message-row.incoming .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.message-row.outgoing .message-bubble {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.75;
}

.message-image {
  max-width: 320px;
  max-height: 280px;
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  cursor: pointer;
  display: block;
}

.message-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.reaction-tag {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
}

/* Chat Input Dock */
.chat-dock {
  padding: 10px 18px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-field {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 120px;
  min-height: 42px;
  line-height: 20px;
}

.input-field:focus {
  border-color: var(--primary);
}

.send-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

/* Voice recording wave animation */
.voice-recording-box {
  display: none;
  flex: 1;
  align-items: center;
  gap: 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  color: #f87171;
}
.record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger-red);
  animation: pulseAnim 1.2s infinite;
}

/* Modals & Overlays (Glassmorphism) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Call Overlay */
.call-overlay {
  position: fixed;
  inset: 0;
  background: #09090b;
  z-index: 300;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 60px 24px 48px;
}

.call-avatar {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  margin-bottom: 20px;
}

.call-actions {
  display: flex;
  gap: 24px;
}

.call-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s;
}
.call-btn:hover { transform: scale(1.06); }

.call-btn.end {
  background: var(--danger-red);
  color: #fff;
}

.call-btn.accept {
  background: var(--online-green);
  color: #fff;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    min-width: 100%;
  }
  .chat-pane {
    display: none;
  }
  .chat-pane.mobile-open {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 50;
  }
}
