/* ================================================================
   eldauto.ru — Стили шапки (ТОЛЬКО ПК, ≥769px)
   Версия: v=20 (Планшетная адаптация шапки 769px–1180px, свободный правый край)
   ----------------------------------------------------------------
   Что здесь:
     - .header-divider, .header-main-nav, .header-nav-link, .header-badge
     - .header-user-dropdown / -btn / -avatar / -name / -menu / -divider
     - @keyframes fadeIn (используется в .header-user-menu)
     - @media (max-width: 1024px) — скрытие divider/nav на планшетах
   Что НЕ здесь (сознательно):
     - Базовый header { display:flex; ... } — он в style.css
     - .logo, .nav-actions, .btn-add-listing, .theme-toggle*, .btn-login-desktop,
       .btn-region — остаются в style.css
     - Всё ≤768px — остаётся в mobile.css
     - Тёмная тема шапки — вынесена в dark-theme.css (Шаг 4)
   TODO (backlog):
     - Конфликт mobile.css + inline header{display:none} — решается на шаге «Мобилка»
   ================================================================ */

/* ---------- Разделитель и основная навигация ---------- */
.header-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 12px;
  flex-shrink: 0;
}

.header-main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 0 !important;
}

.header-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--primary);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  font-family: inherit;
}

.header-nav-link svg {
  width: 18px;
  height: 18px;
}

.header-nav-link:hover {
  background: var(--input-bg);
  color: var(--text);
}

.header-nav-link.active {
  color: var(--primary);
  background: rgba(15, 23, 42, 0.08);
  font-weight: 600;
}

/* ---------- Бейдж на иконке (сообщения) ---------- */
.header-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--card-bg);
}

/* ---------- Дропдаун пользователя ---------- */
.header-user-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

.header-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 8px 4px 4px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  text-decoration: none; /* важно: в add-listing.html кнопка — это <a> */
}

.header-user-btn:hover {
  background: var(--input-bg);
  border-color: var(--border);
}

.header-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  overflow: hidden;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.header-user-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  max-width: 100px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-user-btn svg {
  color: var(--text-muted);
  transition: transform 0.2s;
}

.header-user-dropdown.open .header-user-btn svg {
  transform: rotate(180deg);
}

/* ---------- Меню дропдауна ---------- */
.header-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  min-width: 220px;
  padding: 6px;
  display: none;
  flex-direction: column;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}


.header-user-dropdown.open .header-user-menu {
  display: flex;
}

.header-user-menu a,
.header-user-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.15s;
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.header-user-menu a svg,
.header-user-menu button svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: color 0.15s;
  flex-shrink: 0;
}

.header-user-menu a:hover,
.header-user-menu button:hover {
  background: var(--input-bg);
  color: var(--primary);
}

.header-user-menu a:hover svg,
.header-user-menu button:hover svg {
  color: var(--primary);
}

.header-user-menu button#logoutBtnHeader:hover {
  color: #ef4444 !important;
}

.header-user-menu button#logoutBtnHeader:hover svg {
  color: #ef4444 !important;
}

.header-user-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* ---------- Анимация ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Планшеты: скрываем divider и main-nav ----------
   ВАЖНО: это НЕ мобилка (≤768px), а именно 769–1024px.
   Мобильные правила остаются в mobile.css.
   TODO(backlog): конфликт с inline header{display:none} в mobile.css — на шаге «Мобилка».
--------------------------------------------------------------- */

/* ---------- Планшеты (769px – 1180px): компактная 1-строчная шапка ---------- */
@media (min-width: 769px) and (max-width: 1180px) {
  header {
    padding: 0.6rem 0.85rem;
    gap: 0.5rem;
  }

  header > div:last-child {
    gap: 8px !important;
    min-width: 0;
  }

  .header-divider {
    margin: 0 6px;
  }

  .header-main-nav {
    gap: 2px;
  }

  .header-nav-link {
    padding: 6px 8px;
    font-size: 0.85rem;
    gap: 5px;
    white-space: nowrap;
  }

  .header-nav-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
  }

  .header-user-name {
    max-width: 78px;
    font-size: 0.83rem;
  }

  header .btn-region {
    padding: 0 9px;
    min-height: 38px;
    font-size: 0.82rem;
    gap: 4px;
  }

  header .btn-region #regionLabel {
    max-width: 86px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  header .btn-add-listing {
    padding: 0.5rem 0.85rem;
    min-height: 38px;
    font-size: 0.84rem;
  }

  header .btn-login-desktop {
    padding: 0.5rem 0.8rem;
    min-height: 38px;
    height: 38px;
    font-size: 0.84rem;
  }

  header .header-cat-nav .cat-btn {
    padding: 7px 10px;
    font-size: 0.84rem;
    gap: 5px;
  }
}

/* ---------- iPad Pro / портретные и средние планшеты (769px – 1080px) ---------- */
@media (min-width: 769px) and (max-width: 1080px) {
  header {
    padding: 0.55rem 0.8rem;
    gap: 0.45rem;
  }

  header .logo {
    font-size: 1.38rem;
    gap: 5px !important;
  }

  header > div:last-child {
    gap: 7px !important;
  }

  .header-divider {
    display: none;
  }

  .header-nav-link {
    padding: 6px 7px;
    font-size: 0.83rem;
    gap: 3px;
  }

  .header-nav-link svg {
    display: none;
  }

  #headerMoreBtn svg {
    display: inline-block;
    width: 13px;
    height: 13px;
  }

  .header-badge {
    top: -2px;
    right: -2px;
  }

  .header-user-name {
    display: none;
  }

  .header-user-btn {
    padding: 3px;
    gap: 0;
  }

  header .btn-region {
    padding: 0 8px;
    min-height: 36px;
    font-size: 0.8rem;
  }

  header .btn-region #regionLabel {
    max-width: 76px;
  }

  header .btn-add-listing {
    padding: 0.45rem 0.78rem;
    min-height: 36px;
    font-size: 0.82rem;
  }

  header .btn-login-desktop {
    padding: 0.45rem 0.75rem;
    min-height: 36px;
    height: 36px;
    font-size: 0.82rem;
  }

  header .header-cat-nav .cat-btn {
    padding: 6px 8px;
    font-size: 0.82rem;
  }

  header .header-cat-nav .cat-btn svg {
    display: none;
  }
}

/* ---------- Узкие портретные планшеты (769px – 880px) ---------- */
@media (min-width: 769px) and (max-width: 880px) {
  header {
    padding: 0.5rem 0.65rem;
    gap: 0.35rem;
  }

  header .logo {
    font-size: 1.28rem;
  }

  header > div:last-child {
    gap: 5px !important;
  }

  .header-nav-link {
    padding: 5px 6px;
    font-size: 0.78rem;
  }

  header .btn-region {
    padding: 0 7px;
    font-size: 0.76rem;
  }

  header .btn-region .icon-pin {
    display: none;
  }

  header .btn-region #regionLabel {
    max-width: 66px;
  }

  header .btn-add-listing {
    padding: 0.42rem 0.65rem;
    font-size: 0.78rem;
  }

  header .btn-login-desktop {
    padding: 0.42rem 0.65rem;
    font-size: 0.78rem;
  }
}
