/* =============================================
   TIMPRO — Final Polish CSS
   Анимации, mobile, loading states, финальные детали
   ============================================= */

/* --- Плавные переходы страниц --- */
.workspace, .admin-layout {
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* --- Skeleton loading --- */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-tertiary) 0%, var(--bg-hover) 50%, var(--bg-tertiary) 100%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text  { height: 14px; margin-bottom: 8px; }
.skeleton-circle { border-radius: 50%; }
.skeleton-avatar { width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; }

/* --- Spinner --- */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Улучшенные hover-эффекты --- */
.btn-primary:active   { transform: scale(0.97); }
.btn-secondary:active { transform: scale(0.97); }
.send-btn:active      { transform: scale(0.92) !important; }

/* --- Анимация появления диалогов --- */
.dialog-item {
  animation: slideIn 0.2s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: none; }
}

/* --- Анимация появления сообщений --- */
.msg-group {
  animation: msgIn 0.18s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* --- Анимация карточек задач --- */
.task-card {
  animation: cardIn 0.2s ease;
}
@keyframes cardIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* --- Улучшенный скроллбар для чата --- */
.chat-messages::-webkit-scrollbar { width: 4px; }
.dialogs-list::-webkit-scrollbar  { width: 4px; }
.kanban-col-body::-webkit-scrollbar { width: 4px; }

/* --- Status indicator (онлайн) --- */
.online-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--bg-secondary);
  position: absolute;
  bottom: 0; right: 0;
}

/* --- Горячие клавиши бейдж --- */
.kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  color: var(--text-muted);
}

/* --- Floating action button (мобильный) --- */
.fab {
  position: fixed;
  bottom: 80px; right: 16px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-size: 22px;
  display: none;
  align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(46,125,255,0.4);
  cursor: pointer;
  border: none;
  z-index: 100;
  transition: var(--transition);
}
.fab:hover { transform: scale(1.08); }
.fab:active { transform: scale(0.95); }

/* --- Tooltips улучшенные --- */
[title]:not(.nav-item):not(button) {
  position: relative;
}

/* --- Индикатор набора текста --- */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 8px 14px;
}
.typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s ease infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* --- Пустые состояния --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; line-height: 1; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); }
.empty-state-sub { font-size: 13px; max-width: 240px; line-height: 1.5; }

/* =============================================
   MOBILE RESPONSIVE (< 768px)
   ============================================= */

@media (max-width: 768px) {
  /* Скрываем сайдбар диалогов по умолчанию */
  .dialogs-panel {
    position: fixed !important;
    left: 64px !important;
    top: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-110%) !important;
    transition: transform 0.3s ease !important;
    box-shadow: var(--shadow-lg);
    width: 280px !important;
  }
  .dialogs-panel.mobile-open {
    transform: translateX(0) !important;
  }

  /* Навбар на мобильном — горизонтальный снизу */
  .nav-sidebar {
    position: fixed !important;
    bottom: 0; left: 0; right: 0;
    top: auto !important;
    width: 100% !important;
    height: 58px !important;
    flex-direction: row !important;
    padding: 0 8px !important;
    justify-content: space-around !important;
    border-right: none !important;
    border-top: 1px solid var(--border);
    z-index: 100;
  }

  .nav-logo { display: none !important; }
  .nav-item .tooltip { display: none !important; }
  .nav-bottom {
    flex-direction: row !important;
    margin-top: 0 !important;
    gap: 0 !important;
  }

  /* Основная область — убираем нижний padding для navbar */
  .workspace {
    padding-bottom: 58px;
  }

  /* Главная область — полная ширина */
  .chat-area, #mainArea {
    width: 100% !important;
  }

  /* FAB на мобильном */
  .fab { display: flex; }

  /* Задачи */
  .tasks-topbar { padding: 0 12px; }
  .tasks-filters { padding: 8px 12px; gap: 6px; }
  .tasks-filters .search-box { width: 100%; }

  /* Панель клиента — полноэкранная */
  .client-panel.open {
    position: fixed !important;
    right: 0; top: 0; bottom: 58px;
    width: 280px !important;
    min-width: 280px !important;
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }

  /* Сообщения */
  .msg-bubble { max-width: 88% !important; }

  /* Шапка чата */
  .chat-header { padding: 0 10px; }
  .chat-header-actions .icon-btn:nth-child(n+3) { display: none; }

  /* Модалки */
  .modal { margin: 10px; }
  .task-modal-body { grid-template-columns: 1fr !important; }

  /* Доски */
  .boards-grid { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 480px) {
  .boards-grid { grid-template-columns: 1fr !important; }
  .kanban-view { padding: 10px 8px; gap: 10px; }
  .kanban-col { width: 260px; min-width: 260px; }
  .login-card { padding: 24px 16px !important; }
}

/* =============================================
   УЛУЧШЕНИЯ ИНТЕРФЕЙСА
   ============================================= */

/* Кнопка "наверх" в чате */
.scroll-to-bottom {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: var(--transition);
  z-index: 10;
}
.scroll-to-bottom:hover { background: var(--accent); color: white; border-color: var(--accent); }
.scroll-to-bottom.show { display: flex; }

/* Разделитель "непрочитанные сообщения" */
.unread-divider {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin: 12px 0;
  position: relative;
}
.unread-divider::before, .unread-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 60px);
  height: 1px;
  background: var(--accent);
  opacity: 0.3;
}
.unread-divider::before { left: 0; }
.unread-divider::after  { right: 0; }

/* Закреплённое сообщение */
.pinned-msg {
  padding: 8px 14px;
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 8px;
}
.pinned-msg.show { display: flex; }

/* --- Улучшение кнопок тулбара --- */
.toolbar-btn {
  border-radius: var(--radius-sm) !important;
  font-size: 12px !important;
}

/* --- Cmd+K подсказка --- */
.cmdK-hint {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-muted);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 200;
}
.cmdK-hint.show { opacity: 1; }

/* --- Improved focus states --- */
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Print styles --- */
@media print {
  .nav-sidebar, .dialogs-panel, .chat-input-area, .milash-bar { display: none !important; }
  .chat-messages { overflow: visible !important; height: auto !important; }
  .msg-bubble { break-inside: avoid; }
}
