/* ==================== СБРОС И ПЕРЕМЕННЫЕ ==================== */
*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  /* Фоновые тона */
  --bg-primary: #0f1115;
  --bg-secondary: #151922;
  --bg-card: #1a1f28;
  --bg-card-hover: #1f2633;
  --bg-chat: #1c2230;
  --bg-chat-dark: #171c26;
  --bg-chat-sidebar: #232a3b;
  --bg-chat-content: #2a3245;
  --bg-chat-avatar: #222838;

  /* Текст и границы */
  --text-primary: #eaeaea;
  --text-secondary: #b0b7c3;
  --border-color: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(74, 158, 255, 0.4);

  /* Тени и акценты */
  --shadow: rgba(0, 0, 0, 0.25);
  --shadow-elevated: rgba(0, 0, 0, 0.35);
  --accent-blue: #4a9eff;
  --accent-purple: #774aff;
  --accent-green: #2ecc71;
  --gradient-overlay: linear-gradient(135deg, rgba(74, 158, 255, 0.025) 0%, rgba(167, 139, 250, 0.025) 100%);

  /* Скругления и переходы */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== БАЗОВЫЕ СТИЛИ ==================== */
html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  position: relative;
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--gradient-overlay);
  pointer-events: none;
  z-index: 0;
}

/* Пользовательский скроллбар для современных браузеров */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-chat-sidebar);
  border-radius: var(--radius-sm);
  border: 2px solid var(--bg-primary);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-purple);
}

/* ==================== ШАПКА (HEADER) ==================== */
header {
  padding: 14px 24px;
  background: rgba(21, 25, 34, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 4px 16px var(--shadow), inset 0 -1px 0 var(--border-color);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.header-left,
.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* ==================== ПОИСК ==================== */
.header-search {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 640px;
  margin: 0 auto;
  gap: 10px;
}

#headerSearchInput {
  flex: 1;
  padding: 11px 44px 11px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#headerSearchInput::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

#headerSearchInput:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--border-focus);
}

/* ==================== КНОПКИ И ИКОНКИ ==================== */
.home-btn,
.refresh-btn,
.notifications-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-radius: var(--radius-sm);
  position: relative;
  text-decoration: none;
  line-height: 1;
}

.home-btn {
  font-size: 22px;
  padding: 10px;
}
.home-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: scale(1.08);
}

.refresh-btn,
.notifications-btn {
  width: 40px;
  height: 40px;
  font-size: 18px;
}

.refresh-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: rotate(180deg);
}

.notifications-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: scale(1.05);
}

.user-icon {
  width: 44px;
  height: 44px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 24px;
  transition: all var(--transition-fast);
  position: relative;
}

.user-icon:hover {
  transform: scale(1.06);
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(119, 74, 255, 0.25);
}

/* Безопасное состояние фокуса для клавиатурной навигации */
.home-btn:focus-visible,
.refresh-btn:focus-visible,
.notifications-btn:focus-visible,
.user-icon:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* ==================== БОКОВОЕ МЕНЮ (SIDEBAR) ==================== */
.sidebar {
  position: fixed;
  top: 68px;
  left: -320px;
  width: 320px;
  height: calc(100vh - 68px);
  background: rgba(21, 25, 34, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: 6px 0 24px var(--shadow-elevated);
  z-index: 150;
  transition: left var(--transition-normal);
  overflow-y: auto;
  border-right: 1px solid var(--border-color);
}

.sidebar.active {
  left: 0;
}

.sidebar-nav {
  padding: 20px 12px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 6px;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.sidebar-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(119, 74, 255, 0.08), transparent);
  transform: translateX(-100%);
  transition: transform 0.4s ease;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.04);
  transform: translateX(-4px);
  color: var(--accent-blue);
}

.sidebar-item:hover::before {
  transform: translateX(0);
}

.sidebar-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.sidebar-item.disabled:hover {
  background: transparent;
  transform: none;
}

.sidebar-divider {
  height: 1px;
  background: var(--border-color);
  margin: 14px 4px;
}

/* ==================== БУРГЕР-МЕНЮ (АНИМАЦИЯ) ==================== */
.quick-menu-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}

.quick-menu-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.menu-line {
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition-normal);
  transform-origin: center;
}

.quick-menu-btn.rotated .menu-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.quick-menu-btn.rotated .menu-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.quick-menu-btn.rotated .menu-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.quick-menu-btn:hover .menu-line {
  background: var(--accent-purple);
}

/* ==================== ПОДВАЛ (FOOTER) ==================== */
footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.7;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
  position: relative;
  z-index: 1;
}

/* ==================== АДАПТИВНОСТЬ ==================== */
@media (max-width: 768px) {
  header {
    padding: 12px 14px;
    gap: 12px;
  }

  .header-search {
    display: none; /* Скрываем поиск на мобильных для экономии места */
  }

  .home-btn { padding: 8px; font-size: 20px; }
  .user-icon { width: 38px; height: 38px; font-size: 18px; }
  .sidebar { top: 60px; height: calc(100vh - 60px); }
  header { top: 0; padding-top: 12px; padding-bottom: 12px; }
}

/* ==================== ДОСТУПНОСТЬ И ПРОИЗВОДИТЕЛЬНОСТЬ ==================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Отключаем обводку для мыши, оставляем только для клавиатуры */
:focus:not(:focus-visible) {
  outline: none;
}