/* ==========================================================================
   WhatsApp Web Application - CSS Design System & Stylesheet
   Designed with vibrant dark/light modes, glassmorphism, responsive drawer layout
   ========================================================================== */

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

:root {
  /* WhatsApp Light Theme Tokens */
  --bg-app: #e1e9eb;
  --bg-sidebar: #ffffff;
  --bg-header: #f0f2f5;
  --bg-chat-header: #f0f2f5;
  --bg-chat: #efeae2;
  --bg-chat-wallpaper: radial-gradient(circle, rgba(0, 168, 132, 0.04) 0%, rgba(240, 242, 245, 0.8) 100%);
  --bg-input-bar: #f0f2f5;
  --bg-input: #ffffff;
  --bg-msg-out: #d9fdd3;
  --bg-msg-in: #ffffff;
  --bg-msg-hover: rgba(0, 0, 0, 0.02);
  --bg-card: #ffffff;
  --bg-modal: #ffffff;
  
  /* Text & Accents */
  --text-primary: #111b21;
  --text-secondary: #667781;
  --text-muted: #8696a0;
  --text-link: #027eb5;
  --border-color: #e9edef;
  
  --primary: #00a884;
  --primary-hover: #008f70;
  --primary-dark: #005c4b;
  --primary-light: #25d366;
  
  --unread-badge: #25d366;
  --read-receipt: #53bdeb;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.15);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  /* WhatsApp Dark Theme Tokens */
  --bg-app: #0c1317;
  --bg-sidebar: #111b21;
  --bg-header: #202c33;
  --bg-chat-header: #202c33;
  --bg-chat: #0b141a;
  --bg-chat-wallpaper: radial-gradient(circle, rgba(0, 168, 132, 0.05) 0%, rgba(11, 20, 26, 0.95) 100%);
  --bg-input-bar: #202c33;
  --bg-input: #2a3942;
  --bg-msg-out: #005c4b;
  --bg-msg-in: #202c33;
  --bg-msg-hover: rgba(255, 255, 255, 0.03);
  --bg-card: #202c33;
  --bg-modal: #111b21;
  
  --text-primary: #e9edef;
  --text-secondary: #8696a0;
  --text-muted: #667781;
  --text-link: #53bdeb;
  --border-color: #222d34;
}

/* Reset & Basic Setup */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Custom Smooth Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(134, 150, 160, 0.25);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 168, 132, 0.5);
}

body {
  font-family: 'Plus Jakarta Sans', 'Outfit', -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, sans-serif;
  background-color: var(--bg-app);
  background-image: 
    radial-gradient(at 0% 0%, rgba(0, 168, 132, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(37, 211, 102, 0.1) 0px, transparent 50%);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
}

button, input, textarea, select {
  font-family: inherit;
  outline: none;
  border: none;
}

/* App Container Window */
.app-container {
  width: 100vw;
  height: 100vh;
  max-width: 1600px;
  max-height: 100vh;
  display: flex;
  background-color: var(--bg-sidebar);
  position: relative;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

@media (min-width: 1400px) {
  body {
    padding: 16px;
  }
  .app-container {
    height: calc(100vh - 32px);
    border-radius: var(--radius-lg);
  }
}

/* ==========================================================================
   AUTHENTICATION OVERLAY / LOGIN & REGISTER FORM
   ========================================================================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top left, #00a884 0%, #111b21 70%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 20px;
  backdrop-filter: blur(10px);
}

.auth-card {
  background: rgba(32, 44, 51, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(16px);
  width: 100%;
  max-width: 440px;
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  color: #e9edef;
  animation: fadeInScale 0.4s ease-out;
}

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

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

.auth-header .brand-logo {
  width: 68px;
  height: 68px;
  background: linear-gradient(135deg, #25d366, #00a884);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(0, 168, 132, 0.4);
  color: #fff;
  font-size: 32px;
}

.auth-header h2 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.auth-header p {
  color: #8696a0;
  font-size: 14px;
}

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

.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  background: transparent;
  color: #8696a0;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.auth-tab.active {
  background: #00a884;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Admin / User Role Switcher */
.role-selector-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px;
  border-radius: var(--radius-sm);
  gap: 4px;
  margin-bottom: 4px;
}

.role-option {
  flex: 1;
  padding: 8px 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #8696a0;
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.role-option:hover {
  color: #e9edef;
}

.role-option.active {
  background: linear-gradient(135deg, #00a884, #25d366);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 168, 132, 0.3);
}

.auth-form-group {
  margin-bottom: 18px;
}

.auth-form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #8696a0;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.auth-form-group input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 15px;
  transition: var(--transition);
}

.auth-form-group input:focus {
  border-color: #00a884;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.2);
}

.btn-auth-submit {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #00a884, #25d366);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(0, 168, 132, 0.3);
  margin-top: 10px;
}

.btn-auth-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 168, 132, 0.4);
}

.auth-error-msg {
  background: rgba(234, 67, 53, 0.15);
  border: 1px solid rgba(234, 67, 53, 0.4);
  color: #ff6b6b;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 18px;
  display: none;
}

/* ==========================================================================
   LEFT SIDEBAR (CHATS & CONTACTS LIST)
   ========================================================================== */
.sidebar {
  width: 380px;
  min-width: 340px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  z-index: 10;
  transition: transform 0.3s ease;
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: absolute;
    inset: 0;
    z-index: 20;
  }
  .sidebar.mobile-hidden {
    transform: translateX(-100%);
  }
}

/* Sidebar Top Header */
.sidebar-header {
  height: 64px;
  padding: 10px 16px;
  background-color: var(--bg-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

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

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00a884, #25d366);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  text-transform: uppercase;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 168, 132, 0.25);
  position: relative;
  transition: transform 0.2s ease;
}

.avatar:hover {
  transform: scale(1.05);
}

.avatar.online::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  background-color: #25d366;
  border: 2px solid var(--bg-sidebar);
  border-radius: 50%;
  box-shadow: 0 0 6px #25d366;
}

.user-info-text .user-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.2;
}

.user-info-text .user-role-badge {
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  background: var(--primary);
  padding: 1px 6px;
  border-radius: 10px;
  display: inline-block;
}

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

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn:hover {
  background-color: rgba(134, 150, 160, 0.15);
  color: var(--text-primary);
}

/* Sidebar Search Box */
.sidebar-search {
  padding: 10px 14px;
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
}

.search-input-wrap {
  background-color: var(--bg-header);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 10px;
}

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

.search-input-wrap input {
  background: transparent;
  width: 100%;
  color: var(--text-primary);
  font-size: 14px;
}

.search-input-wrap input::placeholder {
  color: var(--text-muted);
}

/* Sidebar Navigation Tabs */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-sidebar);
}

.tab-btn {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn i {
  font-size: 15px;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Chat Contact List */
.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 14px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

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

.chat-item.active {
  background-color: var(--bg-header);
}

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

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

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

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

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

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

.unread-badge {
  background-color: var(--unread-badge);
  color: #111b21;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ==========================================================================
   RIGHT MAIN CHAT WINDOW
   ========================================================================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-chat);
  background-image: var(--bg-chat-wallpaper);
  height: 100%;
  position: relative;
}

/* Chat Header */
.chat-main-header {
  height: 64px;
  padding: 10px 16px;
  background-color: var(--bg-chat-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
}

.chat-partner-info {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.mobile-back-btn {
  display: none;
}

@media (max-width: 768px) {
  .mobile-back-btn {
    display: flex;
  }
}

.partner-details .partner-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.partner-status.online {
  color: var(--primary-light);
  font-weight: 600;
}

/* Messages Container */
.messages-container {
  flex: 1;
  padding: 20px 5%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Message Bubble Styling */
.message-bubble {
  max-width: 65%;
  padding: 8px 12px 6px;
  border-radius: var(--radius-sm);
  position: relative;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: var(--shadow-sm);
  word-wrap: break-word;
  animation: popIn 0.2s cubic-bezier(0, 1, 0.5, 1);
}

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

.message-bubble.outgoing {
  align-self: flex-end;
  background-color: var(--bg-msg-out);
  color: var(--text-primary);
  border-top-right-radius: 2px;
}

.message-bubble.incoming {
  align-self: flex-start;
  background-color: var(--bg-msg-in);
  color: var(--text-primary);
  border-top-left-radius: 2px;
}

/* Delete action button on message hover */
.msg-action-btn {
  position: absolute;
  top: 4px;
  right: 6px;
  opacity: 0;
  color: var(--text-muted);
  background: rgba(0,0,0,0.15);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.message-bubble:hover .msg-action-btn {
  opacity: 1;
}

.msg-action-btn:hover {
  color: #ff4d4d;
  background: rgba(255, 77, 77, 0.2);
}

/* Custom Wallpapers */
.wallpaper-emerald {
  background-image: radial-gradient(circle, rgba(0, 210, 150, 0.12) 0%, rgba(10, 30, 25, 0.95) 100%) !important;
}
.wallpaper-midnight {
  background-image: linear-gradient(135deg, #0f172a 0%, #020617 100%) !important;
}
.wallpaper-purple {
  background-image: radial-gradient(circle, rgba(168, 85, 247, 0.12) 0%, rgba(15, 10, 25, 0.95) 100%) !important;
}

.message-sender-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.message-content {
  margin-bottom: 4px;
  white-space: pre-wrap;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  float: right;
  margin-left: 12px;
  margin-top: 2px;
}

.message-meta .read-ticks {
  font-size: 14px;
}

.message-meta .read-ticks.read {
  color: var(--read-receipt);
}

/* Media Attachments in Messages */
.message-media {
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-width: 320px;
}

.message-media img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: transform 0.2s ease;
}

.message-media img:hover {
  transform: scale(1.02);
}

/* Document & File Attachment Card */
.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0,0,0,0.06);
  padding: 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  border: 1px solid var(--border-color);
}

.file-icon {
  width: 38px;
  height: 38px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

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

.file-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.btn-download-file {
  padding: 8px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 18px;
  border-radius: 50%;
  transition: var(--transition);
}

.btn-download-file:hover {
  background-color: rgba(0, 168, 132, 0.15);
}

/* Audio Voice Note Card */
.audio-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  min-width: 240px;
}

.audio-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
}

.audio-waveform {
  flex: 1;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.waveform-bar {
  flex: 1;
  height: 40%;
  background: var(--text-muted);
  border-radius: 2px;
  transition: height 0.2s ease, background 0.2s ease;
}

.audio-card.playing .waveform-bar {
  animation: pulseBar 0.8s infinite ease-in-out alternate;
  background: var(--primary);
}

@keyframes pulseBar {
  0% { height: 20%; }
  100% { height: 100%; }
}

/* Bottom Input Toolbar */
.chat-input-bar {
  min-height: 62px;
  padding: 10px 16px;
  background-color: var(--bg-input-bar);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-input-wrap {
  flex: 1;
  background-color: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  display: flex;
  align-items: center;
}

.chat-input-wrap textarea {
  width: 100%;
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  resize: none;
  max-height: 100px;
  height: 24px;
  line-height: 24px;
}

.btn-send-msg {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

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

/* ==========================================================================
   AUDIO RECORDING OVERLAY MODAL
   ========================================================================== */
.voice-recorder-bar {
  display: none;
  align-items: center;
  gap: 16px;
  width: 100%;
  background: var(--bg-input-bar);
  padding: 10px 16px;
}

.voice-recorder-bar.active {
  display: flex;
}

.recording-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ff4d4d;
  font-weight: 600;
  font-size: 14px;
}

.recording-pulse {
  width: 12px;
  height: 12px;
  background: #ff4d4d;
  border-radius: 50%;
  animation: pulseRed 1s infinite;
}

@keyframes pulseRed {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   MODALS (ADMIN BOT CONFIG & USER CREATION)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9000;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background-color: var(--bg-modal);
  color: var(--text-primary);
  width: 100%;
  max-width: 520px;
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

/* Lightbox Modal */
.lightbox-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-modal img {
  max-width: 90%;
  max-height: 90vh;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

/* EMOJI PICKER CONTAINER */
.emoji-picker-container {
  position: absolute;
  bottom: 70px;
  left: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  z-index: 100;
  max-height: 220px;
  overflow-y: auto;
}

.emoji-btn {
  font-size: 22px;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: transform 0.15s ease;
}

.emoji-btn:hover {
  transform: scale(1.3);
  background: rgba(0,0,0,0.05);
}

/* ==========================================================================
   ULTIMATE MOBILE RESPONSIVENESS & TOUCH OPTIMIZATION
   ========================================================================== */
@media (max-width: 768px) {
  html, body, .app-container {
    height: 100dvh; /* Dynamic Viewport Height for Mobile Browsers */
    width: 100vw;
    overflow: hidden;
    touch-action: manipulation;
  }

  .app-container {
    border-radius: 0;
    flex-direction: column;
  }

  /* Auth Overlay Mobile Scrollability */
  .auth-overlay {
    padding: 12px;
    align-items: flex-start;
    overflow-y: auto;
  }

  .auth-card {
    padding: 24px 18px;
    max-width: 100%;
    margin: auto 0;
    border-radius: var(--radius-md);
  }

  .auth-header .brand-logo {
    width: 54px;
    height: 54px;
    font-size: 24px;
    margin-bottom: 10px;
  }

  .auth-header h2 {
    font-size: 20px;
  }

  .role-option {
    padding: 10px 8px;
    font-size: 13px;
    min-height: 42px;
  }

  /* Drawer Navigation */
  .sidebar {
    width: 100%;
    height: 100dvh;
    position: absolute;
    inset: 0;
    z-index: 20;
    transform: translateX(0);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

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

  .chat-main {
    width: 100%;
    height: 100dvh;
  }

  .sidebar-header, .chat-main-header {
    padding: 8px 12px;
    height: 60px;
  }

  .sidebar-actions {
    gap: 4px;
  }

  .icon-btn {
    width: 40px;
    height: 40px;
    font-size: 17px;
  }

  .mobile-back-btn {
    display: flex;
    font-size: 20px;
    color: var(--primary);
  }

  .messages-container {
    padding: 12px 10px;
    gap: 10px;
  }

  .message-bubble {
    max-width: 88%;
    font-size: 15px;
    padding: 8px 12px;
  }

  /* Mobile Input Bar & Keyboard Safety */
  .chat-input-bar {
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    gap: 8px;
  }

  .chat-input-wrap textarea {
    font-size: 16px; /* Prevents auto-zoom on iOS Safari */
  }

  .btn-send-msg {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .voice-recorder-bar {
    padding: 8px 12px;
    gap: 10px;
  }

  .emoji-picker-container {
    left: 8px;
    right: 8px;
    bottom: 65px;
    grid-template-columns: repeat(6, 1fr);
  }

  /* Modals Mobile Sizing */
  .modal-box {
    max-width: 96vw;
    padding: 18px 14px;
    border-radius: var(--radius-sm);
  }
}

@media (max-width: 480px) {
  .sidebar-header {
    padding: 6px 10px;
  }
  .partner-details .partner-name {
    font-size: 15px;
  }
  .chat-item {
    padding: 10px 12px;
    gap: 10px;
  }
  .avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
}
