/* Chat Themes CSS - Light and Dark Theme Support */
:root {
  /* Primary Colors */
  --primary-color: #3b7aad;
  --summary-color: #4677ac;
  --primary-hover: #9fc9f5;
  --primary-rgb: 0, 123, 255;
  
  /* Danger Colors */
  --danger-rgb: 220, 53, 69;
  
  /* Success Colors */
  --success-rgb: 40, 167, 69;
  
  /* Text Secondary Colors */
  --text-secondary-rgb: 108, 117, 125;
  
  /* Background Colors */
  --background-color: #f8f9fa;
  --surface-color: #ffffff;
  --message-user-color: #dddddd;
  --message-self-color: #14578f;
  --sidebar-background: #ffffff;
  --chat-bg: #f8f9fa;
  
  /* Text Colors */
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  --header-text: #ffffff;
  --header-bg: var(--summary-color);
  
  /* Border Colors */
  --border-color: #dee2e6;
  --sidebar-border: #dee2e6;
  
  /* State Colors */
  --danger-color: #dc3545;
  --danger-hover: #c82333;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --info-color: #17a2b8;
  
  /* Shadow Colors */
  --shadow-light: rgba(0, 0, 0, 0.1);
  --shadow-medium: rgba(0, 0, 0, 0.15);
  --header-shadow: rgba(0, 123, 255, 0.25);
  
  /* Interactive Elements */
  --button-bg: rgba(0, 123, 255, 0.1);
  --button-border: rgba(0, 123, 255, 0.3);
  --button-text: var(--text-primary);
  --button-hover-bg: var(--primary-color);
  --button-hover-border: var(--primary-color);
  
  /* Chat Specific */
  --user-item-hover: #f8f9fa;
  --user-item-active: #e3f2fd;
  --unread-badge-bg: linear-gradient(135deg, #dc3545, #c82333);
  
  /* Mobile overlay */
  --overlay-bg: rgba(0, 0, 0, 0.4);
}

/* Dark Theme Variables */
[data-theme="dark"] {
  --primary-color: #3b7aad;
  --primary-hover: #2762a1;
  --primary-rgb: 77, 171, 247;
  --danger-rgb: 255, 107, 107;
  --success-rgb: 81, 207, 102;
  --text-secondary-rgb: 189, 195, 197;
  --background-color: #1a1a1a;
  --surface-color: #2d2d2d;
  --message-user-color: #2d2d2d;
  --message-self-color: #07477a;
  --sidebar-background: #2d2d2d;
  --chat-bg: #1a1a1a;
  --text-primary: #ffffff;
  --text-secondary: #bdc3c7;
  --text-muted: #95a5a6;
  --header-text: #ffffff;
  --header-bg: var(--summary-color);
  --border-color: #404040;
  --sidebar-border: #404040;
  --danger-color: #ff6b6b;
  --danger-hover: #ee5a52;
  --success-color: #51cf66;
  --warning-color: #ffd43b;
  --info-color: #74c0fc;
  --shadow-light: rgba(0, 0, 0, 0.3);
  --shadow-medium: rgba(0, 0, 0, 0.5);
  --header-shadow: rgba(0, 0, 0, 0.3);
  --button-bg: rgba(255, 255, 255, 0.1);
  --button-border: rgba(255, 255, 255, 0.2);
  --button-text: #ffffff;
  --button-hover-bg: rgba(255, 107, 107, 0.8);
  --button-hover-border: rgba(255, 107, 107, 0.8);
  --user-item-hover: #3a3a3a;
  --user-item-active: #404040;
  --unread-badge-bg: linear-gradient(135deg, #ff6b6b, #ee5a52);
  --overlay-bg: rgba(0, 0, 0, 0.6);
}

/* Dark Theme Message Enhancements */
[data-theme="dark"] .message-send {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .message-send:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .message-rescive,
[data-theme="dark"] .message-from-user {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .message-rescive:hover,
[data-theme="dark"] .message-from-user:hover {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4), 0 1px 5px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .other-message .message-bubble {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .other-message .message-bubble:hover {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4), 0 1px 5px rgba(0, 0, 0, 0.3);
}

/* Улучшенные хвостики для темной темы */

/* Force layout recalculation on theme change for mobile */
@media (max-width: 768px) {
  [data-theme="dark"] .simple-chat-container,
  .simple-chat-container {
    height: 100svh;
    height: 100dvh;
    height: 100vh;
  }
  
  [data-theme="dark"] .simple-chat-input-area,
  .simple-chat-input-area {
    position: sticky;
    bottom: 0;
  }

[data-theme="dark"] .chat-input-area {
  background-color: var(--surface-color);
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.3);
}
}

/* Base Layout */
.chat-layout {
  height: 100vh;
  height: 100dvh;
  display: flex;
  overflow: hidden;
  background-color: var(--background-color);
}

.container {
  height: 100vh;
  height: 100dvh;
  background: var(--background-color);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  max-width: none;
  position: relative;
  overflow: hidden;
}

.chat-wrapper {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Desktop */
@media (min-width: 768px) {
  .chat-wrapper {
    max-width: 800px;
    margin: 0 auto;
    box-shadow: 0 0 20px var(--shadow-medium);
    border-left: 1px solid var(--sidebar-border);
    border-right: 1px solid var(--sidebar-border);
  }
}

@media (min-width: 1200px) {
  .container {
    max-width: none;
  }
}

/* Chat Sidebar */
.chat-sidebar {
  width: 430px;
  min-width: 430px;
  border-right: 1px solid var(--sidebar-border);
  background: var(--sidebar-background);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 2px 0 8px var(--shadow-light);
}

.chat-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--chat-bg);
}

/* Header */
.chat-header {
  background: var(--header-bg);
  color: var(--header-text);
  box-shadow: 0 2px 4px var(--header-shadow);
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-avatar {
  width: 40px;
  height: 40px;
  font-weight: bold;
  font-size: 1rem;
  background: var(--danger-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-user-name {
  color: var(--header-text);
  font-weight: bold;
}

.header-user-status {
  color: var(--text-primary);
}

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

.header-actions .btn-link {
  color: var(--header-text);
  text-decoration: none;
  border: none;
  background: transparent;
  transition: all 0.2s ease;
}

.header-actions .btn-link:hover {
  color: rgba(255, 255, 255, 0.8);
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Logout Button */
.logout-button {
  background: var(--button-bg);
  border: 1px solid var(--button-border);
  color: var(--button-text);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 500;
}

.logout-button:hover {
  background: var(--button-hover-bg);
  border-color: var(--button-hover-border);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px var(--shadow-medium);
}

.logout-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px var(--shadow-medium);
}

/* Header Buttons */
.header-buttons-container {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.header-action-btn {
  background: var(--button-bg);
  border: 1px solid var(--button-border);
  color: var(--header-text);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
}

.header-action-btn:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-medium);
}

.header-action-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px var(--shadow-medium);
}

.header-close-btn {
  background: var(--danger-color);
  border-color: var(--danger-color);
}

.header-close-btn:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.btn-text {
  font-size: 0.8125rem;
}

/* Burger Button */
.burger-button {
  display: none;
  color: var(--header-text);
  background: transparent;
  border: none;
  font-size: 1.25rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  position: relative;
}

.burger-button.has-unread {
  animation: burgerPulse 2s infinite;
}

@keyframes burgerPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(var(--danger-rgb, 220, 53, 69), 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(var(--danger-rgb, 220, 53, 69), 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(var(--danger-rgb, 220, 53, 69), 0);
  }
}

.burger-unread-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--unread-badge-bg);
  color: white;
  border-radius: 50%;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: bold;
  box-shadow: 0 2px 4px var(--shadow-medium);
  z-index: 10;
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: 1040;
}

/* Theme Toggle */
.theme-toggle {
  background: var(--button-bg);
  border: 1px solid var(--button-border);
  color: var(--button-text);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  margin-right: 8px;
}

.theme-toggle:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px var(--shadow-medium);
}

.theme-toggle:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px var(--shadow-medium);
}

/* Mobile Responsive */
@media (max-width: 991.98px) {
  .chat-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1050;
    width: 100%;
    min-width: 100%;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 2px 0 16px var(--shadow-medium);
  }

  .chat-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.show {
    display: block;
  }

  .burger-button {
    display: inline-block;
    position: relative;
  }

  .chat-content {
    width: 100%;
  }

  .logout-button,
  .theme-toggle {
    padding: 6px 8px;
    font-size: 0.8rem;
  }

  .logout-text,
  .theme-toggle-text {
    display: none;
  }
  
  .header-buttons-container {
    gap: 0.375rem;
  }
  
  .header-action-btn {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
    min-width: 2.25rem;
    height: 2.25rem;
  }
  
  .header-action-btn i {
    font-size: 1rem;
  }
  
  .btn-text {
    display: none;
  }
}

/* Scrollbar */
.chat-sidebar::-webkit-scrollbar {
  width: 6px;
}

.chat-sidebar::-webkit-scrollbar-track {
  background: var(--background-color);
}

.chat-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.chat-sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Loading States */
.loading-shimmer {
  background: linear-gradient(90deg, 
    var(--surface-color) 25%, 
    var(--user-item-hover) 50%, 
    var(--surface-color) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Status Indicators */
.status-online {
  color: var(--success-color);
}

.status-offline {
  color: var(--text-muted);
}

.status-away {
  color: var(--warning-color);
}

/* Utility Classes */
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }
.bg-primary { background-color: var(--primary-color) !important; }
.bg-surface { background-color: var(--surface-color) !important; }
.border-primary { border-color: var(--primary-color) !important; }

/* Focus States */
.logout-button:focus,
.theme-toggle:focus,
.burger-button:focus,
.header-action-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --text-secondary: #000000;
  }
  
  [data-theme="dark"] {
    --border-color: #ffffff;
    --text-secondary: #ffffff;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .burger-button.has-unread,
  .logout-button,
  .theme-toggle,
  .header-action-btn,
  .loading-shimmer {
    animation: none;
    transition: none;
  }
}

/* User List */
.pulse-animation {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: var(--danger-color);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(var(--danger-rgb, 220, 53, 69), 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(var(--danger-rgb, 220, 53, 69), 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(var(--danger-rgb, 220, 53, 69), 0);
  }
}

/* User List Card */
.user-list-card {
  background-color: var(--sidebar-background);
  border: 1px solid var(--sidebar-border);
  border-radius: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.user-list-header {
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: none;
  padding: 1rem;
  flex-shrink: 0;
  height: 73px;
}

.user-list-header h5 {
  margin: 0;
  font-weight: 600;
  display: flex;
  align-items: center;
}

.user-list-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  background-color: var(--background-color);
}

.user-list-item {
  background-color: var(--sidebar-background);
  border-bottom: 1px solid var(--sidebar-border);
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.user-list-item:hover {
  background-color: var(--user-item-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--shadow-light);
}

.user-list-item.selected {
  background: var(--user-item-active);
  border-bottom: 1px solid var(--sidebar-border);
}

.user-list-item.selected:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 12px var(--shadow-medium);
}

.user-list-item.selected::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--success-color);
}

.user-list-item.loading {
  opacity: 0.7;
  pointer-events: none;
  cursor: not-allowed;
}

/* Loading Indicators */
.loading-indicator {
  position: absolute;
  top: 50%;
  right: 60px;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  z-index: 10;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-muted);
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* User Avatar */
.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: bold;
  margin-right: 12px;
  flex-shrink: 0;
  background: var(--surface-color);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.user-avatar.client {
  background: var(--primary-color);
  color: white;
}

/* User Info */
.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0 0 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-detail {
  color: var(--text-secondary);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.user-detail i {
  width: 12px;
  text-align: center;
}

.user-detail .phone-link {
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 4px;
  padding: 2px 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.user-detail .phone-link:hover {
  color: var(--success-color);
  background-color: rgba(var(--success-rgb, 40, 167, 69), 0.1);
  text-decoration: none;
}

.user-detail .phone-link:active {
  transform: scale(0.95);
}

/* User Actions */
.user-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.unread-counter {
  position: relative;
}

.unread-badge {
  background: var(--unread-badge-bg);
  color: white;
  border-radius: 12px;
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 2px;
  box-shadow: 0 2px 4px var(--shadow-medium);
}

.unread-check {
  color: var(--success-color);
  font-size: 1rem;
}

.dropdown-toggle-btn,
.menu-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
}

.dropdown-toggle-btn:hover,
.menu-toggle-btn:hover {
  background-color: rgba(var(--text-secondary-rgb, 108, 117, 125), 0.1);
  color: var(--text-primary);
}

/* User Menu */
.user-menu-buttons {
  position: absolute;
  top: 50%;
  right: 40px;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 4px 12px var(--shadow-medium);
  z-index: 100;
  animation: menuSlideIn 0.2s ease-out;
}

@keyframes menuSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50%) translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
}

.user-menu-btn {
  background: transparent;
  border: none;
  padding: 6px;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary);
}

.user-menu-btn:hover {
  transform: scale(1.1);
  color: var(--text-primary);
}

.user-menu-btn.info:hover {
  background-color: rgba(var(--info-color, 23, 162, 184), 0.1);
  color: var(--info-color);
}

.user-menu-btn.edit:hover {
  background-color: rgba(var(--primary-rgb, 0, 123, 255), 0.1);
  color: var(--primary-color);
}

.user-menu-btn.delete:hover {
  background-color: rgba(var(--danger-rgb, 220, 53, 69), 0.1);
  color: var(--danger-color);
}

/* Call Modal */
.call-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--overlay-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.call-modal {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 16px 32px var(--shadow-medium);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.call-modal .phone-icon {
  font-size: 3rem;
  color: var(--success-color);
  margin-bottom: 1rem;
  animation: pulseIcon 2s infinite;
}

@keyframes pulseIcon {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.call-modal .phone-number {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 1rem;
  word-break: break-all;
}

.call-modal .call-instructions {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.call-modal .modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.call-modal .btn-call {
  background: var(--success-color);
  border: none;
  color: white;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.call-modal .btn-call:hover {
  background: var(--success-color);
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--success-rgb, 40, 167, 69), 0.3);
}

.call-modal .btn-cancel {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.75rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.call-modal .btn-cancel:hover {
  background-color: rgba(var(--text-secondary-rgb, 108, 117, 125), 0.1);
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Mobile Responsive for User List */
@media (max-width: 768px) {
  .user-avatar {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .user-name {
    font-size: 0.9rem;
  }

  .user-detail {
    font-size: 0.7rem;
  }

  .unread-badge {
    font-size: 0.65rem;
    padding: 3px 6px;
  }

  .dropdown-menu-modern {
    min-width: 160px;
    max-width: 180px;
    font-size: 0.85rem;
  }

  .dropdown-item {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .user-list-header {
    padding: 0.75rem;
  }

  .user-list-header h5 {
    font-size: 0.95rem;
  }

  .user-menu-buttons {
    right: 35px;
    padding: 3px;
  }

  .user-menu-btn {
    width: 26px;
    height: 26px;
    padding: 5px;
  }

  .menu-toggle-btn {
    width: 30px;
    height: 30px;
    padding: 5px;
  }
}

/* Registration Page */
.registration-container {
  min-height: 100vh;
  background: var(--background-color);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

.registration-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(0,0,0,0.03)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
  pointer-events: none;
}

.registration-card {
  background: var(--surface-color);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  box-shadow: 0 20px 40px var(--shadow-medium);
  padding: 40px;
  width: 100%;
  max-width: 450px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.registration-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: var(--primary-color);
}

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

.registration-header .logo-section {
  margin-bottom: 20px;
}

.registration-header .app-logo {
  width: 60px;
  height: 60px;
  background: var(--primary-color);
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 15px;
  box-shadow: 0 10px 30px var(--shadow-medium);
}

.registration-header .app-logo i {
  color: white;
  font-size: 24px;
}

.registration-header .app-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 5px 0;
  background: var(--primary-color);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.registration-header .app-version {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 20px 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.registration-header h2 {
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 20px;
}

.registration-header p {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0;
}

/* Form Controls */
.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-control {
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 15px 20px;
  font-size: 16px;
  transition: all 0.3s ease;
  background: var(--surface-color);
  color: var(--text-primary);
}

.form-control::placeholder {
  color: var(--text-secondary);
  opacity: 1;
}

.form-control:focus {
  border-color: var(--primary-color);
  background: var(--surface-color);
  box-shadow: 0 0 0 0.2rem rgba(var(--primary-rgb, 0, 123, 255), 0.25);
  color: var(--text-primary);
}

.form-control.is-invalid {
  border-color: var(--danger-color);
  background: var(--surface-color);
  color: var(--text-primary);
}

.input-group {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  z-index: 10;
}

.input-with-icon {
  padding-left: 45px;
}

/* Registration Buttons */
.btn-registration {
  background: var(--primary-color);
  border: none;
  border-radius: 12px;
  padding: 15px 30px;
  font-size: 16px;
  font-weight: 600;
  color: white;
  width: 100%;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.btn-registration:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px var(--shadow-medium);
}

.btn-registration:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-loading {
  position: relative;
  color: transparent;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid #ffffff;
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Alerts */
.alert {
  border-radius: 12px;
  border: none;
  padding: 15px 20px;
  margin-bottom: 20px;
  font-weight: 500;
}

.alert-danger {
  background: var(--danger-color);
  color: white;
}

.alert-success {
  background: var(--success-color);
  color: white;
}

.alert-info {
  background: var(--info-color);
  color: white;
}

/* Phone Display */
.phone-display {
  background: var(--background-color);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 15px 20px;
  margin-bottom: 20px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.code-input {
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  letter-spacing: 8px;
  text-transform: uppercase;
}

.code-input::placeholder {
  letter-spacing: normal;
  text-transform: none;
  font-weight: normal;
  color: var(--text-secondary);
}

/* Resend Link */
.resend-code {
  text-align: center;
  margin-top: 15px;
}

.resend-link {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.3s ease;
}

.resend-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.resend-link.disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  text-decoration: none;
}

/* Registration Mobile */
.remember-me {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.remember-me input[type="checkbox"] {
  margin-right: 10px;
  width: 18px;
  height: 18px;
  accent-color: var(--primary-color);
}

.remember-me label {
  margin: 0;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}

/* Timer */
.timer {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 10px;
}

/* Step Indicator */
.step-indicator {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
}

.step {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--background-color);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin: 0 10px;
  position: relative;
  transition: all 0.3s ease;
}

.step.active {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 5px 15px var(--shadow-medium);
}

.step.completed {
  background: var(--success-color);
  color: white;
}

.step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  width: 30px;
  height: 2px;
  background: var(--background-color);
  transform: translateY(-50%);
}

.step.completed:not(:last-child)::after {
  background: var(--success-color);
}

/* Validation Messages */
.validation-message {
  color: var(--danger-color);
  font-size: 14px;
  margin-top: 5px;
  display: none;
}

.validation-message.show {
  display: block;
}

/* Success Animation */
.success-animation {
  text-align: center;
  padding: 20px 0;
}

.success-icon {
  font-size: 80px;
  color: var(--success-color);
  margin-bottom: 20px;
  animation: bounceIn 0.6s ease-out;
}

@keyframes bounceIn {
  0% { transform: scale(0); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Registration Animations */
.fade-in {
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 576px) {
  .registration-container {
    padding: 10px;
  }

  .registration-card {
    padding: 30px 20px;
    margin: 0;
  }

  .registration-header h2 {
    font-size: 24px;
  }
}

/* Chat Messages */
.chat-date {
  border-radius: 20px;
  padding: 5px;
  margin: 5px;
  width: max-content;
  height: auto;
  word-wrap: break-word;
  background: var(--surface-color);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

/* User Info Panel */
.user-info-panel {
  width: 400px;
  background-color: var(--surface-color);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  transition: transform 0.3s ease, width 0.3s ease;
  z-index: 10;
}

.user-info-header {
  padding: 2rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--background-color);
  position: relative;
}

.user-info-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: bold;
  margin: 0 auto 1rem;
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.user-info-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.user-info-role {
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  background-color: rgba(var(--primary-rgb), 0.1);
  border-radius: 20px;
  color: var(--primary-color);
  font-weight: 500;
}

.user-info-role.phone-link {
  color: var(--primary-color);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.user-info-role.phone-link:hover {
  color: var(--success-color);
  background-color: rgba(var(--success-rgb, 40, 167, 69), 0.15);
  border-color: rgba(var(--success-rgb, 40, 167, 69), 0.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px var(--shadow-light);
}

.user-info-role.phone-link:active {
  transform: translateY(0);
  box-shadow: none;
}

.user-info-role.phone-link i {
  transition: transform 0.2s ease;
}

.user-info-role.phone-link:hover i {
  transform: scale(1.1);
}

.user-info-body {
  padding: 1.5rem;
  flex: 1;
}

.user-info-section {
  margin-bottom: 1.5rem;
}

.user-info-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.user-info-value {
  font-size: 1rem;
  color: var(--text-primary);
  word-break: break-word;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  background-color: var(--background-color);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.user-info-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  line-height: 1;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.user-info-close-btn:hover {
  background-color: rgba(var(--text-secondary-rgb), 0.1);
  color: var(--text-primary);
}

.user-info-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1055;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.user-info-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.chat-main-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--chat-bg);
  min-width: 0;
}

.chat-area-with-info {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.chat-messages-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

@media (max-width: 991.98px) {
  .user-info-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1060;
    width: 85%;
    max-width: 350px;
    box-shadow: -4px 0 20px var(--shadow-medium);
    transform: translateX(100%);
  }

  .user-info-panel.open {
    transform: translateX(0);
  }

  .user-info-close-btn {
    display: block;
  }
}

@media (min-width: 992px) {
  .user-info-panel {
    transform: translateX(0) !important;
  }

  .user-info-backdrop {
    display: none;
  }
}

/* File Attach */
#attach-file {
  height: 100%;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  display: none;
}

.preview-container {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  display: none;
  background: var(--surface-color);
  color: var(--text-primary);
}

.preview-item {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--background-color);
}

.preview-image {
  max-width: 100px;
  max-height: 100px;
  margin-right: 10px;
  border-radius: 4px;
  border: 1px solid var(--text-muted);
}

.preview-file {
  display: flex;
  align-items: center;
  flex-grow: 1;
  color: var(--text-primary);
}

.preview-file i {
  margin-right: 10px;
  font-size: 24px;
  color: var(--text-secondary);
}

.remove-file {
  margin-left: 10px;
  cursor: pointer;
  color: var(--danger-color);
  padding: 5px;
  transition: color 0.2s;
}

.remove-file:hover {
  color: var(--danger-hover);
}

.preview-item span {
  color: var(--text-primary);
}

/* Message Bubbles */
.mes {
  margin-bottom: 1rem;
  max-width: 70%;
  word-wrap: break-word;
  position: relative;
  animation: messageSlideIn 0.3s ease-out;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.mes:hover {
  transform: translateY(-1px);
}

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

.message-send {
  background: linear-gradient(135deg, var(--message-self-color) 0%, var(--primary-color) 100%);
  border-radius: 18px 18px 18px 4px;
  padding: 0.875rem 1rem;
  position: relative;
  color: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  line-height: 1.5;
  font-weight: 400;
}

.message-send:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.message-rescive {
  align-self: flex-start;
  background-color: var(--surface-color);
  border-radius: 18px 18px 18px 4px;
  padding: 0.875rem 1rem;
  position: relative;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
  line-height: 1.5;
  font-weight: 400;
}

.message-rescive:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.05);
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.message-from-user {
  align-self: flex-start;
  background: linear-gradient(135deg, var(--message-user-color) 0%, var(--background-color) 100%);
  border-radius: 18px 18px 18px 4px;
  padding: 0.875rem 1rem;
  position: relative;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
  line-height: 1.5;
  font-weight: 400;
}

.message-from-user:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.05);
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.message-send-file,
.message-rescive-file,
.message-from-user-file {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin-top: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: block;
}

.message-send-file:hover,
.message-rescive-file:hover,
.message-from-user-file:hover {
  opacity: 0.9;
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.message-text {
  white-space: pre-line;
  line-height: 1.6;
  font-size: 0.9375rem;
  letter-spacing: 0.01em;
}

.message-text a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.5);
  transition: text-decoration-color 0.2s ease;
}

.message-send .message-text a {
  color: rgba(255, 255, 255, 0.95);
  text-decoration-color: rgba(255, 255, 255, 0.6);
}

.message-send .message-text a:hover {
  text-decoration-color: rgba(255, 255, 255, 0.9);
}

.message-rescive .message-text a,
.message-from-user .message-text a {
  color: var(--primary-color);
  text-decoration-color: rgba(var(--primary-rgb, 0, 123, 255), 0.4);
}

.message-rescive .message-text a:hover,
.message-from-user .message-text a:hover {
  text-decoration-color: var(--primary-color);
}

/* Chat Container */
.chat-messages-container {
  padding: 1rem;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background-color: var(--chat-bg);
}

/* Scroll to Bottom Button */
.scroll-to-bottom-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow-medium);
  transition: all 0.3s ease;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scroll-to-bottom-btn:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--shadow-medium);
}

.scroll-to-bottom-btn.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
}

/* Chat Container Positioning */
.chat-container {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.messages-area {
  flex: 1;
  overflow-y: auto;
  /* padding: 1rem; */
  display: flex;
  flex-direction: column;
  background-color: var(--chat-bg);
  position: relative;
  gap: 0.5rem;
}

/* Enhanced Input Group */
.enhanced-input-group {
  border: 1.5px solid var(--border-color);
  border-radius: 24px;
  background-color: var(--background-color);
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.enhanced-input-group:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 0, 123, 255), 0.12), 
              0 4px 16px rgba(var(--primary-rgb, 0, 123, 255), 0.15),
              0 2px 4px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.message-input-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: transparent;
  min-height: 44px;
}

.message-textarea {
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 12px 16px 8px 16px;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  min-height: 24px;
  max-height: 120px;
  overflow-y: auto;
  border-radius: 0;
  transition: all 0.2s ease;
  font-family: inherit;
}

.message-textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

.message-textarea:focus {
  background-color: transparent;
  box-shadow: none;
  border-radius: 0;
  margin: 0;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 12px 8px 16px;
  background-color: transparent;
  gap: 8px;
}

.character-count {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.7;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.attach-button {
  border: none;
  background-color: transparent;
  color: var(--text-secondary);
  padding: 10px 14px;
  border-radius: 50%;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px;
}

.attach-button:hover {
  background-color: rgba(var(--text-secondary-rgb, 108, 117, 125), 0.12);
  color: var(--primary-color);
  transform: scale(1.05);
}

.attach-button:active {
  transform: scale(0.95);
}

.send-button {
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  border: none;
  color: white;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb, 0, 123, 255), 0.3);
  margin: 2px;
}

.send-button:hover:not(:disabled) {
  transform: scale(1.08) translateY(-1px);
  box-shadow: 0 6px 16px rgba(var(--primary-rgb, 0, 123, 255), 0.4);
  background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-color) 100%);
}

.send-button:active:not(:disabled) {
  transform: scale(1.0) translateY(0);
}

.send-button:disabled {
  background: var(--text-muted);
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.input-group-prepend {
  display: flex;
  align-items: center;
  padding: 0;
  margin: 0;
}

/* Send Button Animation */
.send-button.has-content {
  animation: pulse 2s infinite;
}

/* File Preview Styles */
.minimal-file-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
  padding: 0;
}

.minimal-file-chip {
  display: inline-flex;
  align-items: center;
  background-color: rgba(var(--primary-rgb, 0, 123, 255), 0.1);
  border: 1px solid rgba(var(--primary-rgb, 0, 123, 255), 0.3);
  border-radius: 12px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--primary-color);
  transition: all 0.2s ease;
}

.minimal-file-chip:hover {
  background-color: rgba(var(--primary-rgb, 0, 123, 255), 0.2);
  border-color: var(--primary-color);
}

.minimal-remove {
  background: none;
  border: none;
  color: var(--danger-color);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  margin-left: 2px;
  padding: 0;
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.minimal-remove:hover {
  background-color: rgba(220, 53, 69, 0.1);
  color: var(--danger-hover);
}

.compact-file-preview {
  margin: 8px 0;
  padding: 0;
  display: flex;
  align-items: center;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  transition: all 0.2s ease;
}

.compact-file-preview:hover {
  background-color: var(--background-color);
  border-color: var(--primary-color);
}

.compact-files-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.compact-file-item {
  position: relative;
  display: inline-block;
}

.compact-image-preview {
  position: relative;
  display: inline-block;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border-color);
  transition: all 0.2s ease;
}

.compact-image-preview:hover {
  border-color: var(--primary-color);
  transform: scale(1.02);
}

.compact-thumbnail {
  width: 60px;
  height: 60px;
  object-fit: cover;
  display: block;
}

/* Video preview styles */
.compact-video-preview {
  position: relative;
  display: inline-block;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border-color);
  transition: all 0.2s ease;
}

.compact-video-preview:hover {
  border-color: var(--primary-color);
  transform: scale(1.02);
}

.compact-video-thumbnail {
  width: 60px;
  height: 60px;
  object-fit: cover;
  display: block;
  background-color: #000;
}

.compact-video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.compact-video-play-icon {
  color: white;
  font-size: 20px;
  opacity: 0.9;
}

.compact-file-icon {
  color: var(--primary-color);
  font-size: 16px;
  margin-right: 8px;
  flex-shrink: 0;
}

.compact-file-name {
  color: var(--text-primary);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 8px;
}

.compact-remove-btn {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: var(--danger-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
  box-shadow: 0 2px 4px var(--shadow-medium);
}

.compact-remove-btn:hover {
  background-color: var(--danger-hover);
  transform: scale(1.1);
}

.compact-file-item.loaded {
  animation: slideIn 0.3s ease-out;
}

.compact-file-preview:empty::after {
  content: "Нет прикрепленных файлов";
  color: var(--text-secondary);
  font-style: italic;
  font-size: 12px;
}

/* Simple Chat Component Styles */
.simple-chat-container {
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  display: flex;
  flex-direction: column;
  background-color: var(--chat-bg);
  color: var(--text-primary);
  overflow: hidden; /* Prevent scrolling issues */
  position: relative;
}

/* Fix for mobile browsers that don't support dvh */
@supports not (height: 100dvh) {
  .simple-chat-container {
    height: 100vh;
    height: -webkit-fill-available;
  }
}

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

.message {
  display: flex;
  margin-bottom: 0.75rem;
  animation: messageSlideIn 0.3s ease-out;
  transition: transform 0.2s ease;
}

.message:hover {
  transform: translateY(-1px);
}

.message.own-message {
  justify-content: flex-end;
}

.message.other-message {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 70%;
  padding: 0.875rem 1rem;
  border-radius: 20px;
  position: relative;
  line-height: 1.5;
  font-weight: 400;
  word-wrap: break-word;
  transition: all 0.2s ease;
}

.own-message .message-bubble {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--message-self-color) 100%);
  color: white;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
}

.own-message .message-bubble:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.1);
}

.other-message .message-bubble {
  background: var(--surface-color);
  color: var(--text-primary);
  border-radius: 18px 18px 18px 4px;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
}

.other-message .message-bubble:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.05);
  border-color: var(--primary-color);
}

.message-files {
  margin-top: 0.5rem;
}

.message-image {
  max-width: 250px;
  max-height: 250px;
  border-radius: 12px;
  margin-top: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: block;
}

.message-image:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.file-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--background-color);
  border-radius: 10px;
  margin-top: 0.5rem;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
  font-size: 0.875rem;
}

.file-link:hover {
  background: var(--user-item-hover);
  border-color: var(--primary-color);
  transform: translateX(2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.file-link:active {
  transform: translateX(1px);
}

.message-time {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  text-align: right;
  margin-top: 6px;
  opacity: 0.7;
  font-weight: 400;
  letter-spacing: 0.02em;
  transition: opacity 0.2s ease;
}

.mes:hover .message-time,
.message:hover .message-time {
  opacity: 1;
}

.message-send .message-time {
  color: rgba(255, 255, 255, 0.85);
}

.message-rescive .message-time,
.message-from-user .message-time {
  color: var(--text-secondary);
}

.no-messages {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  text-align: center;
}

.no-messages i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Simple Chat Input Area */
.chat-input-area {
  padding: 1rem 1.25rem;
  background-color: var(--surface-color);
  flex-shrink: 0;
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(10px);
}

/* Simple Chat Input Area - Mobile Fix */
.simple-chat-input-area {
  padding: 0.75rem;
  background-color: var(--surface-color);
  flex-shrink: 0;
  border-top: 1px solid var(--border-color);
  position: relative;
  z-index: 100;
  /* Ensure it stays at bottom */
  margin-top: auto;
}

/* Fix for iOS Safari and other mobile browsers */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .simple-chat-input-area {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }
}

/* Message Upload Progress Bar */
.message-upload-progress-container {
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--background-color);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-upload-progress-bar {
  width: 100%;
  height: 6px;
  background-color: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.5rem;
  position: relative;
}

.message-upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), rgba(var(--primary-rgb, 0, 123, 255), 0.8));
  border-radius: 3px;
  transition: width 0.3s ease-out;
  position: relative;
  overflow: hidden;
}

.message-upload-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.message-upload-progress-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
  font-weight: 500;
}
  
.file-preview {
  margin-bottom: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--background-color);
  border-radius: 8px;
  max-width: 200px;
  border: 1px solid var(--border-color);
}

.file-item img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
}

.file-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background-color);
  border-radius: 4px;
  color: var(--primary-color);
}

.file-name {
  flex: 1;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-group {
  flex: 1;
  display: flex;
  background: var(--surface-color);
  border: 2px solid var(--border-color);
  border-radius: 25px;
  overflow: hidden;
  transition: border-color 0.3s ease;
}

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

.message-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 14px;
  resize: none;
  min-height: 44px;
  max-height: 120px;
}

.message-input::placeholder {
  color: var(--text-secondary);
}

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

/* Loading State */
.chat-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  padding: 2rem;
}

.chat-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

/* Loading Messages */
.loading-messages {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  padding: 2rem;
}

.loading-messages-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.loading-spinner-wrapper {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.loading-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  box-shadow: 0 2px 8px rgba(var(--primary-rgb, 0, 123, 255), 0.4);
  animation: loading-bounce 1.4s ease-in-out infinite both;
}

.loading-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
  animation-delay: -0.16s;
}

.loading-dot:nth-child(3) {
  animation-delay: 0s;
}

@keyframes loading-bounce {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

.loading-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  margin: 0;
  animation: loading-pulse 2s ease-in-out infinite;
}

@keyframes loading-pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* Улучшенная анимация для темной темы */
[data-theme="dark"] .loading-dot {
  box-shadow: 0 2px 12px rgba(var(--primary-rgb, 0, 123, 255), 0.6);
}

/* Адаптивность */
@media (max-width: 768px) {
  .loading-spinner-wrapper {
    width: 60px;
    height: 60px;
  }
  
  .loading-dot {
    width: 12px;
    height: 12px;
  }
  
  .loading-spinner-dots {
    gap: 10px;
  }
  
  .loading-text {
    font-size: 0.85rem;
  }
}

/* Empty Messages State */
.empty-messages-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  padding: 2rem;
}

.empty-messages-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  text-align: center;
  max-width: 400px;
}

.empty-messages-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(var(--primary-rgb, 0, 123, 255), 0.1) 0%, rgba(var(--primary-rgb, 0, 123, 255), 0.05) 100%);
  margin-bottom: 0.5rem;
  transition: transform 0.3s ease;
}

.empty-messages-icon-wrapper:hover {
  transform: scale(1.05);
}

.empty-messages-icon {
  font-size: 3.5rem;
  color: var(--primary-color);
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

.empty-messages-icon-wrapper:hover .empty-messages-icon {
  opacity: 0.8;
}

.empty-messages-text {
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.3px;
}

.empty-messages-subtext {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 400;
  margin: 0;
  opacity: 0.8;
  line-height: 1.5;
}

/* Адаптивность для пустого состояния */
@media (max-width: 768px) {
  .empty-messages-state {
    min-height: 250px;
    padding: 1.5rem;
  }
  
  .empty-messages-icon-wrapper {
    width: 80px;
    height: 80px;
  }
  
  .empty-messages-icon {
    font-size: 2.75rem;
  }
  
  .empty-messages-text {
    font-size: 1.1rem;
  }
  
  .empty-messages-subtext {
    font-size: 0.875rem;
  }
}

/* Simple Chat Mobile */
@media (max-width: 768px) {
  .simple-chat-container {
    height: 100vh;
    height: 100dvh;
    height: 100svh; /* Small viewport height - excludes browser UI */
    /* Fallback for browsers without svh support */
    min-height: -webkit-fill-available;
    max-height: 100vh;
    max-height: 100dvh;
    max-height: 100svh;
  }

  /* Ensure messages area doesn't get hidden behind keyboard */
  .messages-area {
    flex: 1;
    min-height: 0; /* Important for flex items */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Add bottom padding to prevent content from being hidden behind input */
    /* padding-bottom: 1rem; */
  }

  .chat-header {
    padding: 0.75rem;
    flex-shrink: 0;
  }

  .message-bubble {
    max-width: 85%;
  }

  .chat-input-area {
    padding: 0.75rem 1rem;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.08);
  }

  .simple-chat-input-area {
    padding: 0.75rem;
    /* Ensure input area is always visible - sticky positioning */
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    /* Add safe area support for devices with home indicator */
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    /* Ensure it stays within viewport */
    width: 100%;
    box-sizing: border-box;
    /* Add shadow for better visibility */
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  }

  .message-input {
    padding: 10px 12px;
    font-size: 16px;
  }

  .mes {
    max-width: 85%;
    margin-bottom: 0.875rem;
  }

  /* Выравнивание отправленных сообщений по правому краю в мобильной версии */
  .mes.message-own-mobile {
    align-self: flex-end;
    margin-left: auto;
    width: auto;
    min-width: 0;
    max-width: 85%;
  }

  /* Альтернативный способ через CSS селектор для надежности */
  .mes:has(.message-send) {
    align-self: flex-end;
    margin-left: auto;
    width: auto;
    min-width: 0;
  }

  /* Убираем двойное ограничение ширины для message-bubble в отправленных сообщениях */
  .mes.message-own-mobile .message-bubble,
  .mes:has(.message-send) .message-bubble {
    max-width: 100%;
    width: 100%;
  }

  .message-send,
  .message-rescive,
  .message-from-user {
    padding: 0.75rem 0.875rem;
  }

  .message-send {
    border-radius: 18px 18px 4px 18px; /* Хвостик справа для отправленных сообщений */
  }

  .message-rescive,
  .message-from-user {
    border-radius: 18px 18px 18px 4px;
  }

  .message-bubble {
    max-width: 85%;
    padding: 0.75rem 0.875rem;
  }

  .own-message .message-bubble {
    border-radius: 18px 18px 4px 18px;
  }

  .other-message .message-bubble {
    border-radius: 18px 18px 18px 4px;
  }

  .message-text {
    font-size: 0.9375rem;
  }

  .message-image {
    max-width: 200px;
    max-height: 200px;
  }

  .message-image-custom {
    max-width: 250px;
  }

  .scroll-to-bottom-btn {
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: 15px;
    width: 45px;
    height: 45px;
    font-size: 16px;
  }


  .message-textarea {
    padding: 10px 12px;
    font-size: 16px;
    /* Ensure textarea doesn't cause layout shift */
    max-height: 120px;
    overflow-y: auto;
  }

  .input-footer {
    padding: 0 12px 6px 12px;
  }

  .attach-button {
    padding: 10px 12px;
  }

  .enhanced-input-group:focus-within {
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb, 0, 123, 255), 0.15), 0 0 8px var(--shadow-medium);
  }

  .compact-files-container {
    gap: 6px;
  }

  .compact-thumbnail {
    width: 50px;
    height: 50px;
  }

  .compact-file-preview {
    padding: 4px 8px;
    max-width: 150px;
  }

  .compact-file-name {
    font-size: 11px;
  }

  .compact-remove-btn {
    width: 18px;
    height: 18px;
    font-size: 10px;
  }

  /* Fix for iOS Safari address bar */
  @supports (-webkit-touch-callout: none) {
    .simple-chat-container {
      height: -webkit-fill-available;
      max-height: -webkit-fill-available;
    }
    
    .simple-chat-input-area {
      position: sticky;
      bottom: 0;
    }
  }
  
  /* Ensure input area stays visible when keyboard appears */
  .simple-chat-input-area {
    will-change: transform;
    transform: translateZ(0); /* Force hardware acceleration */
  }
}

/* Extra small devices */
@media (max-width: 480px) {
  .simple-chat-input-area {
    padding: 0.5rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  }
  
  .enhanced-input-group {
    border-radius: 20px;
  }
  
  .message-textarea {
    padding: 8px 12px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* React Root */
#react_root_local {
  height: 100vh;
  height: 100dvh;
  height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Chat Messages Specific */
.chat-messages-flex-container {
  flex: 1;
  overflow: hidden;
}

.chat-placeholder-bg {
  background-color: var(--chat-bg);
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.message-sender-name {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  margin-bottom: 0.25rem;
}

.message-sender-name small {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  opacity: 0.8;
}

/* Message Grouping - улучшенное визуальное разделение */
.mes + .mes {
  margin-top: 0.25rem;
}

.mes:not(:last-child) {
  margin-bottom: 0.75rem;
}

/* Улучшенная читаемость длинных сообщений */
.mes .message-text,
.message-bubble .message-text-content {
  hyphens: auto;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Выделение упоминаний и важных частей */
.message-text strong {
  font-weight: 600;
  color: inherit;
}

.message-send .message-text strong {
  color: rgba(255, 255, 255, 0.95);
}

.message-rescive .message-text strong,
.message-from-user .message-text strong {
  color: var(--text-primary);
}

/* Улучшенные стили для кода в сообщениях */
.message-text code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.875em;
}

.message-send .message-text code {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.95);
}

.message-rescive .message-text code,
.message-from-user .message-text code {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

[data-theme="dark"] .message-rescive .message-text code,
[data-theme="dark"] .message-from-user .message-text code {
  background: rgba(255, 255, 255, 0.1);
}

.message-text-custom {
  max-width: 40vh;
  height: auto;
  line-height: 1.6;
  font-size: 0.9375rem;
  letter-spacing: 0.01em;
}

/* В мобильной версии убираем ограничение ширины для текста сообщений */
@media (max-width: 991px) {
  .message-text-custom {
    max-width: 100%;
  }
}

.message-text-content {
  white-space: pre-line;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message-image-custom {
  width: 100%;
  height: auto;
  max-width: 300px;
  border-radius: 12px;
  margin-top: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: block;
}

.message-image-custom:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Video styles in messages */
.message-video-custom {
  position: relative;
  max-width: 300px;
  margin-top: 0.5rem;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.message-video-custom:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.message-video-player {
  width: 100%;
  height: auto;
  max-height: 400px;
  display: block;
  border-radius: 12px;
  background-color: #000;
}

.message-video-download-link {
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.2s ease;
  z-index: 5;
}

.message-video-download-link:hover {
  background-color: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
  color: white;
}

/* Индикатор обработки видео */
.message-video-converting {
  position: relative;
}

.video-converting-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.video-converting-spinner {
  font-size: 32px;
  color: var(--primary-color);
  margin-bottom: 10px;
}

.video-converting-text {
  color: white;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

/* Ошибка воспроизведения видео */
.message-video-error {
  position: relative;
  max-width: 300px;
  margin-top: 0.5rem;
  padding: 20px;
  background: var(--bg-secondary, #f8f9fa);
  border: 2px dashed var(--border-color, #dee2e6);
  border-radius: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.video-error-icon {
  font-size: 32px;
  color: var(--danger-color, #dc3545);
}

.video-error-message {
  color: var(--text-primary, #212529);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.video-error-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--primary-color, #3b7aad);
  color: white;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
}

.video-error-download-btn:hover {
  background: var(--primary-hover, #2d5f87);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 122, 173, 0.3);
  color: white;
  text-decoration: none;
}

[data-theme="dark"] .message-video-error {
  background: var(--bg-secondary, #2d2d2d);
  border-color: var(--border-color, #444);
}

[data-theme="dark"] .video-error-message {
  color: var(--text-primary, #e0e0e0);
}

.messages-end-ref {
  height: 1px;
}

/* Chat Blocked Overlay */
.chat-blocked-overlay {
  position: absolute;
  inset: 0;
  background-color: var(--overlay-bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.3s ease-in-out;
}

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

.chat-blocked-overlay .wifi-icon {
  font-size: 2rem;
  opacity: 0.8;
}

.chat-blocked-overlay .connection-text {
  font-weight: 600;
}

.chat-blocked-overlay .small-text {
  opacity: 0.8;
}

.chat-blocked-overlay .reload-button {
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
}

/* Message Textarea Disabled */
.message-textarea-disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* User List Specific */
.user-list-full-height {
  height: 100vh;
  overflow-y: auto;
}

.mobile-close-button {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

/* Dropdown Portal */
.dropdown-portal-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

.dropdown-menu-modern {
  pointer-events: auto;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 8px 24px var(--shadow-medium);
  padding: 8px 0;
  min-width: 200px;
  max-width: 250px;
}

/* User Card Popup */
.user-card-popup {
  pointer-events: auto;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 8px 24px var(--shadow-medium);
  padding: 16px;
  min-width: 200px;
  max-width: 280px;
  animation: cardFadeIn 0.2s ease-out;
}

@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-card-popup .header-avatar {
  transition: transform 0.2s ease;
}

.user-card-popup .header-avatar:hover {
  transform: scale(1.05);
}

/* Mobile responsive for user card */
@media (max-width: 991px) {
  .user-card-popup {
    min-width: 180px;
    max-width: 240px;
    padding: 12px;
    font-size: 0.9rem;
  }
  
  .user-card-popup .header-avatar {
    width: 40px !important;
    height: 40px !important;
    font-size: 16px !important;
  }
  
  /* Адаптивность для имени пользователя в header */
  .user-list-header .d-flex.align-items-center > div[style*="maxWidth"] {
    max-width: 100px !important;
    font-size: 14px !important;
  }
}

/* Toast Notification */
.toast-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--success-color);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  z-index: 10001;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(var(--success-rgb, 40, 167, 69), 0.3);
}

/* Mobile Close Button Full Width */
.mobile-close-button-full {
  background: var(--danger-color);
  border: 1px solid var(--danger-color);
  color: var(--header-text);
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 500;
  width: 100%;
  min-height: 44px;
}

.mobile-close-button-full:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px var(--shadow-medium);
}

.mobile-close-button-full:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px var(--shadow-medium);
}

/* Unified Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--background-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

::-webkit-scrollbar-thumb:active {
  background: var(--primary-color);
}

::-webkit-scrollbar-corner {
  background: var(--background-color);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--background-color);
}

*:hover {
  scrollbar-color: var(--text-secondary) var(--background-color);
}

/* Specific Scrollbars */
.chat-sidebar::-webkit-scrollbar,
.user-list-body::-webkit-scrollbar {
  width: 6px;
}

.chat-sidebar::-webkit-scrollbar-track,
.user-list-body::-webkit-scrollbar-track {
  background: var(--background-color);
}

.chat-sidebar::-webkit-scrollbar-thumb,
.user-list-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.chat-sidebar::-webkit-scrollbar-thumb:hover,
.user-list-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.messages-area::-webkit-scrollbar {
  width: 6px;
}

.messages-area::-webkit-scrollbar-track {
  background: var(--background-color);
}

.messages-area::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.message-textarea::-webkit-scrollbar {
  width: 4px;
}

.message-textarea::-webkit-scrollbar-track {
  background: transparent;
}

.message-textarea::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.message-textarea::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Dark Theme Scrollbar */
[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--surface-color);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--border-color);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

[data-theme="dark"] ::-webkit-scrollbar-corner {
  background: var(--surface-color);
}

[data-theme="dark"] {
  scrollbar-color: var(--border-color) var(--surface-color);
}

[data-theme="dark"] *:hover {
  scrollbar-color: var(--text-muted) var(--surface-color);
}

/* Gradient Scrollbar */
.gradient-scrollbar::-webkit-scrollbar {
  width: 10px;
}

.gradient-scrollbar::-webkit-scrollbar-track {
  background: var(--background-color);
  border-radius: 5px;
}

.gradient-scrollbar::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, 
    var(--primary-color) 0%, 
    var(--primary-hover) 100%
  );
  border-radius: 5px;
  border: 2px solid var(--background-color);
}

.gradient-scrollbar::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, 
    var(--primary-hover) 0%, 
    var(--primary-color) 100%
  );
}

/* Thin Scrollbar */
.thin-scrollbar::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.thin-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.thin-scrollbar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.thin-scrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Invisible Scrollbar */
.invisible-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.invisible-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Device Card Styles */
.devices-list {
  max-height: calc(100vh - 300px);
  overflow-y: auto;
}

.device-card {
  background: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px;
  transition: all 0.2s ease;
}

.device-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px var(--shadow-light);
}

.device-header {
  margin-bottom: 0.5rem !important;
  padding: 0.5rem 0.75rem 0.25rem !important;
}

.device-details {
  padding: 0 0.75rem 0.5rem !important;
}

.device-icon {
  flex-shrink: 0;
  width: 24px !important;
  height: 24px !important;
  font-size: 12px !important;
}

.device-row {
  min-height: 20px;
  padding: 0.25rem 0 !important;
  font-size: 0.8rem !important;
}

.device-row .fa {
  width: 14px !important;
  font-size: 0.75rem !important;
}

.device-row.border-bottom {
  border-bottom: 1px solid var(--border-color) !important;
  margin-bottom: 0.125rem;
}

.border-bottom {
  border-bottom: 1px solid var(--border-color) !important;
}

.fw-medium {
  font-weight: 500;
  color: var(--info-color);
}

.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Device Group */
.device-group {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.device-group-header {
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 60px;
  gap: 0.75rem;
}

.device-group-header:hover {
  background-color: var(--user-item-hover) !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.device-group-header > div:first-child {
  flex: 1;
  min-width: 0;
  gap: 0.75rem;
}

.device-group-header > div:first-child > div {
  flex: 1;
  min-width: 0;
}

.device-group-header .fw-bold {
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.device-group-header small {
  display: block;
  line-height: 1.4;
  margin-top: 0.25rem;
}

.device-group-header .sysinfo-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.device-group-header .sysinfo-link:hover {
  background-color: rgba(var(--primary-rgb, 0, 123, 255), 0.1);
}

.device-group-header > div:last-child {
  flex-shrink: 0;
  margin-left: auto;
  padding-left: 0.5rem;
}

.cursor-pointer {
  cursor: pointer;
}

.fw-bold {
  font-weight: 600;
}

@media (max-width: 991.98px) {
  .devices-list {
    max-height: calc(100vh - 250px);
  }
}

/* SysInfo Modal */
.sysinfo-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--overlay-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.sysinfo-modal-content {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  max-width: 550px;
  width: 95%;
  max-height: 85vh;
  height: auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px var(--shadow-medium);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.sysinfo-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  flex-grow: 0;
}

.sysinfo-modal-header h5 {
  margin: 0;
  font-weight: 600;
  display: flex;
  align-items: center;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--header-text);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
}

.btn-close-modal:hover {
  background-color: rgba(255, 255, 255, 0.15);
  opacity: 1;
}

.sysinfo-modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  box-sizing: border-box;
  position: relative;
}

.sysinfo-modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--surface-color);
  flex-shrink: 0;
  flex-grow: 0;
}

/* Manage Users Page Styles */
body.manage-users-page,
html.manage-users-page {
  overflow: auto !important;
  height: auto !important;
  position: relative !important;
}

body.manage-users-page .container,
html.manage-users-page .container {
  overflow: visible !important;
  height: auto !important;
  position: relative !important;
}

.manage-users-container {
  overflow: visible !important;
  height: auto !important;
  position: relative !important;
}

.manage-users-container .container-fluid {
  overflow: visible !important;
  height: auto !important;
  position: relative !important;
}

#react_root_local {
  overflow: visible !important;
  height: auto !important;
  position: relative !important;
}

.sysinfo-section {
  margin-bottom: 1.5rem;
}

.sysinfo-section:last-child {
  margin-bottom: 0;
}

.sysinfo-section-title {
  display: flex;
  align-items: center;
  color: var(--primary-color);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.sysinfo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.sysinfo-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
  background-color: var(--background-color);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.sysinfo-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.sysinfo-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  word-break: break-word;
}

.sysinfo-link {
  transition: all 0.2s ease;
  border-radius: 4px;
  padding: 2px 4px;
  display: inline-flex;
  align-items: center;
}

.sysinfo-link:hover {
  background-color: rgba(var(--primary-rgb, 0, 123, 255), 0.1);
  color: var(--primary-color) !important;
}

/* Rename Modal - same z-index as sysinfo to appear above user-info-panel */
.rename-modal-content {
  max-width: 400px;
  width: 90%;
}

.rename-modal-content .sysinfo-modal-body {
  padding: 1.5rem;
}

.rename-modal-content .form-label {
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.rename-modal-content .form-control {
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.rename-modal-content .form-control:focus {
  box-shadow: 0 0 0 0.2rem rgba(var(--primary-rgb, 0, 123, 255), 0.25);
}

.rename-modal-content .btn {
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-weight: 500;
}

.rename-modal-content .btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.rename-modal-content .btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.rename-modal-content .btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.rename-modal-content .btn-secondary {
  background-color: var(--background-color);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.rename-modal-content .btn-secondary:hover {
  background-color: var(--surface-color);
  border-color: var(--text-secondary);
}

/* Notes Modal - larger size */
.notes-modal-content {
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  min-height: 400px;
}

.notes-modal-content .sysinfo-modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 300px;
}

.notes-modal-content textarea.form-control {
  min-height: 250px;
  flex: 1;
}

/* Mobile Responsive for SysInfo Modal */
@media (max-width: 576px) {
  .sysinfo-modal-content {
    width: 98%;
    max-height: 90vh;
    margin: 1rem;
  }

  .sysinfo-modal-header {
    padding: 0.875rem 1rem;
  }

  .sysinfo-modal-header h5 {
    font-size: 1rem;
  }

  .sysinfo-modal-body {
    padding: 1rem;
  }

  .sysinfo-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .sysinfo-section {
    margin-bottom: 1rem;
  }

  .sysinfo-item {
    padding: 0.375rem 0.5rem;
  }

  .sysinfo-label {
    font-size: 0.7rem;
  }

  .sysinfo-value {
    font-size: 0.8125rem;
  }

  /* Rename modal mobile styles */
  .rename-modal-content {
    width: 95%;
    margin: 0.5rem;
  }

  .rename-modal-content .sysinfo-modal-body {
    padding: 1rem;
  }

  .rename-modal-content .form-control {
    font-size: 16px;
  }

  /* Notes modal mobile styles */
  .notes-modal-content {
    width: 95%;
    max-width: 95%;
    margin: 0.5rem;
    max-height: 85vh;
    min-height: 350px;
  }

  .notes-modal-content .sysinfo-modal-body {
    padding: 1rem;
    min-height: 250px;
  }

  .notes-modal-content textarea.form-control {
    min-height: 200px;
  }
}

/* User Edit Modal - larger size for user management */
.user-edit-modal-content {
  max-width: 800px !important;
  width: 90% !important;
  max-height: 90vh !important;
  height: 90vh !important;
  min-height: 500px !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.user-edit-modal-content .sysinfo-modal-body {
  padding: 1.25rem;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  flex: 1 1 0% !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
}

@media (max-width: 768px) {
  .user-edit-modal-content {
    max-width: 95% !important;
    width: 95% !important;
    max-height: 95vh !important;
    height: 95vh !important;
    min-height: 400px !important;
  }
  
  .user-edit-modal-content .sysinfo-modal-body {
    padding: 1rem;
  }
}

/* Notification Highlighting Styles */
.highlight-notification {
  animation: notification-pulse 3s ease-in-out;
  border-radius: 8px !important;
  position: relative;
  z-index: 10;
}

@keyframes notification-pulse {
  0% {
    background-color: var(--background-color);
    box-shadow: 0 0 0 0 rgba(var(--primary-rgb, 0, 123, 255), 0.7);
  }
  
  50% {
    background-color: rgba(var(--primary-rgb, 0, 123, 255), 0.1);
    box-shadow: 0 0 0 10px rgba(var(--primary-rgb, 0, 123, 255), 0);
    transform: scale(1.02);
  }
  
  100% {
    background-color: var(--background-color);
    box-shadow: 0 0 0 0 rgba(var(--primary-rgb, 0, 123, 255), 0);
    transform: scale(1);
  }
}

/* Enhanced notification focus for chat elements */
.chat-notification-focus {
  background-color: rgba(var(--primary-rgb, 0, 123, 255), 0.15) !important;
  border-left: 4px solid var(--primary-color) !important;
  padding-left: 12px !important;
  margin-left: -4px !important;
  border-radius: 0 8px 8px 0 !important;
}

/* Message highlight for new messages from notifications */
.message-notification-highlight {
  background: linear-gradient(90deg, 
    rgba(var(--primary-rgb, 0, 123, 255), 0.1) 0%, 
    transparent 100%);
  border-left: 3px solid var(--primary-color);
  padding-left: 12px;
  margin-left: -3px;
  border-radius: 0 6px 6px 0;
  animation: slide-in-left 0.5s ease-out;
}

@keyframes slide-in-left {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Chat container focus indication */
#chat-container.highlight-notification {
  border: 2px solid var(--primary-color);
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(var(--primary-rgb, 0, 123, 255), 0.3);
}

/* Sidebar chat item focus */
.chat-sidebar-item.highlight-notification {
  background-color: rgba(var(--primary-rgb, 0, 123, 255), 0.15);
  border-left: 4px solid var(--primary-color);
  padding-left: 12px;
  margin-left: -4px;
  border-radius: 0 6px 6px 0;
}

/* App Launch Animation from Notification */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

@keyframes appLaunchPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(var(--primary-rgb, 0, 123, 255), 0.7);
  }
  70% {
    box-shadow: 0 0 0 20px rgba(var(--primary-rgb, 0, 123, 255), 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(var(--primary-rgb, 0, 123, 255), 0);
  }
}

/* App container animation when launched from notification */
body.launched-from-notification #chat-container {
  animation: appLaunchPulse 2s ease-out;
  border: 2px solid var(--primary-color);
  border-radius: 12px;
}

/* Enhanced PWA focus indicators */
.pwa-window-focused {
  outline: 3px solid var(--primary-color) !important;
  outline-offset: 2px;
  border-radius: 8px !important;
}

/* Notification feedback animations */
.notification-feedback-enter {
  animation: slideInRight 0.3s ease-out;
}

.notification-feedback-exit {
  animation: slideOutRight 0.3s ease-in;
}

/* Standalone mode indicators */
@media (display-mode: standalone) {
  .browser-only {
    display: none !important;
  }
  
  .standalone-only {
    display: block !important;
  }
}

@media not (display-mode: standalone) {
  .standalone-only {
    display: none !important;
  }
  
  .browser-only {
    display: block !important;
  }
}

/* Enhanced notification badge for PWA */
.pwa-notification-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--danger-color, #dc3545);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  animation: notification-badge-pulse 2s infinite;
}

@keyframes notification-badge-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* PWA install prompt improvements */
.pwa-install-prompt {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.pwa-install-prompt.hidden {
  animation: slideDown 0.3s ease-in;
}

@keyframes slideDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

/* Mobile PWA and Keyboard Fixes */
@media screen and (max-width: 768px) {
  /* Fix for mobile viewport issues */
  html, body {
    height: 100%;
    height: 100vh;
    height: 100dvh;
    overflow-x: hidden;
    /* Prevent zoom on input focus */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
  }

  /* Ensure chat container uses full viewport height */
  .simple-chat-container {
    height: 100vh;
    height: 100dvh;
    /* Fallback for browsers without dvh */
    min-height: -webkit-fill-available;
    position: relative;
  }

  /* Fix for iOS Safari address bar */
  @supports (-webkit-touch-callout: none) {
    .simple-chat-container {
      height: -webkit-fill-available;
    }
  }

  /* Prevent layout shift when keyboard appears */
  .messages-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Prevent content from being pushed up */
    position: relative;
  }

  /* Ensure input area stays visible */
  .simple-chat-input-area {
    position: relative;
    flex-shrink: 0;
    z-index: 1000;
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    /* Account for safe areas */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Fix textarea zoom on iOS */
  .message-textarea {
    font-size: 16px !important;
    /* Prevent zoom on focus */
    transform: scale(1);
  }

  /* Better scroll behavior for mobile */
  .messages-area {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
  }

  .messages-area::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }
}

/* Landscape mobile orientation fixes */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .simple-chat-container {
    height: 100vh;
    height: 100dvh;
  }

  .chat-header {
    padding: 0.5rem;
    flex-shrink: 0;
  }

  .simple-chat-input-area {
    padding: 0.5rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  }

  .messages-area {
    padding: 0.5rem;
  }

  .message-textarea {
    padding: 8px 12px;
    max-height: 80px;
  }
}

/* PWA specific fixes */
@media (display-mode: standalone) {
  /* Фиксы для страниц с чатом */
  body:has(.simple-chat-container),
  body:has(.chat-layout) {
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
  }

  body:has(.simple-chat-container) #react_root_local,
  body:has(.chat-layout) #react_root_local {
    height: 100%;
    width: 100%;
    overflow: hidden;
  }

  .simple-chat-container {
    height: 100vh;
    height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
  }

  .chat-layout {
    height: 100vh;
    height: 100dvh;
  }

  .chat-header {
    padding-top: calc(1rem + env(safe-area-inset-top));
    flex-shrink: 0;
  }

  .messages-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .simple-chat-input-area,
  .chat-input-area {
    flex-shrink: 0;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }

  .chat-main-column {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }

  .chat-area-with-info {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .chat-messages-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }

  .chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }

  .chat-messages-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
}