/* =====================================================
   SITE HEADER - Компактный минималистичный дизайн
   Mobile-first approach
   Breakpoints: 768px (tablet), 1024px (desktop)

   Структура мобильной шапки:
   [Лого] [---Поиск---] [Burger]

   Структура desktop шапки:
   [Лого] [Nav меню] [---Поиск---] [Actions] [User]
   ===================================================== */

/* ----- CSS Custom Properties ----- */
.site-header {
  --sh-height: 56px;
  --sh-bg: #121111;
  --sh-border: rgba(255, 255, 255, 0.08);
  --sh-text: #ffffff;
  --sh-text-muted: #a0a0a0;
  --sh-accent: #e34449;
  --sh-accent-hover: #ff5a5f;
  --sh-input-bg: #1a1a1a;
  --sh-dropdown-bg: #1a1a1a;
  --sh-transition: 0.2s ease;
  --sh-radius: 8px;
  --sh-gap: 12px;
}

/* ----- Reset for header elements ----- */
.site-header,
.site-header *,
.site-header *::before,
.site-header *::after {
  box-sizing: border-box;
}

.site-header ul,
.site-header ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-header a {
  text-decoration: none;
  color: inherit;
}

.site-header button {
  font-family: inherit;
}

/* ----- Base Header ----- */
.site-header {
  position: relative;
  width: 100%;
  background-color: var(--sh-bg);
  border-bottom: 1px solid var(--sh-border);
  z-index: 1000;
}

.site-header__container {
  display: flex;
  align-items: center;
  gap: var(--sh-gap);
  max-width: 1920px;
  height: var(--sh-height);
  margin: 0 auto;
  padding: 0 12px;
}

/* ----- Logo ----- */
.site-header__logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.site-header__logo img {
  display: block;
  width: auto;
  height: 28px;
  max-width: 100px;
  object-fit: contain;
}

/* ----- SVG Icons ----- */
.site-header svg.site-header__icon {
  display: block;
  flex-shrink: 0;
  fill: currentColor;
  transition: color var(--sh-transition), transform var(--sh-transition);
}

/* Icon sizes by context */
.site-header__search-btn svg.site-header__icon {
  width: 18px;
  height: 18px;
  color: var(--sh-accent);
}

.site-header__action-btn svg.site-header__icon {
  width: 20px;
  height: 20px;
}

.site-header__icon--star {
  color: #ffc107;
}

.site-header__icon--dropdown {
  width: 12px;
  height: 12px;
  margin-left: 4px;
}

.site-header__avatar svg.site-header__icon {
  width: 18px;
  height: 18px;
  color: var(--sh-text-muted);
}

.site-header__dropdown-link svg.site-header__icon {
  width: 16px;
  height: 16px;
  color: var(--sh-text-muted);
  flex-shrink: 0;
}

.site-header__mobile-action svg.site-header__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ----- Search (visible on all screens) ----- */
.site-header__search {
  display: flex;
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

.site-header__search-input {
  width: 100%;
  height: 36px;
  padding: 0 38px 0 12px;
  font-size: 14px;
  color: var(--sh-text);
  background-color: var(--sh-input-bg);
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-radius);
  outline: none;
  transition: border-color var(--sh-transition), background-color var(--sh-transition);
}

.site-header__search-input::placeholder {
  color: var(--sh-text-muted);
}

.site-header__search-input:focus,
.site-header__search-input:focus-visible {
  border-color: var(--sh-accent);
  background-color: #0d0d0d;
  outline: none;
}

.site-header__search-btn {
  position: absolute;
  top: 50%;
  right: 2px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color var(--sh-transition);
}

.site-header__search-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* ----- Navigation (hidden on mobile/tablet) ----- */
.site-header__nav {
  display: none;
}

.site-header__menu {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-header__menu-item {
  margin: 0;
}

.site-header__link {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--sh-text);
  border-radius: var(--sh-radius);
  transition: background-color var(--sh-transition), color var(--sh-transition);
  white-space: nowrap;
}

.site-header__link:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--sh-text);
}

.site-header__link.is-active {
  color: var(--sh-accent);
}

.site-header__link--highlight {
  color: var(--sh-accent);
}

.site-header__link--highlight:hover {
  background-color: rgba(227, 68, 73, 0.15);
  color: var(--sh-accent);
}

/* ----- Action Buttons (hidden on mobile/tablet) ----- */
.site-header__actions {
  display: none;
  align-items: center;
  gap: 4px;
}

.site-header__action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--sh-text);
  border-radius: var(--sh-radius);
  transition: background-color var(--sh-transition);
}

.site-header__action-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--sh-text);
}

.site-header__action-btn--premium {
  color: #ffc107;
}

.site-header__action-btn--premium:hover {
  background-color: rgba(255, 193, 7, 0.12);
  color: #ffc107;
}

.site-header__action-text {
  display: none;
}

/* ----- User Section (hidden on mobile/tablet) ----- */
.site-header__user {
  display: none;
  margin-left: auto;
}

/* Profile (logged in) */
.site-header__profile {
  position: relative;
}

.site-header__profile-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--sh-text);
  background: transparent;
  border: none;
  border-radius: var(--sh-radius);
  cursor: pointer;
  transition: background-color var(--sh-transition);
}

.site-header__profile-toggle:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.site-header__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background-color: var(--sh-input-bg);
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.site-header__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.site-header__username {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Profile Dropdown */
.site-header__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background-color: var(--sh-dropdown-bg);
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity var(--sh-transition), visibility var(--sh-transition), transform var(--sh-transition);
  z-index: 100;
}

.site-header__profile.is-open .site-header__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.site-header__profile.is-open .site-header__icon--dropdown {
  transform: rotate(180deg);
}

.site-header__dropdown-list {
  padding: 6px 0;
}

.site-header__dropdown-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--sh-text);
  transition: background-color var(--sh-transition);
}

.site-header__dropdown-link:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--sh-text);
}

.site-header__dropdown-link--logout {
  color: var(--sh-accent);
}

.site-header__dropdown-link--logout svg.site-header__icon {
  color: var(--sh-accent);
}

.site-header__dropdown-divider {
  height: 1px;
  margin: 6px 0;
  background-color: var(--sh-border);
}

/* Auth Buttons (logged out) */
.site-header__auth {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-header__auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--sh-radius);
  cursor: pointer;
  transition: background-color var(--sh-transition), border-color var(--sh-transition);
}

.site-header__auth-btn--login {
  color: var(--sh-text);
  background-color: transparent;
  border: 1px solid var(--sh-border);
}

.site-header__auth-btn--login:hover {
  border-color: var(--sh-text-muted);
  color: var(--sh-text);
}

.site-header__auth-btn--signup {
  color: #fff;
  background-color: var(--sh-accent);
  border: 1px solid var(--sh-accent);
}

.site-header__auth-btn--signup:hover {
  background-color: var(--sh-accent-hover);
  border-color: var(--sh-accent-hover);
  color: #fff;
}

/* ----- Burger Menu ----- */
.site-header__burger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  padding: 9px;
  background: transparent;
  border: none;
  border-radius: var(--sh-radius);
  cursor: pointer;
  transition: background-color var(--sh-transition);
}

.site-header__burger:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.site-header__burger-line {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--sh-text);
  border-radius: 2px;
  transition: transform var(--sh-transition), opacity var(--sh-transition);
}

.site-header__burger.is-active .site-header__burger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.site-header__burger.is-active .site-header__burger-line:nth-child(2) {
  opacity: 0;
}

.site-header__burger.is-active .site-header__burger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ----- Mobile Menu ----- */
.site-header__mobile-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 0;
  background-color: var(--sh-bg);
  border-bottom: 1px solid var(--sh-border);
  overflow: hidden;
  transition: max-height 0.3s ease;
  z-index: 999;
}

.site-header__mobile-menu.is-open {
  max-height: calc(100vh - var(--sh-height));
  overflow-y: auto;
}

.site-header__mobile-inner {
  padding: 16px;
}

/* Mobile Search - скрыт, т.к. поиск в основной шапке */
.site-header__mobile-search {
  display: none;
}

/* Mobile Nav */
.site-header__mobile-nav {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--sh-border);
}

.site-header__mobile-link {
  display: flex;
  align-items: center;
  padding: 12px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--sh-text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.site-header__mobile-link:last-child {
  border-bottom: none;
}

.site-header__mobile-link.is-active {
  color: var(--sh-accent);
}

.site-header__mobile-link--highlight {
  color: var(--sh-accent);
}

/* Mobile Actions */
.site-header__mobile-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--sh-border);
}

.site-header__mobile-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--sh-text);
  background-color: var(--sh-input-bg);
  border-radius: var(--sh-radius);
  transition: background-color var(--sh-transition);
}

.site-header__mobile-action:hover,
.site-header__mobile-action:active {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--sh-text);
}

.site-header__mobile-action--premium {
  color: #ffc107;
}

.site-header__mobile-action--premium svg.site-header__icon {
  color: #ffc107;
}

.site-header__mobile-action--logout {
  color: var(--sh-accent);
}

.site-header__mobile-action--logout svg.site-header__icon {
  color: var(--sh-accent);
}

/* Mobile User */
.site-header__mobile-user {
  padding-top: 8px;
}

.site-header__mobile-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--sh-border);
}

.site-header__mobile-profile .site-header__avatar {
  width: 40px;
  height: 40px;
}

.site-header__mobile-username {
  font-size: 15px;
  font-weight: 600;
  color: var(--sh-text);
}

.site-header__mobile-profile-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.site-header__mobile-auth {
  display: flex;
  gap: 8px;
}

.site-header__mobile-auth .site-header__auth-btn {
  flex: 1;
  height: 42px;
  font-size: 14px;
}

/* =====================================================
   TABLET (768px+)
   ===================================================== */
@media (min-width: 768px) {
  .site-header {
    --sh-height: 60px;
    --sh-gap: 16px;
  }

  .site-header__container {
    padding: 0 20px;
  }

  .site-header__logo img {
    height: 32px;
    max-width: 120px;
  }

  .site-header__search {
    max-width: 300px;
  }

  .site-header__search-input {
    height: 38px;
    font-size: 14px;
  }

  .site-header__mobile-inner {
    padding: 20px;
  }
}

/* =====================================================
   DESKTOP (1024px+)
   ===================================================== */
@media (min-width: 1024px) {
  .site-header {
    --sh-height: 60px;
    --sh-gap: 20px;
  }

  .site-header__container {
    padding: 0 28px;
  }

  .site-header__logo img {
    height: 36px;
  }

  /* Show navigation */
  .site-header__nav {
    display: flex;
    margin-left: 16px;
  }

  /* Search stays flexible */
  .site-header__search {
    max-width: 320px;
    margin-left: auto;
  }

  /* Show actions */
  .site-header__actions {
    display: flex;
  }

  /* Show user section */
  .site-header__user {
    display: flex;
    margin-left: 8px;
  }

  /* Hide burger */
  .site-header__burger {
    display: none;
  }

  /* Hide mobile menu */
  .site-header__mobile-menu {
    display: none;
  }
}

/* =====================================================
   LARGE DESKTOP (1280px+)
   ===================================================== */
@media (min-width: 1280px) {
  .site-header {
    --sh-gap: 24px;
  }

  .site-header__container {
    padding: 0 36px;
  }

  .site-header__search {
    max-width: 400px;
  }

  .site-header__action-text {
    display: inline;
  }

  .site-header__link {
    padding: 8px 16px;
    font-size: 15px;
  }
}

/* =====================================================
   EXTRA LARGE (1440px+)
   ===================================================== */
@media (min-width: 1440px) {
  .site-header__search {
    max-width: 480px;
  }

  .site-header__nav {
    margin-left: 28px;
  }

  .site-header__menu {
    gap: 6px;
  }
}

/* =====================================================
   ACCESSIBILITY
   ===================================================== */
@media (prefers-reduced-motion: reduce) {
  .site-header,
  .site-header *,
  .site-header *::before,
  .site-header *::after {
    transition-duration: 0.01ms;
  }
}

/* Focus styles for interactive elements (except search input which has its own) */
.site-header a:focus-visible,
.site-header button:focus-visible {
  outline: 2px solid var(--sh-accent);
  outline-offset: 2px;
}

.site-header__search-input:focus-visible {
  outline: none;
}
