:root {
  --bg: #0b1020;
  --bg-2: #0f152b;
  --text: #e6e9f2;
  --muted: #a8b0c3;
  --primary: #2563eb;
  --primary-2: #ec4899;
  --accent: #f0abfc;
  --card: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius-xl: 20px;
  --nav-search-margin: 6px; /* Расстояние между навигацией и поиском */
}

/* Светлая тема по умолчанию */
:root {
  --bg: #f7f8fb;
  --bg-2: #ffffff;
  --text: #0b1020;
  --muted: #4b576b;
  --card: rgba(10, 10, 10, 0.04);
  --border: rgba(10, 10, 10, 0.1);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --nav-search-margin: 6px; /* Расстояние между навигацией и поиском */
}


/* Темная тема только когда явно включена */
body.dark {
  --bg: #0b1020;
  --bg-2: #0f152b;
  --text: #e6e9f2;
  --muted: #a8b0c3;
  --card: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --nav-search-margin: 6px; /* Расстояние между навигацией и поиском */
}

/* Feather Icons Sizing */
[data-feather] {
  width: 16px;
  height: 16px;
  vertical-align: middle;
}

/* Smaller icons for navigation */
.nav-links [data-feather] {
  width: 14px;
  height: 14px;
}

/* Larger icons for headers */
h1 [data-feather] {
  width: 20px;
  height: 20px;
}

/* Medium icons for buttons */
button [data-feather] {
  width: 16px;
  height: 16px;
}

/* Навигация */
#navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(12px);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: none;
  margin: 0 12px;
  margin-bottom: -1px;
  border-radius: 0 0 24px 24px;
  padding: 0 12px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-links {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 8px;
}

.nav-links a {
  padding: 8px 16px;
  border-radius: 12px;
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  opacity: 0.8;
  transition: all 0.2s ease;
}

.nav-links a:hover {
  color: var(--text);
  opacity: 1;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(236, 72, 153, 0.12));
  transform: translateY(-1px);
  font-weight: 600;
}

.nav-links a.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15), rgba(236, 72, 153, 0.15));
  opacity: 1;
  font-weight: 600;
}

/* Дропдауны */
.dropdown {
  position: relative;
}

.dropdown-btn {
  padding: 8px 16px;
  border-radius: 12px;
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  opacity: 0.8;
  transition: all 0.2s ease;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.dropdown-btn:hover {
  opacity: 1;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(236, 72, 153, 0.12));
  transform: translateY(-1px);
  font-weight: 600;
}

.dropdown-btn.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15), rgba(236, 72, 153, 0.15));
  opacity: 1;
  color: var(--text);
  font-weight: 600;
}

.dropdown-btn::after {
  content: '▼';
  font-size: 10px;
  transition: transform 0.2s ease;
}

.dropdown-content {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  min-width: 200px;
  background: var(--bg-2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.98);
  transform-origin: top left;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown:hover .dropdown-content {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dropdown-content a {
  display: block;
  padding: 12px 16px;
  color: var(--text);
  font-size: 14px;
  border-radius: 8px;
  transition: all 0.2s ease;
  opacity: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  background: var(--bg-2);
}

.dropdown-content a:last-child {
  border-bottom: none;
}

.dropdown-content a:hover {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(236, 72, 153, 0.18));
  transform: translateX(4px);
  font-weight: 600;
}

/* Поиск */
#navbar .nav-search {
  position: relative;
  margin-left: var(--nav-search-margin, 6px) !important; /* Настраиваемое расстояние с приоритетом */
}

#searchInput {
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 14px;
  width: 200px;
  transition: all 0.3s ease;
}

#searchInput:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  width: 300px;
}

#searchResults {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 400px;
  background: var(--bg-2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.35);
  max-height: 400px;
  overflow-y: auto;
  display: none;
}

#searchResults li {
  padding: 12px 16px;
  border-bottom: 1px solid var(--card-border);
  transition: all 0.2s ease;
  background: var(--card-bg);
}

body.dark #searchResults li {
  background: var(--card-bg);
  border-color: var(--card-border);
}

#searchResults li:hover {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(236, 72, 153, 0.18));
}

#searchResults li:last-child {
  border-bottom: none;
}

#searchResults a {
  color: var(--text);
  font-weight: 600;
  opacity: 1;
}

#searchResults a:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#searchResults p {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 0;
  opacity: 1;
  line-height: 1.5;
}

.highlight {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(236, 72, 153, 0.2));
  padding: 2px 4px;
  border-radius: 4px;
}

/* Кнопка выхода */
.nav-logout-btn {
  padding: 8px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  border: none;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-left: 12px;
}

.nav-logout-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

/* Кнопка мобильного меню */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 24px;
}

/* Мобильная версия */
@media (max-width: 768px) {
  #navbar {
    padding: 0 16px;
    height: 64px;
  }

  .mobile-menu-btn {
    display: block;
    margin-right: 16px;
  }

  .nav-links {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    padding: 16px;
    flex-direction: column;
    gap: 8px;
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    height: auto;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
  }

  body.dark .nav-links {
    background: var(--card-bg);
    border-color: var(--card-border);
  }

  .nav-links.show {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .nav-links a,
  .dropdown-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    opacity: 1;
  }

  .dropdown {
    width: 100%;
  }

  .dropdown-content {
    position: static;
    width: 100%;
    margin: 0;
    transform: none;
    box-shadow: none;
    background: var(--card-bg);
    padding: 0;
    height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  body.dark .dropdown-content {
    background: var(--card-bg);
  }

  body.dark .dropdown-btn.active {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(236, 72, 153, 0.2));
    opacity: 1;
    color: var(--text);
  }

  .dropdown.open .dropdown-content {
    height: auto;
    opacity: 1;
    visibility: visible;
    padding: 8px 0 8px 16px;
    border-left: 2px solid var(--card-border);
  }

  body.dark .dropdown.open .dropdown-content {
    border-left-color: var(--card-border);
  }

  .dropdown-content a {
    padding: 10px 16px;
    font-size: 15px;
  }

  /* Поиск на мобильных */
  .nav-search {
    width: 100%;
    margin: 8px 0;
  }

  #searchInput {
    width: 100%;
    max-width: none;
  }

  #searchInput:focus {
    width: 100%;
  }

  #searchResults {
    width: 100%;
    left: 0;
    right: 0;
  }
}

/* Темная тема для поиска */
body.dark #navbar .nav-search {
  margin-left: var(--nav-search-margin, 6px) !important;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
  #navbar .nav-search {
    margin-left: 8px !important; /* Немного больше расстояния на мобильных */
  }
}
