/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #25d366;
  --primary-dark: #1da851;
  --secondary-color: #34b7f1;
  --background-color: #f0f2f5;
  --chat-background: #e5ddd5;
  --sidebar-bg: #ffffff;
  --header-bg: #2a2f32;
  --text-primary: #111b21;
  --text-secondary: #667781;
  --text-light: #8696a0;
  --border-color: #e9edef;
  --message-in: #ffffff;
  --message-out: #d9fdd3;
  --error-color: #f15c6d;
  --success-color: #06d755;
  --warning-color: #ffb52b;
  
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
  
  --transition: all 0.2s ease;
  --animation-bounce: bounce 0.6s ease;
  
  /* Responsive breakpoints */
  --mobile-max: 767px;
  --tablet-min: 768px;
  --desktop-min: 1024px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--background-color);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  margin: 0;
  padding: 0;
  height: 100vh;
  width: 100vw;
  /* Handle safe areas on mobile devices */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Screen Management */
.screen {
  display: none;
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.loading {
  opacity: 0.6;
  pointer-events: none;
}

.text-center {
  text-align: center;
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  min-height: 44px;
  position: relative;
  overflow: hidden;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--sidebar-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--background-color);
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 8px;
  border-radius: 50%;
  background-color: transparent;
  color: var(--text-secondary);
}

.btn-icon:hover:not(:disabled) {
  background-color: var(--background-color);
  color: var(--text-primary);
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
}

input, textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 14px;
  transition: var(--transition);
  background-color: white;
  color: var(--text-primary);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

/* Login Screen */
.login-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.login-header {
  text-align: center;
  margin-bottom: 40px;
  color: white;
}

.login-header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
  font-weight: 700;
}

.login-header p {
  font-size: 1.1em;
  opacity: 0.9;
}

.connection-status {
  margin-top: 15px;
  padding: 8px 12px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  font-size: 0.9em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-indicator {
  font-size: 1.2em;
}

.connection-status.connected .status-indicator {
  color: #4CAF50;
}

.connection-status.error .status-indicator {
  color: #f44336;
}

.login-form {
  background: white;
  padding: 40px;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}

/* Dashboard Layout - Desktop First */
.dashboard-container {
  display: flex;
  height: 100vh;
  background-color: var(--background-color);
  overflow: hidden;
  width: 100vw;
  position: relative;
  max-width: 100%;
}

/* Sidebar - Desktop */
.sidebar {
  width: 350px;
  min-width: 320px;
  max-width: 380px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: relative;
  flex-shrink: 0;
}

/* Chat area - Desktop */
.chat-area {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--chat-background);
  position: relative;
  overflow: hidden;
  min-width: 0; /* Allow flex shrinking */
  max-width: 100%;
}

/* Mobile Layout - Clean and Simple */
@media (max-width: 768px) {
  /* Force proper mobile layout */
  html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: fixed;
    margin: 0;
    padding: 0;
  }
  
  .dashboard-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
  }
  
  /* Mobile Sidebar - Default visible */
  .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1002;
    transform: translateX(0);
    transition: transform 0.3s ease;
    border-right: none;
    max-width: none;
  }
  
  .sidebar.hidden-mobile {
    transform: translateX(-100vw);
  }
  
  /* Mobile Chat Area - Default hidden */
  .chat-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1001;
    transform: translateX(100vw);
    transition: transform 0.3s ease;
    background-color: white;
    overflow: hidden;
  }
  
  .chat-area.active-mobile {
    transform: translateX(0);
  }
  
  /* Dashboard Container Chat State */
  .dashboard-container.chat-active .sidebar {
    transform: translateX(-100vw);
  }
  
  .dashboard-container.chat-active .chat-area {
    transform: translateX(0);
  }
  
  /* Mobile Chat Components Layout */
  .chat-header {
    position: relative;
    flex-shrink: 0;
    height: 60px;
    min-height: 60px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--header-bg);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
  }
  
  .messages-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 8px;
    background-color: var(--chat-background);
    background-image: 
      radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.1) 1px, transparent 1px),
      radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 20px 20px;
  }
  
  .message-input-container {
    position: relative;
    flex-shrink: 0;
    padding: 12px 8px 12px 8px;
    background-color: white;
    border-top: 1px solid var(--border-color);
    min-height: 64px;
    z-index: 100;
    /* Add safe area padding for mobile devices */
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  
  /* Mobile Navigation Buttons */
  .mobile-back-btn {
    display: flex !important;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: 4px;
  }
  
  .mobile-back-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .mobile-menu-btn {
    display: flex !important;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    flex-shrink: 0;
    margin-left: 4px;
  }
  
  .mobile-menu-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  /* Mobile Chat Header Info */
  .chat-header-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
  }
  
  .contact-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
  }
  
  .contact-details {
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }
  
  .contact-details h3 {
    font-size: 16px;
    font-weight: 600;
    color: white;
    margin: 0;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .contact-details p {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  /* Mobile Message Input */
  .message-input {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    min-height: 40px;
    width: 100%;
  }
  
  .text-input-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: flex-end;
    background-color: var(--background-color);
    border-radius: 20px;
    min-height: 40px;
    max-height: 120px;
    width: 100%;
  }
  
  #messageInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 40px 10px 12px;
    resize: none;
    max-height: 100px;
    min-height: 20px;
    font-family: inherit;
    border-radius: 20px;
    font-size: 16px; /* Prevent zoom on iOS */
    outline: none;
    line-height: 1.4;
  }
  
  .emoji-btn {
    position: absolute;
    right: 4px;
    bottom: 2px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: transparent;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Mobile Specific Component Adjustments */
  .conversation-item {
    padding: 16px 20px;
    min-height: 72px;
  }
  
  .conversation-avatar {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
  
  .message {
    max-width: 95%;
  }
  
  .btn-icon {
    width: 44px;
    height: 44px;
  }
  
  .attachment-btn {
    background-color: transparent;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  
  .send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    padding: 6px;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: none;
    cursor: pointer;
  }
  
  /* Ensure chat elements are visible when chat is active */
  .dashboard-container.chat-active .chat-header,
  .dashboard-container.chat-active .messages-container,
  .dashboard-container.chat-active .message-input-container {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  .dashboard-container.chat-active .no-chat-selected {
    display: none !important;
  }
  
  /* Force proper layout in mobile chat mode */
  .chat-area.active-mobile {
    display: flex !important;
    flex-direction: column !important;
  }
  
  .chat-area.active-mobile .chat-header {
    flex-shrink: 0;
  }
  
  .chat-area.active-mobile .messages-container {
    flex: 1;
    overflow-y: auto;
  }
  
  .chat-area.active-mobile .message-input-container {
    flex-shrink: 0;
  }
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--header-bg);
  color: white;
  min-height: 70px;
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 1.3em;
  font-weight: 600;
}

.user-info .app-title {
  font-size: 1.3em;
  font-weight: 600;
  margin-bottom: 2px;
}

.user-info .user-name {
  font-size: 0.85em;
  opacity: 0.8;
  font-weight: 400;
}

/* Sidebar header actions */
.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-header-actions .btn-icon {
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: 50%;
  background-color: transparent;
  color: rgba(255, 255, 255, 0.8);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  position: relative;
  overflow: hidden;
}

.sidebar-header-actions .btn-icon:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.sidebar-header-actions .btn-icon:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Mobile menu button */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5em;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.mobile-menu-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Chat header with mobile back button */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background-color: var(--header-bg);
  color: white;
  border-bottom: 1px solid var(--border-color);
  min-height: 70px;
}

.mobile-back-btn {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5em;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.mobile-back-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.search-container {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-light);
  z-index: 2;
}

#searchInput {
  padding-left: 44px;
  padding-right: 44px;
  border: 1px solid var(--border-color);
  background-color: var(--background-color);
}

.clear-search {
  position: absolute;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-search:hover {
  background-color: var(--border-color);
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
  background-color: white;
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.conversation-item:hover {
  background-color: var(--background-color);
}

.conversation-item.active {
  background-color: #e7f3ff;
  border-right: 4px solid var(--primary-color);
}

.conversation-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  margin-right: 16px;
  flex-shrink: 0;
}

.conversation-info {
  flex: 1;
  min-width: 0;
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.conversation-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-time {
  font-size: 12px;
  color: var(--text-light);
  flex-shrink: 0;
  margin-left: 8px;
}

.conversation-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.conversation-last-message {
  font-size: 14px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.unread-badge {
  background-color: var(--primary-color);
  color: white;
  border-radius: 50%;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
}

.sidebar-footer {
  padding: 15px 20px;
  border-top: 1px solid var(--border-color);
  background-color: var(--sidebar-bg);
  display: flex;
  gap: 10px;
}

.sidebar-footer .btn {
  flex: 1;
}

.no-chat-selected {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: white;
  padding: 40px;
}

.no-chat-content {
  text-align: center;
  color: var(--text-light);
  max-width: 400px;
}

.no-chat-content svg {
  margin-bottom: 24px;
  opacity: 0.5;
}

.no-chat-content h3 {
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 600;
}

.no-chat-content p {
  font-size: 16px;
  line-height: 1.5;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background-color: var(--header-bg);
  color: white;
  border-bottom: 1px solid var(--border-color);
  position: relative;
  min-height: 70px;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 16px;
  min-width: 0;
}

/* Mobile menu button in chat header */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.mobile-menu-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
}

.contact-details {
  flex: 1;
  min-width: 0;
}

.contact-details h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px 0;
  color: white;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-details p {
  font-size: 14px;
  opacity: 0.8;
  margin: 0;
  color: rgba(255, 255, 255, 0.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.back-btn {
  color: white;
  background-color: transparent;
}

.back-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23000000' fill-opacity='0.03'%3E%3Cpath d='M20 20c0-5.5-4.5-10-10-10s-10 4.5-10 10 4.5 10 10 10 10-4.5 10-10zm10 0c0-5.5-4.5-10-10-10s-10 4.5-10 10 4.5 10 10 10 10-4.5 10-10z'/%3E%3C/g%3E%3C/svg%3E");
  min-height: 0; /* Allow proper flex shrinking */
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100%;
  width: 100% !important;
}

.message {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 18px;
  position: relative;
  word-wrap: break-word;
  animation: var(--animation-bounce);
  margin-bottom: 2px;
}

.message.inbound {
  align-self: flex-start;
  background-color: var(--message-in);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.message.outbound {
  align-self: flex-end;
  background-color: var(--message-out);
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.message-body {
  margin-bottom: 4px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.message-media {
  margin-bottom: 8px;
}

.media-item {
  margin-bottom: 8px;
  border-radius: var(--border-radius);
  overflow: hidden;
  max-width: 300px;
}

.media-image {
  width: 100%;
  height: auto;
  cursor: pointer;
  transition: var(--transition);
}

.media-image:hover {
  opacity: 0.9;
}

.media-video {
  width: 100%;
  max-width: 300px;
}

.media-audio {
  width: 100%;
  max-width: 300px;
}

.media-document {
  display: flex;
  align-items: center;
  padding: 12px;
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: var(--border-radius);
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
}

.media-document:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.document-icon {
  margin-right: 10px;
  color: var(--primary-color);
}

.message-time {
  font-size: 11px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.message-status {
  display: flex;
  align-items: center;
}

.status-icon {
  width: 12px;
  height: 12px;
}

/* Message Input */
.message-input-container {
  padding: 16px 20px;
  background-color: white;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.message-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  width: 100%;
}

.text-input-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  background-color: var(--background-color);
  border-radius: 24px;
  min-height: 48px;
  max-height: 120px;
  width: 100%;
}

#messageInput {
  flex: 1;
  border: none;
  background: transparent;
  padding: 14px 50px 14px 20px;
  resize: none;
  max-height: 100px;
  min-height: 20px;
  font-family: inherit;
  border-radius: 24px;
  font-size: 15px;
  line-height: 1.4;
  outline: none;
}

#messageInput:focus {
  box-shadow: none;
  border: none;
}

.emoji-btn {
  position: absolute;
  right: 8px;
  bottom: 6px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.emoji-btn:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.attachment-btn {
  background-color: transparent;
  color: var(--text-secondary);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.attachment-btn:hover {
  background-color: var(--background-color);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 10px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.send-btn:hover {
  background-color: var(--primary-dark);
}

.file-preview {
  margin-bottom: 10px;
  padding: 12px;
  background-color: var(--background-color);
  border-radius: var(--border-radius);
  position: relative;
}

.file-preview-items {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.file-preview-item {
  position: relative;
  background-color: white;
  border-radius: var(--border-radius);
  padding: 8px;
  box-shadow: var(--shadow-sm);
}

.file-preview-image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}

.file-preview-info {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 150px;
}

.file-preview-name {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-files {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background-color: var(--error-color);
  color: white;
  border-radius: 50%;
}

/* Loading States */
.loading-conversations,
.loading-messages {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-4px);
  }
  60% {
    transform: translateY(-2px);
  }
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  animation: fadeIn 0.3s ease;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  background-color: white;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 20px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  font-size: 28px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body img,
.modal-body video {
  width: 100%;
  height: auto;
  max-width: 80vw;
  max-height: 80vh;
  object-fit: contain;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1050;
}

.toast {
  background-color: var(--text-primary);
  color: white;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow-lg);
  max-width: 300px;
  animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s;
  animation-fill-mode: forwards;
}

.toast.success {
  background-color: var(--success-color);
}

.toast.error {
  background-color: var(--error-color);
}

.toast.warning {
  background-color: var(--warning-color);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* Error States */
.error-message {
  color: var(--error-color);
  font-size: 14px;
  margin-top: 8px;
  text-align: center;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Desktop Responsive - Clean desktop styles */
@media (min-width: 769px) {
  .mobile-back-btn,
  .mobile-menu-btn {
    display: none !important;
  }
  
  .sidebar {
    position: relative !important;
    transform: none !important;
    z-index: auto !important;
    width: 350px;
    min-width: 320px;
    max-width: 380px;
    flex-shrink: 0;
  }
  
  .chat-area {
    position: relative !important;
    transform: none !important;
    z-index: auto !important;
    flex: 1;
    width: 100%;
    max-width: none;
  }
  
  /* Ensure proper desktop chat header layout */
  .chat-header {
    padding: 16px 20px;
    min-height: 70px;
    width: 100%;
  }
  
  .chat-header-info {
    margin-left: 0;
    gap: 16px;
  }
  
  /* Desktop messages container - utilize full width */
  .messages-container {
    width: 100%;
    max-width: none;
    padding: 20px;
  }
  
  .messages-list {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }
  
  /* Desktop message styling for better width utilization */
  .message {
    max-width: 70%;
    margin-bottom: 12px;
  }
  
  .message.outbound {
    margin-left: auto;
    margin-right: 0;
  }
  
  .message.inbound {
    margin-left: 0;
    margin-right: auto;
  }
  
  /* Desktop message input improvements */
  .message-input-container {
    padding: 16px 20px;
    width: 100%;
    max-width: none;
    margin: 0;
  }
  
  .message-input {
    gap: 8px;
    max-width: 100%;
    width: 100%;
  }
  
  .text-input-container {
    min-height: 48px;
    flex: 1;
    width: 100%;
  }
  
  #messageInput {
    padding: 14px 50px 14px 20px;
    font-size: 15px;
    width: 100%;
  }
  
  .attachment-btn {
    width: 44px;
    height: 44px;
  }
  
  .send-btn {
    width: 44px;
    height: 44px;
    padding: 10px;
  }
  
  /* No chat selected state for desktop */
  .no-chat-selected {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Scrollbar Styling */
.conversations-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
  width: 6px;
}

.conversations-list::-webkit-scrollbar-track,
.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.conversations-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 3px;
}

.conversations-list::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-light);
}

/* Focus Styles for Accessibility */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Print Styles */
@media print {
  .sidebar,
  .message-input-container,
  .chat-header {
    display: none;
  }
  
  .chat-area {
    width: 100%;
  }
  
  .message {
    break-inside: avoid;
  }
}

/* Connection Status Indicator */
#connectionStatus {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

#connectionStatus.connected {
    border-color: #28a745;
    background: #28a74520;
    color: #28a745;
}

#connectionStatus.error {
    border-color: #dc3545;
    background: #dc354520;
    color: #dc3545;
}

#connectionStatus.warning {
    border-color: #ffc107;
    background: #ffc10720;
    color: #856404;
}

#statusIndicator {
    font-size: 14px;
}

#statusText {
    white-space: nowrap;
}
