/* sidebar.css - современный красивый стиль для sidebar */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

* {
  box-sizing: border-box;
}

/* Предотвращение скролла когда сайдбар открыт */
body.sidebar-open {
  overflow: hidden;
}

.sidebar {
  position: fixed;
  top: 0;
  left: -300px; /* Start off-screen by default */
  bottom: 0;
  width: 300px;
  height: 100vh;
  max-height: 100vh;
  background: linear-gradient(145deg, #1e3c72 0%, #2a5298 35%, #3b82f6 70%, #6366f1 100%);
  box-shadow: 
    0 25px 50px rgba(0, 0, 0, 0.25), 
    0 15px 25px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  z-index: 1002;
  display: flex;
  transform: translateX(0);
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  backdrop-filter: blur(20px) saturate(180%);
  border-radius: 0;
  overflow: hidden;
  border: none;
  flex-direction: column;
}

/* Collapsed state */
.sidebar.collapsed {
  width: 80px;
}

.sidebar.collapsed .sidebar-text,
.sidebar.collapsed .sidebar-arrow,
.sidebar.collapsed .sidebar-copyright {
  opacity: 0;
  transform: translateX(-20px);
}

/* Open state */
.sidebar.open {
  left: 0; /* Move sidebar back into view when opened */
}

/* Reposition toggle button when sidebar is open */
.sidebar.open .sidebar-toggle-btn {
  left: 260px; /* Move toggle button to inside the sidebar when open */
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
  backdrop-filter: blur(20px);
  z-index: -1;
  animation: shimmer 4s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: slideVertical 3s ease-in-out infinite;
}

@keyframes slideVertical {
  0%, 100% { transform: translateY(-100%); }
  50% { transform: translateY(100%); }
}

/* Скрываем кнопку закрытия для статичного сайдбара */
.sidebar-close-btn {
  display: none;
}

/* Кнопка toggle для сворачивания/разворачивания */
.sidebar-toggle-btn {
  position: fixed;
  top: 20px;
  left: 20px; /* Position toggle button near left edge of screen */
  background: rgba(41, 64, 134, 0.8);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  backdrop-filter: blur(20px);
  z-index: 1003;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 
    0 6px 12px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.sidebar-toggle-btn svg {
  transition: all 0.3s ease;
}

.sidebar-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
  box-shadow: 
    0 8px 16px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Поворот стрелки когда открыт/свернут */
.sidebar.open .sidebar-toggle-btn svg {
  transform: rotate(180deg);
}

/* Заголовок сайдбара */
.sidebar-header {
  padding: 32px 24px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-header::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  border-radius: 20px;
  background: 
    linear-gradient(145deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05)),
    linear-gradient(45deg, rgba(99, 102, 241, 0.3), rgba(59, 130, 246, 0.3));
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 
    0 12px 24px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.sidebar-logo::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: rotate(45deg);
  transition: all 0.6s ease;
  opacity: 0;
}

.sidebar-logo:hover::before {
  opacity: 1;
  animation: shine 0.8s ease-in-out;
}

@keyframes shine {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.sidebar-logo:hover {
  transform: scale(1.08) rotate(-2deg);
  background: 
    linear-gradient(145deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.1)),
    linear-gradient(45deg, rgba(99, 102, 241, 0.4), rgba(59, 130, 246, 0.4));
  box-shadow: 
    0 16px 32px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 20px;
  transition: all 0.3s ease;
}

.sidebar-title {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.5px;
  text-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 1px 3px rgba(0, 0, 0, 0.2);
  background: linear-gradient(135deg, #ffffff 0%, #e0e7ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative;
}

/* Меню */
.sidebar-menu {
  padding: 16px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  justify-content: center;
}

.sidebar-item {
  position: relative;
  transform: translateX(-30px);
  opacity: 0;
}

.sidebar-item a {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  text-decoration: none;
  border-radius: 16px;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: hidden;
  background: 
    linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  justify-content: flex-start;
}

/* Центрирование в свернутом состоянии */
.sidebar.collapsed .sidebar-item a {
  justify-content: center;
  padding: 14px;
}

.sidebar-item a::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.1), 
    rgba(255, 255, 255, 0.2), 
    rgba(255, 255, 255, 0.1), 
    transparent
  );
  transition: all 0.8s ease;
  z-index: 1;
}

.sidebar-item a::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, 
    rgba(99, 102, 241, 0.1) 0%, 
    rgba(59, 130, 246, 0.1) 50%, 
    rgba(147, 51, 234, 0.1) 100%
  );
  opacity: 0;
  transition: all 0.4s ease;
  z-index: 1;
}

.sidebar-item a:hover::before {
  left: 100%;
}

.sidebar-item a:hover::after {
  opacity: 1;
}

.sidebar-item a:hover {
  background: 
    linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
  transform: translateX(12px) scale(1.02) rotate(-1deg);
  box-shadow: 
    0 12px 28px rgba(99, 102, 241, 0.25),
    0 6px 12px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border-color: rgba(99, 102, 241, 0.3);
}

.sidebar-item a:active {
  transform: translateX(8px) scale(0.98);
}

/* Иконка */
.sidebar-icon {
  width: 44px;
  height: 44px;
  margin-right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: 
    linear-gradient(145deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08));
  border-radius: 14px;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 
    0 6px 12px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

.sidebar-icon::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: rotate(45deg);
  transition: all 0.6s ease;
  opacity: 0;
}

.sidebar-item a:hover .sidebar-icon::before {
  opacity: 1;
  animation: iconShine 0.8s ease-in-out;
}

@keyframes iconShine {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.sidebar-item a:hover .sidebar-icon {
  background: 
    linear-gradient(145deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.15));
  transform: scale(1.1) rotate(-3deg);
  box-shadow: 
    0 8px 16px rgba(99, 102, 241, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  border-color: rgba(99, 102, 241, 0.3);
}

.sidebar-icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: brightness(1.2) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
  transition: all 0.3s ease;
}

.sidebar-item a:hover .sidebar-icon img {
  filter: brightness(1.4) drop-shadow(0 3px 8px rgba(99, 102, 241, 0.3));
  transform: scale(1.05);
}

/* Текст */
.sidebar-text {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  flex: 1;
  letter-spacing: 0.4px;
  font-family: 'Inter', sans-serif;
  text-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 2;
  transition: all 0.3s ease;
}

.sidebar-item a:hover .sidebar-text {
  color: #ffffff;
  text-shadow: 
    0 3px 6px rgba(0, 0, 0, 0.4),
    0 0 12px rgba(255, 255, 255, 0.3);
  transform: translateX(2px);
}

/* Стрелка */
.sidebar-arrow {
  opacity: 0;
  transform: translateX(-15px) scale(0.8);
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  color: #fff;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
}

.sidebar-item a:hover .sidebar-arrow {
  opacity: 1;
  transform: translateX(0) scale(1);
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 
    0 4px 8px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.sidebar-arrow svg {
  transition: all 0.3s ease;
}

.sidebar-item a:hover .sidebar-arrow svg {
  transform: translateX(2px);
}

/* Подвал */
.sidebar-footer {
  padding: 16px 24px 20px;
  margin-top: auto;
  position: relative;
  flex-shrink: 0;
}

.sidebar-footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.3), 
    rgba(255, 255, 255, 0.5),
    rgba(255, 255, 255, 0.3), 
    transparent
  );
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.sidebar-divider {
  height: 2px;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.2), 
    rgba(99, 102, 241, 0.4),
    rgba(255, 255, 255, 0.2), 
    transparent
  );
  margin-bottom: 20px;
  border-radius: 1px;
  position: relative;
  overflow: hidden;
}

.sidebar-divider::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.6), 
    transparent
  );
  animation: dividerShine 3s ease-in-out infinite;
}

@keyframes dividerShine {
  0%, 100% { left: -100%; }
  50% { left: 100%; }
}

.sidebar-copyright {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.95rem;
  text-align: center;
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.9) 0%, 
    rgba(224, 231, 255, 0.8) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Анимация появления элементов */
.sidebar-item {
  opacity: 0;
  transform: translateX(-40px) translateY(10px);
  animation: slideInFromLeft 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.sidebar-item:nth-child(1) { animation-delay: 0.1s; }
.sidebar-item:nth-child(2) { animation-delay: 0.2s; }
.sidebar-item:nth-child(3) { animation-delay: 0.3s; }
.sidebar-item:nth-child(4) { animation-delay: 0.4s; }
.sidebar-item:nth-child(5) { animation-delay: 0.5s; }
.sidebar-item:nth-child(6) { animation-delay: 0.6s; }

@keyframes slideInFromLeft {
  0% {
    opacity: 0;
    transform: translateX(-40px) translateY(10px) scale(0.9);
  }
  60% {
    opacity: 0.8;
    transform: translateX(5px) translateY(-2px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1);
  }
}

/* Анимация для заголовка и подвала */
.sidebar-header {
  opacity: 0;
  transform: translateY(-20px);
  animation: fadeInDown 0.8s ease forwards;
  animation-delay: 0.2s;
}

.sidebar-footer {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.8s ease forwards;
  animation-delay: 0.7s;
}

@keyframes fadeInDown {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Дополнительные эффекты при открытии */
.sidebar.open .sidebar-header {
  animation-play-state: running;
}

.sidebar.open .sidebar-item {
  animation-play-state: running;
}

.sidebar.open .sidebar-footer {
  animation-play-state: running;
}

/* Адаптивность */
@media (max-width: 768px) {
  .sidebar {
    width: 90vw;
    max-width: 340px;
    border-radius: 0 28px 28px 0;
  }
  
  .sidebar-close-btn {
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }
  
  .sidebar-header {
    padding: 45px 24px 32px;
  }
  
  .sidebar-logo {
    width: 64px;
    height: 64px;
    border-radius: 20px;
  }
  
  .sidebar-title {
    font-size: 1.2rem;
  }
  
  .sidebar-menu {
    padding: 20px 16px;
    gap: 6px;
  }
  
  .sidebar-item a {
    padding: 16px 18px;
    border-radius: 18px;
  }
  
  .sidebar-icon {
    width: 46px;
    height: 46px;
    margin-right: 14px;
    border-radius: 14px;
  }
  
  .sidebar-icon img {
    width: 26px;
    height: 26px;
  }
  
  .sidebar-text {
    font-size: 1.05rem;
  }
  
  .sidebar-arrow {
    width: 28px;
    height: 28px;
    border-radius: 10px;
  }
  
  .sidebar-footer {
    padding: 24px 24px 28px;
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 95vw;
    border-radius: 0 24px 24px 0;
  }
  
  .sidebar-close-btn {
    top: 18px;
    right: 18px;
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }
  
  .sidebar-header {
    padding: 40px 20px 28px;
  }
  
  .sidebar-logo {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    margin-bottom: 16px;
  }
  
  .sidebar-title {
    font-size: 1.1rem;
  }
  
  .sidebar-menu {
    padding: 16px 12px;
    gap: 4px;
  }
  
  .sidebar-item a {
    padding: 14px 16px;
    border-radius: 16px;
  }
  
  .sidebar-icon {
    width: 42px;
    height: 42px;
    margin-right: 12px;
    border-radius: 12px;
  }
  
  .sidebar-icon img {
    width: 24px;
    height: 24px;
  }
  
  .sidebar-text {
    font-size: 1rem;
  }
  
  .sidebar-arrow {
    width: 26px;
    height: 26px;
    border-radius: 8px;
  }
  
  .sidebar-footer {
    padding: 20px 20px 24px;
  }
  
  .sidebar-copyright {
    font-size: 0.9rem;
  }
}

/* Дополнительные улучшения для темной темы */
@media (prefers-color-scheme: dark) {
  .sidebar {
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 35%, #334155 70%, #475569 100%);
    box-shadow: 
      0 25px 50px rgba(0, 0, 0, 0.4), 
      0 15px 25px rgba(0, 0, 0, 0.25),
      inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }
}

/* Улучшенная прозрачность для современных браузеров */
@supports (backdrop-filter: blur(20px)) {
  .sidebar {
    backdrop-filter: blur(20px) saturate(180%);
  }
  
  .sidebar::before {
    backdrop-filter: blur(25px);
  }
  
  .sidebar-close-btn {
    backdrop-filter: blur(15px);
  }
  
  .sidebar-logo {
    backdrop-filter: blur(25px);
  }
}

/* Плавные переходы для reduce motion */
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar *,
  .sidebar *::before,
  .sidebar *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
