* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #00a884;
  --primary-dark: #008069;
  --primary-light: #00bfa5;
  --bg-dark: #111b21;
  --bg-panel: #202c33;
  --bg-input: #2a3942;
  --bubble-out: #005c4b;
  --bubble-in: #202c33;
  --text-white: #e9edef;
  --text-gray: #8696a0;
  --text-muted: #667781;
  --danger: #f15c6d;
  --success: #00a884;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text-white);
  height: 100vh;
  overflow: hidden;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 1;
}

.screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(100%);
}

/* ========== AUTH SCREEN ========== */
.auth-bg {
  flex: 1;
  background: linear-gradient(160deg, #111b21 0%, #1a2a30 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: rgba(32, 44, 51, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 32px;
  padding: 40px 30px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  animation: slideUp 0.5s ease;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-icon {
  width: 70px;
  height: 70px;
  
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
 
  overflow: hidden;
}

.auth-card h2 {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.auth-card p {
  color: var(--text-gray);
  margin-bottom: 30px;
}

.auth-tabs {
  display: flex;
  gap: 10px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: 60px;
  margin-bottom: 30px;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: transparent;
  color: var(--text-gray);
  font-size: 1rem;
  font-weight: 600;
  border-radius: 60px;
  cursor: pointer;
  transition: all 0.3s;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 168, 132, 0.3);
}

.auth-form {
  display: none;
  animation: fadeIn 0.3s ease;
}

.auth-form.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.input-field {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-input);
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 16px;
  transition: all 0.3s;
  border: 1px solid transparent;
}

.input-field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.2);
}

.input-field svg {
  width: 20px;
  height: 20px;
  fill: var(--text-gray);
  flex-shrink: 0;
}

.input-field input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-white);
  font-size: 1rem;
  -webkit-text-fill-color: var(--text-white);
  caret-color: var(--primary);
}

.input-field input:-webkit-autofill,
.input-field input:-webkit-autofill:hover,
.input-field input:-webkit-autofill:focus,
.input-field input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px var(--bg-input) inset !important;
  -webkit-text-fill-color: var(--text-white) !important;
  caret-color: var(--primary);
  transition: background-color 5000s ease-in-out 0s;
}

.input-field input::placeholder {
  color: var(--text-muted);
}

.auth-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  border-radius: 16px;
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  margin-top: 10px;
}

.auth-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 168, 132, 0.4);
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 12px;
  text-align: center;
}

/* ========== DASHBOARD ========== */
.dash-header {
  background: var(--bg-panel);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  z-index: 50;
}

.dash-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-avatar img {
  width: 35px;
  height: 35px;
  object-fit: contain;
  border-radius: 50%;
  position: relative;
  z-index: 2;
}

.app-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-white);
  font-family: 'Poppins', -apple-system, sans-serif;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #00a884, #00bfa5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.menu-btn {
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
}

.menu-btn:active { background: rgba(255,255,255,0.08); }

.menu-btn span {
  width: 20px;
  height: 2px;
  background: var(--text-white);
  border-radius: 2px;
  transition: 0.3s;
}

.menu-btn.small {
  width: 35px;
  height: 35px;
}

/* ========== DASHBOARD MENU POPUP ========== */
.dash-menu-popup {
  position: absolute;
  top: 62px;
  right: 12px;
  background: #2a3942;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  z-index: 200;
  min-width: 180px;
  animation: popDown 0.18s cubic-bezier(0.34,1.2,0.64,1) both;
}

.dash-menu-popup.hidden {
  display: none;
}

@keyframes popDown {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dash-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 18px;
  background: transparent;
  border: none;
  color: var(--text-white);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}

.dash-menu-item:not(:last-child) {
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.dash-menu-item:active {
  background: rgba(255,255,255,0.08);
}

.dash-menu-item svg {
  width: 20px;
  height: 20px;
  fill: var(--primary);
  flex-shrink: 0;
}

/* ========== PROFILE MODAL (overlay over dashboard) ========== */
.profile-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  display: flex;
  flex-direction: column;
  animation: fadeInBg 0.2s ease;
}

@keyframes fadeInBg {
  from { opacity: 0; }
  to { opacity: 1; }
}

.profile-modal {
  position: absolute;
  inset: 0;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  animation: slideUpModal 0.3s cubic-bezier(0.34,1.1,0.64,1) both;
}

@keyframes slideUpModal {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.profile-header {
  background: var(--bg-panel);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-header h2 {
  font-size: 1.2rem;
}

.profile-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  text-align: center;
}

.profile-avatar-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
  cursor: pointer;
}

.profile-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: bold;
  overflow: hidden;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-edit {
  position: absolute;
  bottom: 0;
  right: 0;
  background: var(--primary);
  border-radius: 50%;
  padding: 8px;
  font-size: 0.8rem;
}

.profile-name {
  font-size: 1.4rem;
  font-weight: bold;
  margin-bottom: 4px;
}

.profile-email {
  color: var(--text-gray);
  margin-bottom: 30px;
}

.profile-info-card {
  background: var(--bg-panel);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 20px;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: 0.2s;
}

.info-row:active {
  background: var(--bg-input);
}

.info-row svg {
  width: 24px;
  height: 24px;
  fill: var(--primary);
}

.info-row div {
  flex: 1;
  text-align: left;
}

.info-row label {
  font-size: 0.7rem;
  color: var(--text-gray);
}

.info-row .arrow {
  color: var(--text-gray);
}

.logout-btn {
  width: 100%;
  padding: 14px;
  background: rgba(241, 92, 109, 0.15);
  border: 1px solid var(--danger);
  border-radius: 16px;
  color: var(--danger);
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: 0.2s;
}

.logout-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--danger);
}

/* ========== GROUP CREATION MODAL ========== */
.group-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 300;
  display: flex;
  align-items: flex-end;
}

.group-modal {
  background: var(--bg-dark);
  width: 100%;
  max-height: 85vh;
  border-radius: 24px 24px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUpSheet 0.3s cubic-bezier(0.34,1.1,0.64,1) both;
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.group-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.group-modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.group-modal-close {
  background: var(--bg-input);
  border: none;
  color: var(--text-white);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.group-name-input {
  margin: 16px 20px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px 16px;
  color: var(--text-white);
  font-size: 0.95rem;
  outline: none;
  width: calc(100% - 40px);
  transition: border-color 0.2s;
}

.group-name-input:focus {
  border-color: var(--primary);
}

.group-modal-subtitle {
  padding: 0 20px 8px;
  font-size: 0.75rem;
  color: var(--text-gray);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.group-users-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px;
}

.group-user-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 8px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.group-user-item:active {
  background: var(--bg-input);
}

.group-user-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.group-user-item.selected .group-user-check {
  background: var(--primary);
  border-color: var(--primary);
}

.group-user-check::after {
  content: '';
  display: none;
  width: 6px;
  height: 10px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}

.group-user-item.selected .group-user-check::after {
  display: block;
}

.group-create-btn {
  margin: 16px 20px;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  border-radius: 16px;
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

.group-create-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ========== SEARCH BAR ========== */
.search-bar {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.search-bar svg {
  width: 20px;
  height: 20px;
  fill: var(--text-gray);
}

.search-bar input {
  flex: 1;
  background: var(--bg-input);
  border: none;
  border-radius: 24px;
  padding: 10px 16px;
  color: var(--text-white);
  font-size: 0.9rem;
  outline: none;
}

.search-bar input:focus {
  outline: 1px solid var(--primary);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.chat-item:hover, .chat-item:active {
  background: var(--bg-panel);
}

.chat-avatar-small {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.chat-avatar-small img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.online-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: var(--success);
  border-radius: 50%;
  border: 2px solid var(--bg-dark);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.chat-info {
  flex: 1;
}

.chat-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.chat-preview {
  font-size: 0.8rem;
  color: var(--text-gray);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ========== CHAT SCREEN ========== */
.chat-header {
  background: var(--bg-panel);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.back-btn {
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-btn svg {
  width: 24px;
  height: 24px;
  fill: var(--text-white);
}

.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-name {
  font-weight: 700;
  font-size: 1rem;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--text-gray);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* ========== DATE DIVIDER ========== */
.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0 6px;
}

.date-divider span {
  background: rgba(0,0,0,0.45);
  color: var(--text-gray);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

/* ========== MESSAGES ========== */
.msg-wrap {
  display: flex;
  margin: 1px 0;
  animation: messageAppear 0.2s ease;
}

@keyframes messageAppear {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-wrap.out { justify-content: flex-end; }
.msg-wrap.in { justify-content: flex-start; }

.bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 18px;
  position: relative;
}

.msg-wrap.out .bubble {
  background: var(--bubble-out);
  border-bottom-right-radius: 4px;
}

.msg-wrap.in .bubble {
  background: var(--bubble-in);
  border-bottom-left-radius: 4px;
}

/* Group sender name label */
.bubble-sender {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary-light);
  margin-bottom: 3px;
}

.bubble-text {
  font-size: 0.9rem;
  line-height: 1.4;
  word-wrap: break-word;
}

.bubble-text a {
  color: var(--primary);
  text-decoration: none;
}

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 2px;
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;   /* keep time + ticks on one line, never wrap */
  float: right;          /* sit bottom-right of bubble exactly like WhatsApp */
  margin-left: 8px;      /* gap from message text when on same line */
  clear: both;
}

.bubble-img {
  max-width: 250px;
  border-radius: 12px;
  cursor: pointer;
}

.bubble-img img {
  width: 100%;
  border-radius: 12px;
}

.bubble-video {
  max-width: 250px;
  position: relative;
  cursor: pointer;
}

.bubble-video video {
  width: 100%;
  border-radius: 12px;
}

.voice-note {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
}

.voice-play {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-play svg {
  width: 18px;
  height: 18px;
  fill: white;
}

.voice-wave {
  flex: 1;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.voice-wave span {
  flex: 1;
  height: 4px;
  background: var(--text-gray);
  border-radius: 2px;
  transition: 0.1s;
}

.voice-wave span.active {
  background: var(--primary);
  height: 12px;
}

.file-attachment {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
}

.file-icon {
  width: 40px;
  height: 40px;
  background: var(--primary-dark);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.download-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
}

/* ========== CHAT INPUT ========== */
.chat-input-area {
  background: var(--bg-dark);
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
}

.input-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.input-wrapper {
  flex: 1;
  background: var(--bg-input);
  border-radius: 24px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
}

.input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-white);
  font-size: 0.9rem;
  resize: none;
  max-height: 100px;
  font-family: inherit;
  padding: 8px 0;
}

.attach-icon {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attach-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mic-send-btn {
  width: 44px;
  height: 44px;
  background: var(--primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  flex-shrink: 0;
}

.mic-send-btn svg {
  width: 22px;
  height: 22px;
  fill: white;
}

.attach-menu {
  position: absolute;
  bottom: 80px;
  left: 12px;
  right: 12px;
  background: var(--bg-panel);
  border-radius: 20px;
  padding: 12px;
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  z-index: 100;
  animation: popUp 0.2s ease;
}

.attach-menu.open {
  display: grid;
}

.attach-menu button {
  padding: 12px;
  background: var(--bg-input);
  border: none;
  border-radius: 12px;
  color: var(--text-white);
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.2s;
}

@keyframes popUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.recording-ui {
  background: var(--bg-input);
  border-radius: 30px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.recording-wave {
  display: flex;
  align-items: center;
  gap: 4px;
}

.recording-wave span {
  width: 4px;
  height: 20px;
  background: var(--danger);
  border-radius: 2px;
  animation: wave 0.8s ease-in-out infinite;
}

.recording-wave span:nth-child(1) { animation-delay: 0s; height: 10px; }
.recording-wave span:nth-child(2) { animation-delay: 0.1s; height: 20px; }
.recording-wave span:nth-child(3) { animation-delay: 0.2s; height: 30px; }
.recording-wave span:nth-child(4) { animation-delay: 0.3s; height: 20px; }
.recording-wave span:nth-child(5) { animation-delay: 0.4s; height: 10px; }

@keyframes wave {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.5); }
}

.recording-time {
  color: var(--danger);
  font-weight: 600;
}

.recording-actions {
  display: flex;
  gap: 12px;
}

.rec-cancel, .rec-send {
  padding: 6px 12px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
}

.rec-cancel {
  background: var(--bg-dark);
  color: var(--text-gray);
}

.rec-send {
  background: var(--primary);
  color: white;
}

/* ========== MEDIA VIEWER ========== */
.media-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.media-viewer.open {
  display: flex;
}

.media-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-panel);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 0.85rem;
  opacity: 0;
  transition: 0.3s;
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.empty-state, .chat-splash {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-gray);
}

.splash-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.chat-splash h3 {
  margin-bottom: 8px;
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  animation: fadeIn 0.2s ease;
}

.modal-box {
  background: #1e2c34;
  border-radius: 20px;
  padding: 24px;
  width: calc(100% - 48px);
  max-width: 340px;
  animation: slideUp 0.25s ease;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.modal-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text-white);
  font-size: 0.95rem;
  outline: none;
  margin-bottom: 20px;
  transition: border-color 0.2s;
}

.modal-input:focus {
  border-color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.modal-btn.cancel {
  background: var(--bg-input);
  color: var(--text-gray);
}

.modal-btn.confirm {
  background: var(--primary);
  color: white;
}

/* ========== CONTEXT MENU ========== */
.context-menu {
  position: fixed;
  background: #1e2c34;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  z-index: 600;
  min-width: 200px;
  animation: popUp 0.15s ease;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.context-menu-item:last-child { border-bottom: none; }
.context-menu-item:active { background: var(--bg-input); }
.context-menu-item.danger { color: var(--danger); }

.cm-icon {
  font-size: 1.1rem;
}

/* ========== MISC ========== */
.deleted-msg {
  color: var(--text-muted);
  font-style: italic;
}

.edited-tag {
  color: var(--text-muted);
  font-size: 0.65rem;
  font-style: italic;
}

/* ========== MESSAGE TICKS ========== */
.ticks {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: -3px;   /* pulls the two ✓✓ close together like WhatsApp */
  line-height: 1;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Single grey tick — message sent to server */
.ticks-sent {
  color: var(--text-muted);
  letter-spacing: 0;      /* single tick needs no squeeze */
}

/* Double grey ticks — delivered to recipient device */
.ticks-delivered {
  color: var(--text-muted);
}

/* Double blue ticks — recipient opened the chat and read */
.ticks-read {
  color: #53bdeb;
}

/* ========== UNREAD BADGE ========== */
.chat-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-item-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.unread-badge {
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  animation: badgePop 0.25s cubic-bezier(0.34,1.56,0.64,1) both;
}

.unread-badge.hidden {
  display: none;
}

@keyframes badgePop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
/* ========== CHAT HEADER MENU POPUP ========== */
.chat-menu-popup {
  position: fixed;
  background: #1e2c34;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
  z-index: 600;
  min-width: 200px;
  animation: popDown 0.18s cubic-bezier(0.34,1.2,0.64,1) both;
}

.chat-menu-item {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 14px 18px;
  background: transparent;
  border: none;
  color: var(--text-white);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.chat-menu-item:last-child {
  border-bottom: none;
}

.chat-menu-item:active {
  background: rgba(255,255,255,0.08);
}

.cmi-icon {
  font-size: 1.05rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}
/* ========== ADMIN PANEL ========== */
#dash-admin-btn svg {
  fill: var(--danger);
}

/* ========== FORWARD MODAL ========== */
.forward-user-item:active {
  background: rgba(0,168,132,0.1) !important;
}
/* ========== BOTTOM NAV ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-panel);
  display: none;
  align-items: center;
  justify-content: space-around;
  border-top: 1px solid rgba(255,255,255,0.07);
  z-index: 300;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav.visible {
  display: flex;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  position: relative;
  transition: color 0.2s;
}

.nav-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  transition: fill 0.2s;
}

.nav-btn.active {
  color: var(--primary);
}

.nav-btn span {
  font-size: 0.68rem;
  letter-spacing: 0.3px;
}

.nav-dot {
  position: absolute;
  top: 4px;
  right: 22%;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  border: 2px solid var(--bg-panel);
}

.nav-dot.hidden { display: none; }

/* ========== DASHBOARD BOTTOM NAV PADDING ========== */
.has-bottom-nav .chat-list {
  padding-bottom: 70px;
}

/* ========== STATUS SCREEN ========== */
#status-screen {
  background: var(--bg-dark);
  padding-bottom: 70px;
}

.status-my-section {
  padding: 12px 16px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.status-my-row {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  padding: 6px 0;
}

.status-avatar-ring {
  position: relative;
  flex-shrink: 0;
}

.status-avatar-ring .chat-avatar-small {
  width: 52px;
  height: 52px;
  border-radius: 50%;
}

.status-avatar-ring.has-status .chat-avatar-small {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.status-add-icon {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 20px;
  height: 20px;
  background: var(--primary);
  border-radius: 50%;
  border: 2px solid var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.status-my-info {
  flex: 1;
}

.status-my-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.status-my-sub {
  color: var(--text-gray);
  font-size: 0.78rem;
  margin-top: 3px;
}

.status-add-menu {
  margin: 8px 16px;
  background: var(--bg-panel);
  border-radius: 16px;
  overflow: hidden;
  animation: popDown 0.18s ease both;
}

.status-add-menu.hidden { display: none; }

.status-add-option {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 14px 18px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-white);
  font-size: 0.92rem;
  cursor: pointer;
  gap: 10px;
  transition: background 0.15s;
}

.status-add-option:last-child { border-bottom: none; }
.status-add-option:active { background: rgba(255,255,255,0.06); }

.status-section-title {
  padding: 14px 16px 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.status-others-list {
  overflow-y: auto;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.status-item:active { background: rgba(255,255,255,0.04); }

.status-ring-wrap {
  position: relative;
  flex-shrink: 0;
}

.status-ring-wrap .chat-avatar-small {
  width: 52px;
  height: 52px;
  border-radius: 50%;
}

.status-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2.5px solid var(--primary);
  pointer-events: none;
}

.status-ring.seen {
  border-color: var(--text-muted);
}

.status-item-info {
  flex: 1;
}

.status-item-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.status-item-time {
  font-size: 0.75rem;
  color: var(--text-gray);
  margin-top: 2px;
}

/* ========== STATUS VIEWER ========== */
.status-viewer {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 800;
  display: flex;
  flex-direction: column;
}

.status-viewer.hidden { display: none; }

.sv-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 48px 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
  z-index: 10;
}

.sv-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  margin-right: 4px;
}

.sv-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.sv-name {
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
}

.sv-time {
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
}

.sv-viewers-btn {
  color: white;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 5px 10px;
  cursor: pointer;
}

.sv-progress-bars {
  position: absolute;
  top: 14px;
  left: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 11;
}

.sv-progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  overflow: hidden;
}

.sv-progress-fill {
  height: 100%;
  background: white;
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}

.sv-progress-fill.done { width: 100%; }

.sv-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sv-content img, .sv-content video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.sv-content .sv-text-status {
  padding: 40px 30px;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  color: white;
  word-break: break-word;
  line-height: 1.5;
  width: 100%;
}

.sv-tap-areas {
  position: absolute;
  inset: 0;
  display: flex;
  z-index: 5;
  top: 120px;
  bottom: 60px;
}

.sv-tap-prev, .sv-tap-next {
  flex: 1;
  cursor: pointer;
}

/* ========== STATUS TEXT COMPOSER ========== */
.status-text-overlay {
  position: fixed;
  inset: 0;
  background: #111b21;
  z-index: 900;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.status-text-overlay.hidden { display: none; }

.sto-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.sto-back {
  background: transparent;
  border: none;
  color: var(--text-white);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
}

.sto-title {
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}

.sto-send {
  background: var(--primary);
  border: none;
  color: white;
  border-radius: 20px;
  padding: 8px 20px;
  font-weight: 700;
  cursor: pointer;
}

.sto-textarea {
  flex: 1;
  background: var(--bg-panel);
  border: none;
  border-radius: 16px;
  padding: 20px;
  color: var(--text-white);
  font-size: 1.3rem;
  resize: none;
  outline: none;
  line-height: 1.6;
}

.sto-textarea::placeholder { color: var(--text-muted); }

/* ========== GROUPS SCREEN ========== */
#groups-screen {
  background: var(--bg-dark);
  padding-bottom: 70px;
}

.groups-list {
  overflow-y: auto;
  flex: 1;
}

.group-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.group-item:active { background: rgba(255,255,255,0.04); }

.group-item-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c4dff, #448aff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.group-item-info {
  flex: 1;
  min-width: 0;
}

.group-item-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-item-sub {
  font-size: 0.78rem;
  color: var(--text-gray);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========== STATUS SCREEN BOTTOM NAV ========== */
#status-screen.has-bottom-nav .status-others-list,
#groups-screen.has-bottom-nav .groups-list {
  padding-bottom: 70px;
}