/* Общие стили header — аватар, кнопка входа */
:root {
  --mobile-nav-h: calc(62px + env(safe-area-inset-bottom, 0px));
  --touch-min: 44px;
}
.header-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid rgba(72, 132, 255, 0.4);
  background: linear-gradient(135deg, #4884ff, #3acf6b);
  text-decoration: none;
  transition: all 0.3s;
  flex-shrink: 0;
  margin-left: 4px;
}
.header-avatar:hover {
  border-color: #4884ff;
  box-shadow: 0 0 20px rgba(72, 132, 255, 0.35);
  transform: scale(1.05);
}
.user-avatar--photo {
  padding: 0;
  overflow: hidden;
  background: transparent;
}
.user-avatar-img,
.header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.profile-avatar-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.profile-avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: linear-gradient(135deg, #4884ff, #3acf6b);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 1.4rem;
  font-weight: 500;
}
.profile-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-avatar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.profile-avatar-hint {
  width: 100%;
  font-size: 0.72rem;
  opacity: 0.5;
  margin: 0;
}
.profile-avatar-upload {
  cursor: pointer;
  margin: 0;
}
.header-avatar__initials {
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  letter-spacing: 0.02em;
}
.header-login-btn {
  background: linear-gradient(135deg, #4884ff, #3a6fd8);
  border: none;
  color: #fff;
  padding: 10px 20px;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.3s;
  white-space: nowrap;
}
.header-login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(72, 132, 255, 0.3);
}

a.btn-primary {
  text-decoration: none;
  color: #fff;
}

.site-logo-img {
  display: block;
  max-height: 40px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
}
.site-logo-img--sidebar {
  max-height: 36px;
  margin-bottom: 4px;
}
.site-logo-img--admin {
  max-height: 28px;
  margin-right: 4px;
}
.logo .site-logo-img,
.sidebar-logo .site-logo-img {
  vertical-align: middle;
}

/* ── Публичный header (главная, каталог, view) ── */
.header.header--public,
.header.header--home {
  flex-wrap: nowrap;
}
.header--public,
.header--home {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.logo-area {
  display: flex;
  align-items: center;
  min-width: 0;
  flex-shrink: 1;
}
.logo-area .logo,
.logo-area .site-logo-img {
  max-height: 40px;
  max-width: 160px;
  object-fit: contain;
}
.header-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: var(--touch-min, 44px);
}
.header--public .header-actions,
.header--home .header-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}
.header-search-row {
  width: 100%;
}
.header-search-row .search-box,
.header-search-row .search-header {
  width: 100%;
}
.header-search-row .search-header.search-box {
  display: flex;
  align-items: center;
  position: relative;
  min-width: 0;
}
.header-search-row .search-header.search-box i {
  position: static;
  transform: none;
  left: auto;
  top: auto;
  margin-right: 10px;
}
.header-search-row .search-header.search-box input {
  padding: 10px 14px 10px 0;
  min-width: 0;
  flex: 1;
  border: none;
  background: transparent;
}
.header-catalog-link {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #eef2f6;
  text-decoration: none;
  flex-shrink: 0;
}
.mobile-only { display: none !important; }
.desktop-only { display: block; }

.menu-trigger { position: relative; }
.menu-btn {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.15);
  color: #eef2f6;
  padding: 10px 20px;
  border-radius: 50px;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s;
  font-weight: 400;
  backdrop-filter: blur(10px);
}
.menu-btn:hover {
  border-color: #4884ff;
  background: rgba(72,132,255,0.1);
}
.dropdown-menu {
  position: absolute;
  top: 55px;
  left: 0;
  min-width: 320px;
  background: rgba(20, 28, 40, 0.98);
  backdrop-filter: blur(30px);
  border-radius: 24px;
  padding: 16px 12px;
  box-shadow: 0 30px 50px -10px rgba(0,0,0,0.8);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.25s ease;
  z-index: 200;
  border: 1px solid rgba(72,132,255,0.2);
  max-height: 70vh;
  overflow-y: auto;
}
.menu-trigger:hover .dropdown-menu,
.menu-trigger:focus-within .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.menu-cat-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  color: #eef2f6;
  text-decoration: none;
  transition: 0.2s;
  margin-bottom: 2px;
}
.menu-cat-item:hover {
  background: rgba(72,132,255,0.08);
}
.menu-cat-img {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1e2a3a, #152030);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #4884ff;
  flex-shrink: 0;
}
.menu-cat-label small {
  display: block;
  font-size: 0.72rem;
  opacity: 0.6;
}

.search-wrap {
  flex: 1 1 250px;
  position: relative;
  max-width: 500px;
}
.header--public .search-wrap,
.header--home .search-wrap {
  max-width: none;
}
.search-box {
  background: rgba(255,255,255,0.03);
  border-radius: 60px;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(255,255,255,0.08);
  transition: all 0.3s;
}
.search-box:focus-within {
  border-color: #4884ff;
  box-shadow: 0 0 20px rgba(72,132,255,0.15);
}
.search-box i {
  color: #7f8fa0;
  margin-right: 12px;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.search-box input {
  background: transparent;
  border: none;
  width: 100%;
  color: white;
  outline: none;
  font-size: 0.95rem;
}

@media (max-width: 768px) {
  .mobile-only { display: flex !important; }
  .desktop-only { display: none !important; }

  .header.header--public,
  .header.header--home {
    padding: 8px 0;
    gap: 8px;
  }

  /* Строка 1: логотип | каталог | аватар */
  .header--public:not(.view-header) .header-top-row,
  .header--home .header-top-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
  }

  .header--public:not(.view-header) .logo-area,
  .header--home .logo-area {
    min-width: 0;
    overflow: hidden;
  }

  .header--public:not(.view-header) .logo-area .logo,
  .header--home .logo-area .logo,
  .header--public:not(.view-header) .logo-area .site-logo-img,
  .header--home .logo-area .site-logo-img {
    max-height: 34px;
    max-width: 130px;
  }

  .header--public .header-top-row .header-actions,
  .header--home .header-top-row .header-actions {
    margin-left: 0;
    flex-wrap: nowrap;
    gap: 6px;
    justify-self: end;
  }

  .header--public .menu-trigger,
  .header--home .menu-trigger { display: none !important; }

  /* На mobile — только аватар/вход (остальное в bottom nav) */
  .header--public .header-actions .header-icon,
  .header--home .header-actions .header-icon {
    display: none !important;
  }

  .header--public .header-actions .header-avatar,
  .header--public .header-actions .header-login-btn,
  .header--home .header-actions .header-avatar,
  .header--home .header-actions .header-login-btn {
    display: flex !important;
    margin-left: 0;
  }

  .header--public .header-login-btn,
  .header--home .header-login-btn {
    padding: 8px 12px;
    font-size: 0.78rem;
    min-height: 38px;
  }

  .header--public .header-avatar,
  .header--home .header-avatar {
    width: 38px;
    height: 38px;
  }

  .header--public .header-search-row,
  .header--home .header-search-row,
  .header--public .search-wrap,
  .header--home .search-wrap {
    width: 100%;
    max-width: none;
    flex: none;
  }
}

@media (min-width: 769px) {
  .header--public,
  .header--home {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
  }
  .header--public:not(.view-header) .header-top-row,
  .header--home .header-top-row {
    display: contents;
  }
  .header--public .logo-area,
  .header--home .logo-area { order: 1; }
  .header--public .menu-trigger,
  .header--home .menu-trigger { order: 2; display: block !important; }
  .header-search-row { order: 3; flex: 1; min-width: 180px; max-width: 480px; }
  .header-top-row .header-actions { order: 4; display: flex !important; margin-left: 0; }
}
