/* =============================================
   ADMIN PANEL - СТИЛОВЕ
   ============================================= */

/* Премахване на черното очертание при фокус */
button:focus,
button:active,
input:focus,
textarea:focus,
select:focus,
a:focus,
.nav-link:focus {
  outline: none !important;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --admin-accent: #008080;
  --admin-accent-dark: #006666;
  --admin-accent-rgb: 0, 128, 128;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f7fa;
  color: #333;
  min-height: 100vh;
  /* overflow: hidden;  Премахнато за тест */
  display: flex;
}

/* ==================== Sidebar (Вертикално меню) ==================== */
.admin-header {
  background: var(--admin-accent);
  color: white;
  width: 280px;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  display: none; /* Скрит по подразбиране */
  flex-direction: column;
  overflow-y: auto;
  z-index: 1000;
}

.admin-header.visible {
  display: flex; /* Показва се след логин като flex контейнер */
}

.admin-header-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
}

.admin-header h1 {
  font-size: 24px;
  font-weight: 600;
  margin-right: 30px;
}

/* User Info Section (горе в sidebar) */
.admin-user-info {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Навигация (вертикална) */
.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 20px 15px;
  flex: 1;
}

.nav-link {
  color: white;
  text-decoration: none;
  padding: 12px 15px;
  border-radius: 6px;
  transition: background 0.2s;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  display: block;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.2);
}

.dashboard-card-static {
  cursor: default;
}

.dashboard-card-static:hover {
  transform: none;
}

/* Падащо меню */
.nav-item.dropdown {
  position: relative;
}

.dropdown-arrow {
  font-size: 12px;
  margin-left: 5px;
  transition: transform 0.2s;
}

/* Breadcrumbs стилове */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 15px 0;
  font-size: 14px;
  color: #666;
  margin-bottom: 10px;
}

.breadcrumbs a {
  color: var(--admin-accent);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumbs a:hover {
  color: var(--admin-accent-dark);
  text-decoration: underline;
}

.breadcrumbs .separator {
  color: #999;
  font-size: 16px;
}

.breadcrumbs .current {
  color: #333;
  font-weight: 600;
}

/* Incoming Chat Popup */
.incoming-popup {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 320px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(var(--admin-accent-rgb), 0.3);
  z-index: 10000;
  transform: translateY(400px);
  opacity: 0;
  transition: all 0.3s ease-in-out;
  border: 2px solid var(--admin-accent);
  animation: pulse-glow 2s infinite;
}

.incoming-popup.active {
  transform: translateY(0);
  opacity: 1;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 8px 24px rgba(var(--admin-accent-rgb), 0.3);
  }
  50% {
    box-shadow: 0 8px 32px rgba(var(--admin-accent-rgb), 0.6), 0 0 20px rgba(var(--admin-accent-rgb), 0.4);
  }
}

.popup-header {
  background: linear-gradient(135deg, var(--admin-accent) 0%, var(--admin-accent-dark) 100%);
  color: white;
  padding: 15px;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.popup-icon {
  font-size: 24px;
  animation: bounce 1s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.popup-title {
  flex: 1;
  font-weight: 600;
  font-size: 16px;
}

.popup-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.popup-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.popup-body {
  padding: 20px;
}

.popup-user-name {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
}

.popup-message-count {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #666;
  font-size: 14px;
}

.count-badge {
  background: #ff4444;
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  animation: pulse-badge 1.5s infinite;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.popup-footer {
  padding: 15px;
  border-top: 1px solid #e0e0e0;
}

.popup-btn {
  width: 100%;
  padding: 12px;
  background: var(--admin-accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  outline: none;
}

.popup-btn:focus,
.popup-btn:active {
  outline: none;
}

.popup-btn:hover {
  background: var(--admin-accent-dark);
}

.dropdown-menu {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  margin-top: 5px;
  padding: 5px 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.nav-item.dropdown.active .dropdown-menu,
.nav-item.dropdown:hover .dropdown-menu {
  max-height: 200px;
}

.nav-item.dropdown:hover .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-menu a {
  display: block;
  padding: 10px 15px 10px 30px;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  transition: background 0.2s;
  font-size: 14px;
  border-radius: 4px;
  margin: 2px 5px;
}

.dropdown-menu a:hover {
  background: rgba(255, 255, 255, 0.1);
}

.dropdown-menu a.active {
  background: rgba(255, 255, 255, 0.15);
}

/* Main Content Area */
.main-content {
  margin-left: 280px;
  width: calc(100% - 280px);
  height: 100vh;
  overflow-y: auto;
  padding: 30px;
  background: #f5f7fa;
}

/* When header is not visible (not logged in) */
body:not(:has(.admin-header.visible)) .main-content {
  margin-left: 0;
  width: 100%;
}

/* Container adjustments */
.dashboard-container,
.visitors-container,
#admin-container {
  max-width: 100%;
  margin: 0;
  padding: 0;
}

/* Breadcrumbs adjustments */
.breadcrumbs {
  padding: 0 0 15px 0;
  margin-bottom: 20px;
  border-bottom: 1px solid #e0e0e0;
}

#agent-name {
  font-weight: 500;
}

/* Agent Name Link */
.agent-name-link {
  color: white;
  text-decoration: none;
  padding: 10px 15px;
  border-radius: 6px;
  transition: background 0.2s;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  display: block;
  text-align: center;
}

.agent-name-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.agent-name-link.active {
  background: rgba(255, 255, 255, 0.2);
}

/* Status Menu - Dropdown with buttons */

.status-menu {
  position: relative;
  position: relative;
  display: flex;
  justify-content: center;
}

.status-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: 2px solid #4CAF50;
  border-radius: 6px;
  background: white;
  color: #333;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  width: 100%;
}

.status-button:hover {
  background: #f0f0f0;
  transform: scale(1.05);
}

.status-button.online {
  border-color: #4CAF50;
  color: #4CAF50;
}

.status-button.offline {
  border-color: #ff4444;
  color: #ff4444;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.status-button.online .status-dot {
  background: #4CAF50;
  box-shadow: 0 0 6px #4CAF50;
}

.status-button.offline .status-dot {
  background: #ff4444;
  box-shadow: 0 0 6px #ff4444;
}

.dropdown-arrow {
  font-size: 12px;
  margin-left: 4px;
}

.status-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: white;
  border: 2px solid red;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 160px;
  display: none;
  flex-direction: column;
  z-index: 9999;
}

.status-dropdown.active {
  display: flex;
}

.status-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: none;
  background: white;
  color: #333;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}

.status-option:first-child {
  border-radius: 6px 6px 0 0;
}

.status-option:last-child {
  border-radius: 0 0 6px 6px;
  border-top: 1px solid #eee;
}

.status-option:hover {
  background: #f5f5f5;
  padding-left: 20px;
}

.status-option.online-option {
  color: #4CAF50;
}

.status-option.online-option .status-dot {
  background: #4CAF50;
  box-shadow: 0 0 6px #4CAF50;
}

.status-option.offline-option {
  color: #ff4444;
}

.status-option.offline-option .status-dot {
  background: #ff4444;
  box-shadow: 0 0 6px #ff4444;
}

#status-text {
  font-weight: 600;
  font-size: 14px;
}

/* ==================== Форма за вход ==================== */
#login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: calc(100vh - 70px);
  background: var(--admin-accent);
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 400px;
}

.login-box h2 {
  margin-bottom: 25px;
  text-align: center;
  color: #333;
}

.login-box input {
  width: 100%;
  padding: 15px;
  margin-bottom: 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
}

.login-box input:focus {
  outline: none;
  border-color: var(--admin-accent);
}

.login-hint {
  margin-top: 15px;
  text-align: center;
  font-size: 13px;
  color: #666;
}

/* ==================== Главен контейнер ==================== */
#admin-container {
  display: flex;
  height: calc(100vh - 70px);
  max-width: 1400px;
  margin: 0 auto;
  overflow: hidden;
}

/* ==================== Лява колона - Сесии ==================== */
.sessions-sidebar {
  width: 350px;
  background: white;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.sessions-list {
  flex: 1;
  overflow-y: auto;
}

.session-item {
  padding: 15px 20px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.2s, border-left 0.2s;
  border-left: 4px solid transparent;
}

.session-item:hover {
  background: #f9f9f9;
}

.session-item.active {
  background: #e0f2f1;
  border-left: 4px solid var(--admin-accent);
}

.session-item.has-new-message {
  background: #fff3e0;
  border-left: 4px solid #ff9800;
  animation: session-unread-glow 1.6s ease-in-out infinite;
}

@keyframes session-unread-glow {
  0%, 100% {
    background: #fff3e0;
    box-shadow: inset 0 0 0 0 rgba(255, 152, 0, 0);
  }
  50% {
    background: #ffe0b2;
    box-shadow: inset 0 0 0 9999px rgba(255, 167, 38, 0.06);
  }
}

.session-item.has-new-message .session-name {
  color: #d84315;
  font-weight: 700;
}

.session-item.has-new-message .session-time {
  color: #e65100;
  font-weight: 600;
}

.session-preview-unread {
  color: #bf360c;
  font-weight: 700;
}

.session-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 10px;
}

.session-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.session-name {
  font-weight: 600;
  font-size: 15px;
}

.session-ip {
  font-size: 11px;
  color: #666;
}

.session-email {
  font-size: 11px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.session-time {
  font-size: 12px;
  color: #999;
  white-space: nowrap;
}

.unread-badge {
  background: #ff4444;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 68, 68, 0.18);
  animation: unread-pulse 1.5s ease-in-out infinite;
}

@keyframes unread-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.session-preview {
  font-size: 13px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-badge {
  background: #ff4444;
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 10px;
}

.sidebar-section {
  padding: 20px;
  border-top: 1px solid #e0e0e0;
}

.sidebar-section h4 {
  font-size: 14px;
  margin-bottom: 10px;
  color: #666;
}

/* ==================== Дясна колона - Чат ==================== */

/* ==================== Дясна колона - Чат (от бекъп 4) ==================== */
.chat-area {
  flex: 1;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.empty-state-large {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #999;
}

.empty-state-large h2 {
  font-size: 28px;
  margin-bottom: 10px;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: #999;
}

#active-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-header {
  background: white;
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.client-info {
  flex: 1;
}

.client-name-row {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 5px;
}

.client-info h3 {
  font-size: 18px;
  margin: 0;
}

.btn-link {
  background: none;
  border: none;
  color: var(--admin-accent);
  font-size: 13px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-link:hover {
  background: #e0f2f1;
  text-decoration: underline;
}

.client-info p {
  font-size: 14px;
  color: #666;
  margin: 0;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: white;
  border: 1px solid #ddd;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--admin-accent);
  outline: none;
}

.btn-icon:focus,
.btn-icon:active {
  outline: none;
}

.btn-icon:hover {
  background: #e0f2f1;
  border-color: var(--admin-accent);
}

.btn-danger-icon {
  color: #ff4444;
  border-color: #ffcccc;
}

.btn-danger-icon:hover {
  background: #ffe0e0;
  border-color: #ff4444;
}

/* Minimized състояние за admin chat */
#active-chat.minimized .chat-messages,
#active-chat.minimized .chat-input-area,
#active-chat.minimized .typing-indicator {
  display: none !important;
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #fafafa;
  scroll-behavior: smooth;
}

/* Съобщения */
.message {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-items: flex-start;
}

.message.agent {
  align-items: flex-end;
}

.message.system {
  align-items: center;
}

.message-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
}

.message.user .message-bubble {
  background: white;
  color: #333;
  border: 1px solid #e0e0e0;
  border-bottom-left-radius: 4px;
}

.message.agent .message-bubble {
  background: var(--admin-accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.system .message-bubble {
  background: #e3f2fd;
  color: #1976d2;
  font-size: 13px;
  padding: 8px 12px;
}

.message-time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
  padding: 0 5px;
}

.message-sender {
  font-size: 12px;
  color: #666;
  margin-bottom: 2px;
  padding: 0 5px;
  font-weight: 600;
}

/* Прикачени файлове в съобщения */
.message-file {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e0e0e0;
  font-size: 13px;
}

.message-file a {
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.message.user .message-file a {
  color: #0066cc;
}

.message-file a:hover {
  text-decoration: underline;
}

/* Индикатор за писане */
.typing-indicator {
  display: none;
  padding: 10px 20px;
  align-items: center;
  gap: 10px;
  background: white;
  border-top: 1px solid #e0e0e0;
  font-size: 13px;
  color: #666;
}

.typing-indicator.active {
  display: flex;
}

.typing-indicator span {
  height: 8px;
  width: 8px;
  background: #999;
  border-radius: 50%;
  display: inline-block;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Поле за писане */
.chat-input-area {
  background: white;
  padding: 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 15px;
  align-items: flex-end;
  flex-shrink: 0;
  position: relative;
}

.shortcuts-dropdown {
  position: absolute;
  bottom: 100%;
  left: 20px;
  right: 20px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
  max-height: 200px;
  overflow-y: auto;
  display: none;
  z-index: 1000;
  margin-bottom: 5px;
}

.shortcuts-dropdown.active {
  display: block;
}

.shortcut-item {
  padding: 12px 15px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.2s;
}

.shortcut-item:last-child {
  border-bottom: none;
}

.shortcut-item:hover {
  background: #f5f5f5;
}

.shortcut-keyword {
  font-weight: 600;
  color: var(--admin-accent);
  font-family: monospace;
  font-size: 13px;
}

.shortcut-preview {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#admin-message-input {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  max-height: 150px;
}

#admin-message-input:focus {
  outline: none;
  border-color: var(--admin-accent);
}

/* ==================== Бутони ==================== */
.btn-primary {
  background: var(--admin-accent);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  outline: none;
}

.btn-primary:focus,
.btn-primary:active {
  outline: none;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: white;
  color: var(--admin-accent);
  border: 1px solid var(--admin-accent);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
}

.btn-secondary:focus,
.btn-secondary:active {
  outline: none;
}

.btn-secondary:hover {
  background: var(--admin-accent);
  color: white;
}

.btn-danger {
  background: #ff4444;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  outline: none;
}

.btn-danger:focus,
.btn-danger:active {
  outline: none;
}

.btn-danger:hover {
  background: #cc0000;
}

.btn-primary {
  background: var(--admin-accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
  text-decoration: none;
  display: inline-block;
}

.btn-primary:hover {
  background: var(--admin-accent-dark);
}

.btn-block {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==================== Badge ==================== */
.badge {
  background: var(--admin-accent);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* ==================== Модал ==================== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-large {
  max-width: 900px;
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, var(--admin-accent) 0%, var(--admin-accent-dark) 100%);
  color: white;
}

.modal-header h3 {
  font-size: 20px;
  color: white;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: white;
  transition: color 0.2s;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(80vh - 80px);
}

.offline-message-item {
  background: #f9f9f9;
  padding: 15px;
  margin-bottom: 15px;
  border-radius: 8px;
  border-left: 4px solid var(--admin-accent);
}

.offline-message-item h4 {
  margin-bottom: 5px;
  font-size: 16px;
}

.offline-message-item p {
  margin: 5px 0;
  font-size: 14px;
  color: #666;
}

.offline-message-item .message-text {
  margin-top: 10px;
  padding: 10px;
  background: white;
  border-radius: 5px;
  color: #333;
}

.offline-message-item button {
  margin-top: 10px;
}

/* ==================== Previous Chats ==================== */
.previous-chat-item {
  background: #f9f9f9;
  padding: 15px;
  margin-bottom: 15px;
  border-radius: 8px;
  border-left: 4px solid var(--admin-accent);
  cursor: pointer;
  transition: all 0.2s;
}

.previous-chat-item:hover {
  background: #e0f2f1;
  transform: translateX(5px);
}

.previous-chat-item.closed {
  border-left-color: #999;
}

.previous-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.previous-chat-date {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.previous-chat-status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  background: #4CAF50;
  color: white;
}

.previous-chat-status.closed {
  background: #999;
}

.previous-chat-status.offline {
  background: #ff9800;
}

.previous-chat-item.offline-message-history {
  border-left-color: #ff9800;
}

.previous-chat-item.offline-message-history:hover {
  background: #fff3e0;
}

.previous-chat-messages {
  font-size: 13px;
  color: #666;
}

.previous-chat-messages .message-count {
  background: var(--admin-accent);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  margin-right: 5px;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: #999;
}

.loading-state {
  text-align: center;
  padding: 40px;
  color: #999;
  font-size: 14px;
}

/* ==================== Scrollbar ==================== */
.sessions-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
  width: 6px;
}

.sessions-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.sessions-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.sessions-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
  #admin-container {
    flex-direction: column;
  }

  .sessions-sidebar {
    width: 100%;
    height: 40%;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }

  .chat-area {
    height: 60%;
  }
}

/* ==================== ПОТРЕБИТЕЛСКА ИНФОРМАЦИЯ ==================== */
.user-info-section {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
}

.user-info-section h4 {
  color: var(--admin-accent);
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 11px;
  color: #666;
  font-weight: 500;
}

.info-value {
  font-size: 13px;
  color: #333;
  word-break: break-all;
}

.btn-info {
  background: var(--admin-accent);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
}

.btn-info:hover {
  opacity: 0.9;
}

/* ==================== CHAT NOTIFY BUTTON (долу в sidebar) ==================== */
.chat-notify-section {
  padding: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  margin-top: auto;
  flex-shrink: 0;
}

.chat-notify-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  text-decoration: none;
  padding: 14px 16px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s;
}

.chat-notify-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.4);
}

.chat-notify-label {
  flex: 1;
}

.chat-notify-badge {
  background: #ff4444;
  color: white;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
  display: none;
}

@keyframes notify-pulse {
  0%, 100% {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
  }
  50% {
    background: rgba(255, 180, 0, 0.35);
    border-color: rgba(255, 200, 0, 0.7);
    box-shadow: 0 0 18px rgba(255, 200, 0, 0.4);
  }
}

.chat-notify-btn.notify-pulse {
  animation: notify-pulse 1.4s ease-in-out infinite;
}

.btn-info:hover {
  background: var(--admin-accent-dark);
}

.btn-danger {
  background: #ff4444;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.2s;
}

.btn-danger:hover {
  background: #cc0000;
}

.user-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.detail-label {
  font-size: 12px;
  color: #666;
  font-weight: 500;
}

.detail-value {
  font-size: 14px;
  color: #333;
}

.detail-edit-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

/* ============================================== */
/* ВХОДЯЩИ ЧАТ ПРОЗОРЦИ (FLOATING) */
/* ============================================== */
.incoming-chat-windows {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  z-index: 9999;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: calc(100vw - 40px);
}

.chat-window {
  width: 380px;
  height: 620px;
  max-height: calc(100vh - 40px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.24);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: none;
  animation: slideIn 0.3s ease-out;
  border: 1px solid rgba(var(--admin-accent-rgb), 0.18);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

.chat-window-header {
  background: linear-gradient(135deg, var(--admin-accent) 0%, var(--admin-accent-dark) 100%);
  color: white;
  padding: 18px 18px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
  font-weight: 600;
}

.chat-window-title-wrap {
  flex: 1;
  min-width: 0;
}

.chat-window-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-window-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.chat-window-title {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-window-subtitle {
  font-size: 12px;
  opacity: 0.92;
  margin-top: 3px;
}

.chat-window-userinfo-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.chat-window-history-btn {
  flex: 0 0 auto;
  position: relative;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.chat-window-history-count {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ff5a5f;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(255, 90, 95, 0.35);
}

.chat-window-history-count[hidden] {
  display: none;
}

.chat-window-history-btn:hover,
.chat-window-userinfo-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.chat-window-history-btn.active,
.chat-window-userinfo-btn.active {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.48);
}

.chat-window-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.chat-window-close {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.chat-window-close:hover {
  transform: scale(1.2);
}

.chat-window-minimize {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.chat-window-minimize:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-1px);
}

.chat-window.minimized {
  height: auto;
  min-height: 0;
  max-height: none;
}

.chat-window.minimized .chat-window-userdata,
.chat-window.minimized .chat-window-history,
.chat-window.minimized .chat-window-content,
.chat-window.minimized .chat-window-input {
  display: none !important;
}

.chat-window.minimized .chat-window-header {
  padding: 14px 18px;
}

.chat-window-userdata {
  background: #f8fbfb;
  border-bottom: 1px solid #e4eeee;
  padding: 12px 16px;
}

.chat-window-userdata[hidden] {
  display: none;
}

.chat-window-history {
  background: #f8fbfb;
  border-bottom: 1px solid #e4eeee;
  padding: 12px 16px;
  max-height: 280px;
  overflow: auto;
}

.chat-window-history[hidden] {
  display: none;
}

.chat-window-history-empty {
  padding: 12px;
  border-radius: 10px;
  background: #ffffff;
  color: #6b7c7c;
  font-size: 13px;
  border: 1px dashed #d7e6e6;
  text-align: center;
}

.chat-window-history-empty.error {
  color: #b42318;
  background: #fef3f2;
  border-color: #fecdca;
}

.chat-window-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.chat-window-history-item {
  width: 100%;
  text-align: left;
  border: 1px solid #dce8e8;
  border-left: 4px solid var(--admin-accent);
  border-radius: 12px;
  background: #ffffff;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.chat-window-history-item:hover {
  border-color: rgba(var(--admin-accent-rgb), 0.45);
  box-shadow: 0 8px 18px rgba(var(--admin-accent-rgb), 0.12);
  transform: translateY(-1px);
}

.chat-window-history-item.active {
  border-color: rgba(var(--admin-accent-rgb), 0.55);
  box-shadow: 0 10px 22px rgba(var(--admin-accent-rgb), 0.18);
}

.chat-window-history-item.is-offline {
  border-left-color: #f59e0b;
}

.chat-window-history-item-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.chat-window-history-date {
  color: #5f7272;
  font-size: 12px;
  font-weight: 600;
}

.chat-window-history-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(var(--admin-accent-rgb), 0.12);
  color: var(--admin-accent-dark);
  font-size: 11px;
  font-weight: 700;
}

.chat-window-history-badge.is-offline {
  background: #fff3e0;
  color: #b45309;
}

.chat-window-history-meta {
  color: #243333;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.chat-window-history-preview {
  color: #5f7272;
  font-size: 12px;
  line-height: 1.45;
}

.chat-window-history-detail {
  margin-top: 8px;
}

.chat-window-history-detail-card {
  background: #ffffff;
  border: 1px solid #dce8e8;
  border-radius: 12px;
  padding: 12px;
}

.chat-window-history-detail-card.is-offline {
  border-left: 4px solid #f59e0b;
}

.chat-window-history-detail-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12px;
  color: #5f7272;
}

.chat-window-history-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  color: #243333;
  font-size: 12px;
}

.chat-window-history-detail-grid .full {
  grid-column: 1 / -1;
}

.chat-window-history-offline-text {
  margin-top: 6px;
  padding: 10px;
  border-radius: 10px;
  background: #fff8eb;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.chat-window-history-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-window-history-message {
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid #dce8e8;
  background: #ffffff;
}

.chat-window-history-message.is-agent {
  background: rgba(var(--admin-accent-rgb), 0.08);
  border-color: rgba(var(--admin-accent-rgb), 0.22);
}

.chat-window-history-message-meta {
  font-size: 11px;
  color: #6b7c7c;
  margin-bottom: 6px;
  font-weight: 600;
}

.chat-window-history-message-body {
  font-size: 12px;
  color: #243333;
  line-height: 1.5;
  word-break: break-word;
}

.chat-window-userdata-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  font-size: 12px;
}

.chat-window-userdata-item {
  min-width: 0;
}

.chat-window-userdata-item.full {
  grid-column: 1 / -1;
}

.chat-window-userdata-label {
  color: #7b8a8a;
  font-size: 11px;
  margin-bottom: 2px;
}

.chat-window-userdata-value {
  color: #243333;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-window-userdata-value.multiline {
  white-space: normal;
  word-break: break-word;
}

.chat-window-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafafa;
}

.chat-window .chat-message {
  display: flex;
  margin-bottom: 14px;
  flex-direction: column;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-window .chat-message.user {
  align-items: flex-start;
}

.chat-window .chat-message.agent {
  align-items: flex-end;
}

.chat-window .chat-message.system {
  align-items: center;
}

.chat-window .chat-message-bubble {
  max-width: 76%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
  word-break: break-word;
}

.chat-window .chat-message.user .chat-message-bubble {
  background: white;
  color: #333;
  border: 1px solid #e0e0e0;
  border-bottom-left-radius: 4px;
}

.chat-window .chat-message.agent .chat-message-bubble {
  background: var(--admin-accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-window .chat-message.system .chat-message-bubble {
  background: #f0f0f0;
  color: #000;
  font-size: 12px;
  max-width: 92%;
}

.chat-window-message-time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

.chat-window-input {
  border-top: 1px solid #e0e0e0;
  padding: 14px 16px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: white;
  position: relative;
}

.chat-window-input-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: flex-end;
}

.chat-window-icon-btn {
  width: 34px !important;
  height: 34px !important;
  border-radius: 10px !important;
  font-size: 15px !important;
  line-height: 1;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  background: #f2f6f6 !important;
  color: #355 !important;
  border: 1px solid #d8e6e6 !important;
}

.chat-window-icon-btn:hover {
  background: #e4f1f1 !important;
  border-color: #c4dada !important;
  transform: translateY(-1px);
}

.chat-window-input textarea {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: none;
  min-height: 44px;
  max-height: 100px;
  font-family: inherit;
}

.chat-window-input textarea:focus {
  border-color: var(--admin-accent);
  box-shadow: 0 0 0 3px rgba(var(--admin-accent-rgb), 0.12);
}

.chat-window-shortcuts-dropdown {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(100% + 8px);
  background: #fff;
  border: 1px solid #dbe8e8;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
  max-height: 220px;
  overflow-y: auto;
  z-index: 6;
}

.chat-window-shortcuts-dropdown[hidden] {
  display: none;
}

.chat-window-shortcut-item {
  width: 100%;
  display: block;
  border: 0;
  border-bottom: 1px solid #edf4f4;
  background: #fff;
  color: #243333;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 0;
}

.chat-window-shortcut-item:last-child {
  border-bottom: none;
}

.chat-window-shortcut-item:hover,
.chat-window-shortcut-item.active {
  background: #eef7f7;
}

.chat-window-shortcut-text {
  font-size: 12px;
  color: #243333;
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
}

.chat-window-emoji-panel {
  position: absolute;
  right: 70px;
  bottom: calc(100% + 8px);
  background: #fff;
  border: 1px solid #dbe8e8;
  border-radius: 12px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
  z-index: 7;
}

.chat-window-emoji-panel[hidden] {
  display: none;
}

.chat-window-emoji-option {
  width: 30px !important;
  height: 30px !important;
  border-radius: 8px !important;
  border: 1px solid #e7efef !important;
  background: #fff !important;
  cursor: pointer;
  font-size: 16px !important;
  line-height: 1;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.chat-window-emoji-option:hover {
  background: #f2f8f8 !important;
}

.chat-window-input button {
  background: var(--admin-accent);
  color: white;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: transform 0.2s, background 0.2s;
}

.chat-window-input button:hover {
  background: var(--admin-accent-dark);
  transform: scale(1.04);
}

.detail-edit-input:focus {
  outline: none;
  border-color: var(--admin-accent);
  box-shadow: 0 0 0 2px rgba(var(--admin-accent-rgb), 0.1);
}

