/* ============================================
   components/header.css
   Стили для шапки сайта и мега-меню каталога
   ============================================ */

/* ============================================
   1. Топ-бар (верхняя строка)
   ============================================ */
.top-bar {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  padding: 4px 0;
}

.top-bar__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 24px;
}

.top-bar__nav {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}

.top-bar__nav a {
  color: var(--text-secondary);
  font-weight: 450;
  padding: 4px 0;
  position: relative;
  transition: color var(--transition);
}

.top-bar__nav a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: width var(--transition);
}

.top-bar__nav a:hover {
  color: var(--primary);
}

.top-bar__nav a:hover::after {
  width: 100%;
}

.top-bar__actions {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.top-bar__actions a {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-weight: 450;
  padding: 4px 0;
  transition: color var(--transition);
}

.top-bar__actions a:hover {
  color: var(--primary);
}

.top-bar__actions svg {
  opacity: 0.6;
  transition: opacity var(--transition);
}

.top-bar__actions a:hover svg {
  opacity: 1;
}

.top-bar__login svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ============================================
   2. Sticky Header (основная шапка)
   ============================================ */
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid transparent;
  padding: 12px 0;
  transition: all var(--transition);
  will-change: transform;
}

.sticky-header.is-sticky {
  border-bottom-color: var(--border-color);
  box-shadow: var(--shadow-md);
  background: rgba(255, 255, 255, 0.98);
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}

/* Логотип */
.logo {
  flex-shrink: 0;
}

.logo a {
  display: block;
  line-height: 0;
}

.logo img {
  display: block;
  height: 48px;
  width: auto;
}

/* ============================================
   3. Кнопка "Каталог" и иконки
   ============================================ */
.catalog-wrapper {
  position: static;
}

.catalog-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 44px;
}

.catalog-btn:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

.catalog-btn:active {
  box-shadow: none;
}

.catalog-btn .catalog-text {
  display: inline;
}

/* Анимация иконок внутри кнопки */
.catalog-btn .icon-menu,
.catalog-btn .icon-close {
  display: block;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}

.catalog-btn .icon-close {
  display: none;
}

.catalog-btn.active .icon-menu {
  display: none;
}

.catalog-btn.active .icon-close {
  display: block;
  animation: iconBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.catalog-btn:not(.active) .icon-menu {
  animation: menuBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes iconBounce {
  0% { transform: rotate(-180deg) scale(0.2); opacity: 0; }
  50% { transform: rotate(15deg) scale(1.2); opacity: 1; }
  70% { transform: rotate(-5deg) scale(0.95); }
  100% { transform: rotate(0deg) scale(1); }
}

@keyframes menuBounce {
  0% { transform: rotate(90deg) scale(0.2); opacity: 0; }
  50% { transform: rotate(-10deg) scale(1.2); opacity: 1; }
  70% { transform: rotate(5deg) scale(0.95); }
  100% { transform: rotate(0deg) scale(1); }
}

/* Иконки действий (избранное, корзина) */
.header-icons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: all var(--transition);
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--primary-bg);
  color: var(--primary);
  transform: translateY(-2px);
}

.icon-btn .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--primary);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-white);
}

/* ============================================
   4. Мега-меню каталога (Dropdown)
   ============================================ */
.catalog-dropdown {
  display: none;
  position: fixed;
  top: 100%;
  left: 0;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.catalog-dropdown.open {
  display: block;
}

.catalog-dropdown__inner {
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 600px);
  height: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
}

/* Две колонки каталога */
.catalog-columns {
  display: flex;
  flex: 1;
  min-height: 0; /* Критически важно для скролла внутри flex */
  overflow: hidden;
}

/* Общие стили скроллбаров для колонок */
.catalog-categories-wrapper,
.catalog-subcategories-wrapper,
.catalog-dropdown {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.catalog-categories-wrapper::-webkit-scrollbar,
.catalog-subcategories-wrapper::-webkit-scrollbar,
.catalog-dropdown::-webkit-scrollbar {
  width: 4px;
}

.catalog-categories-wrapper::-webkit-scrollbar-track,
.catalog-subcategories-wrapper::-webkit-scrollbar-track,
.catalog-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.catalog-categories-wrapper::-webkit-scrollbar-thumb,
.catalog-subcategories-wrapper::-webkit-scrollbar-thumb,
.catalog-dropdown::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.catalog-categories-wrapper::-webkit-scrollbar-thumb:hover,
.catalog-subcategories-wrapper::-webkit-scrollbar-thumb:hover,
.catalog-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Левая колонка: Категории */
.catalog-categories-wrapper {
  flex: 0 0 380px;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--border-color);
  padding: 8px 0;
}

.catalog-categories {
  padding: 0 8px 0 20px;
}

.catalog-category {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 0 4px;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent; /* Предотвращает сдвиг при active */
  padding-left: 11px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 450;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: all var(--transition);
  cursor: pointer;
}

.catalog-category:hover,
.catalog-category.active {
  background: var(--primary-bg);
  color: var(--primary);
}

.catalog-category.active {
  font-weight: 600;
}

.category-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: color var(--transition);
}

.category-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.catalog-category:hover .category-icon,
.catalog-category.active .category-icon {
  color: var(--primary);
}

.catalog-category .category-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalog-category .category-arrow {
  color: var(--text-muted);
  font-size: 1.2rem;
  transition: transform var(--transition);
}

.catalog-category:hover .category-arrow {
  transform: translateX(4px);
  color: var(--primary);
}

/* Правая колонка: Подкатегории */
.catalog-subcategories-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 24px;
}

.catalog-subcategories {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.subcategory-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px; /* 8px между строками, 24px между колонками */
}

.subcategory-group {
  display: none;
  height: 0;
  overflow: hidden;
  opacity: 0;
  margin-bottom: 28px;
  transition: opacity 0.2s ease;
}

.subcategory-group.active {
  display: block;
  height: auto;
  overflow: visible;
  opacity: 1;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.subcategory-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 8px 0;
  padding: 0 4px;
}

.subcategory-group a {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all var(--transition);
  cursor: pointer;
}

.subcategory-group a:hover {
  background: var(--primary-bg);
  color: var(--primary);
  padding-left: 14px;
}

/* Кнопка "Назад" (для мобильных) */
.catalog-back {
  display: none;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-white);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.3s ease;
}

.catalog-back.is-scrolled {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.catalog-dropdown.drilled .catalog-back {
  display: flex;
}

.catalog-back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 8px 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  transition: color var(--transition);
}

.catalog-back-btn:hover {
  color: var(--primary-dark);
}

.catalog-back-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

/* ============================================
   5. Адаптивность (Media Queries)
   ============================================ */

@media (max-width: 992px) {
  .top-bar__nav { gap: 20px; }
  .top-bar__actions { gap: 18px; }
  .catalog-categories-wrapper { flex: 0 0 300px; }
}

@media (max-width: 768px) {
  /* Топ-бар мобильный */
  .top-bar { padding: 8px 0; font-size: 0.7rem; }
  .top-bar__inner { flex-direction: column; gap: 4px; }
  .top-bar__nav, .top-bar__actions { justify-content: center; gap: 16px; }

  /* Шапка мобильная */
  .logo img { height: 32px; }
  .header-main { min-height: 44px; gap: 8px; }
  
  .icon-btn { width: 34px; height: 34px; }
  .icon-btn svg { width: 18px; height: 18px; }

  .catalog-btn { padding: 8px 12px; min-height: 36px; gap: 0; }
  .catalog-btn .catalog-text { display: none; }
  .catalog-btn svg { width: 18px; height: 18px; }

  /* Мега-меню мобильное */
  .catalog-dropdown {
    position: fixed;
    top: 56px; /* Подстроить под высоту sticky-header */
    left: 0;
    right: 0;
    width: 100%;
    margin-left: 0;
    border-radius: 0;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
  }
  
  .catalog-dropdown__inner {
    max-height: none;
    height: auto;
  }

  .catalog-columns {
    flex-direction: column;
    overflow: visible;
  }

  .catalog-categories-wrapper,
  .catalog-subcategories-wrapper {
    flex: none;
    width: 100%;
    overflow-y: visible;
    max-height: none;
    border-right: none;
  }

  .catalog-categories { padding: 4px 0; }
  
  .catalog-category {
    padding: 14px 16px;
    font-size: 0.95rem;
    border-radius: 0;
    border-bottom: 1px solid var(--border-color);
    border-left: none;
    padding-left: 16px;
  }

  .catalog-dropdown.drilled .catalog-categories-wrapper { display: none; }
  .catalog-dropdown.drilled .catalog-subcategories-wrapper { display: block; padding: 0 16px 16px; }

  .subcategory-group { display: block !important; }
  .subcategory-title {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin: 16px 0 8px 0;
  }
  .subcategory-group a { padding: 10px 14px; font-size: 0.9rem; }
  .subcategory-group a:active { background: var(--primary-bg); color: var(--primary); }
}

@media (max-width: 480px) {
  .top-bar { font-size: 0.65rem; padding: 6px 0; }
  .top-bar__nav, .top-bar__actions { gap: 12px; }
  .top-bar__actions a span { display: none; }
  
  .logo img { height: 26px; }
  
  .icon-btn { width: 30px; height: 30px; }
  .icon-btn svg { width: 16px; height: 16px; }
  .icon-btn .badge { min-width: 16px; height: 16px; font-size: 0.5rem; }

  .header-main { min-height: 36px; gap: 6px; }
  .catalog-btn { padding: 6px 10px; min-height: 32px; }
  .catalog-btn svg { width: 16px; height: 16px; }

  .catalog-category { padding: 12px 16px; font-size: 0.9rem; }
  .catalog-dropdown { top: 48px; max-height: calc(100vh - 48px); }
  .subcategory-group a { padding: 8px 12px; font-size: 0.85rem; }
}

@media (max-width: 400px) {
  .logo { display: none; }
}





/* ============================================
   БЛОКИРОВКА DROPDOWN ПРИ ПУСТОЙ КОРЗИНЕ
   ============================================ */

/* 1. Скрываем бейдж, если он пуст или не активен */
.badge#cart-count:empty,
.badge#cart-count:not(.active) {
    display: none !important;
}

/* 2. ПОЛНЫЙ ЗАПРЕТ на показ dropdown, если корзина пустая */
.header-cart-wrapper.is-empty .cart-dropdown {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateY(-8px) !important;
}

/* 3. Меняем курсор, чтобы было понятно, что наводить не на что */
.header-cart-wrapper.is-empty .icon-btn {
    cursor: default;
}


/* ============================================
   Бейдж корзины (скрытие при пустой корзине)
   ============================================ */

/* Бейдж скрыт по умолчанию */
.badge#cart-count {
    display: none;
}

/* Показываем только когда есть класс .active */
.badge#cart-count.active {
    display: inline-block !important;
}

/* Дополнительная страховка: скрыть, если текст пустой или "0" */
.badge#cart-count:empty {
    display: none !important;
}


/* ============================================
   Dropdown корзины в шапке
   ============================================ */

/* Обертка для позиционирования dropdown */
.header-cart-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Невидимый мостик, чтобы dropdown не закрывался при движении мыши */
.cart-dropdown::before {
    content: '';
    position: absolute;
    top: -12px; /* Высота отступа между иконкой и dropdown */
    left: 0;
    right: 0;
    height: 12px;
    background: transparent;
}

/* Стили для новой кнопки очистки */
.cart-dropdown__clear {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    background: transparent;
    border: none;
    border-top: 1px solid var(--border-color, #e2e8f0);
    color: #94a3b8; /* Нейтральный серый */
    font-size: 13px;
    font-weight: 500;
    padding: 12px 0;
    margin-top: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cart-dropdown__clear svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.cart-dropdown__clear:hover {
    color: #ef4444; /* Красный при наведении */
    background: transparent; /* Убираем фон, чтобы не было "кнопки" */
}

.cart-dropdown__clear:hover svg {
    transform: scale(1.1);
}


/* Состояние загрузки в dropdown */
.cart-dropdown__loading {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted, #64748b);
    font-size: 14px;
}

/* Dropdown (скрыт по умолчанию) */
.cart-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 360px;
    background: #fff;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    z-index: 1000;
    overflow: hidden;
    pointer-events: none; /* Чтобы не перехватывал клики, когда скрыт */
}

/* Показ dropdown при hover на всю обертку */
.header-cart-wrapper:hover .cart-dropdown,
.cart-dropdown.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Заголовок dropdown */
.cart-dropdown__header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-dropdown__header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
}

.cart-dropdown__count {
    font-size: 13px;
    color: var(--text-muted, #64748b);
}

/* Тело dropdown (список товаров) */
.cart-dropdown__body {
    flex: 1;
    overflow-y: auto;
    max-height: 360px;
    padding: 8px 0;
}

/* Пустое состояние */
.cart-dropdown__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted, #64748b);
}

.cart-dropdown__empty svg {
    margin-bottom: 12px;
    opacity: 0.3;
}

.cart-dropdown__empty p {
    margin: 0;
    font-size: 14px;
}

/* Элемент товара в dropdown */
.cart-dropdown__item {
    display: flex;
    gap: 12px;
    padding: 12px 20px;
    transition: background-color 0.15s ease;
}

.cart-dropdown__item:hover {
    background-color: var(--bg-light, #f8fafc);
}

.cart-dropdown__item-image {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--bg-light, #f8fafc);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-dropdown__item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cart-dropdown__item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cart-dropdown__item-name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-primary, #0f172a);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2; 
    overflow: hidden;
    text-decoration: none;
}

.cart-dropdown__item-name:hover {
    color: var(--primary, #3b82f6);
}

.cart-dropdown__item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted, #64748b);
}

.cart-dropdown__item-qty {
    background: var(--bg-light, #f8fafc);
    padding: 2px 8px;
    border-radius: 4px;
}

.cart-dropdown__item-price {
    font-weight: 600;
    color: var(--text-primary, #0f172a);
}

.cart-dropdown__item-remove {
    background: none;
    border: none;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 4px;
}

.cart-dropdown__item-remove:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* Футер dropdown с итогом */
.cart-dropdown__footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-light, #f8fafc);
}

.cart-dropdown__total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-secondary, #475569);
}

.cart-dropdown__total strong {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary, #0f172a);
}

.cart-dropdown__checkout {
    display: block;
    width: 100%;
    text-align: center;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
}

/* Скрываем футер, если корзина пуста */
.cart-dropdown.is-empty .cart-dropdown__footer {
    display: none !important;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .cart-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }
    
    .header-cart-wrapper:hover .cart-dropdown,
    .cart-dropdown.is-open {
        transform: translateY(0);
    }

    .subcategory-links {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    
    .subcategory-links a {
        font-size: 0.9rem;
        padding: 8px 0;
    }    

  /* 2. ПОЛНЫЙ ЗАПРЕТ на показ dropdown корзины */
  .header-cart-wrapper .cart-dropdown {
      display: none !important;
      opacity: 0 !important;
      visibility: hidden !important;
      pointer-events: none !important;
      transform: translateY(-8px) !important;
  }    
}







/* ============================================
   6. Город пользователя (top-bar)
   ============================================ */

/* Кнопка города — визуально как телефон/вход в top-bar */
.top-bar__city {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-weight: 450;
  font-size: inherit;
  line-height: inherit;
  cursor: pointer;
  transition: color var(--transition);
}

.top-bar__city:hover {
  color: var(--primary);
}

.top-bar__city:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 2px;
}

.top-bar__city svg {
  opacity: 0.6;
  transition: opacity var(--transition);
  flex-shrink: 0;
}

.top-bar__city:hover svg {
  opacity: 1;
}

/* Название города — без подчёркивания, как у телефона */
.top-bar__city-name {
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Пустой город — приглушённый, как плейсхолдер */
.top-bar__city.is-empty .top-bar__city-name {
  color: var(--text-muted, #94a3b8);
}   
   
/* ============================================
   8. Адаптивность города
   ============================================ */

@media (max-width: 992px) {
  .top-bar__city-name {
    max-width: 120px;
  }
}

@media (max-width: 768px) {
  /* На мобильных город — в sticky-header, в top-bar скрыт */
  .top-bar__city {
    display: none;
  }

  /* Кнопка города в шапке — в стиле соседних иконок */
  .header-city {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
    margin: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 450;
    cursor: pointer;
    transition: color var(--transition);
    flex-shrink: 0;
    max-width: 140px;
  }

  .header-city:hover {
    color: var(--primary);
  }

  .header-city svg {
    opacity: 0.6;
    transition: opacity var(--transition);
    flex-shrink: 0;
  }

  .header-city:hover svg {
    opacity: 1;
  }

  .header-city span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-city.is-empty span {
    color: var(--text-muted, #94a3b8);
  }
}

@media (max-width: 480px) {
  .header-city {
    font-size: 0.7rem;
    max-width: 110px;
  }

  .header-city svg {
    width: 12px;
    height: 12px;
  }
}

@media (max-width: 400px) {
  .header-city span {
    display: none;
  }
  .header-city {
    padding: 6px;
    max-width: none;
  }
}



/* ============================================
   9. Модалка выбора города
   ============================================ */

.city-modal[hidden] {
  display: none;
}

.city-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.city-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: cityFadeIn 0.2s ease;
}

.city-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--bg-white, #fff);
  border-radius: var(--radius-md, 12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: citySlideUp 0.25s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes cityFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes citySlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Заголовок */
.city-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.city-modal__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary, #0f172a);
}

.city-modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--text-secondary, #475569);
  cursor: pointer;
  transition: all var(--transition);
}

.city-modal__close:hover {
  background: var(--primary-bg, rgba(38, 69, 147, 0.06));
  color: var(--primary);
}

/* Поиск */
.city-modal__search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 20px 8px;
  padding: 10px 14px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-light, #f8fafc);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.city-modal__search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg, rgba(38, 69, 147, 0.12));
}

.city-modal__search svg {
  color: var(--text-muted, #94a3b8);
  flex-shrink: 0;
}

.city-modal__search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text-primary, #0f172a);
}

.city-modal__search-input::placeholder {
  color: var(--text-muted, #94a3b8);
}

/* Тело со списком */
.city-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.city-modal__body::-webkit-scrollbar { width: 6px; }
.city-modal__body::-webkit-scrollbar-thumb {
  background: var(--border-color, #e2e8f0);
  border-radius: 3px;
}

.city-modal__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Пункт города */
.city-modal__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm, 8px);
  color: var(--text-primary, #0f172a);
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition);
}

.city-modal__item:hover {
  background: var(--primary-bg, rgba(38, 69, 147, 0.06));
  color: var(--primary);
}

.city-modal__item.is-selected {
  background: var(--primary-bg, rgba(38, 69, 147, 0.1));
  color: var(--primary);
  font-weight: 600;  
}

.city-modal__item.is-selected::after {
  content: '✓';
  font-size: 0.95rem;
  color: var(--primary);
  flex-shrink: 0;
}

/* Активный (навигация стрелками клавиатуры) */
.city-modal__item.is-active:not(.is-selected) {
  background: var(--primary-bg, rgba(38, 69, 147, 0.12));
  outline: 2px solid var(--primary, #264593);
  outline-offset: -2px;
}

/* Выбранный + активный — чуть темнее, чтобы отличать */
.city-modal__item.is-selected.is-active {
  background: var(--primary-dark, #1d3575);
  color: #fff;
}

.city-modal__item.is-selected.is-active::after {
  color: #fff;
}


/* Пусто */
.city-modal__empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted, #94a3b8);
  font-size: 0.9rem;
}

/* Футер */
.city-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-light, #f8fafc);
}

.city-modal__btn {
  min-height: 40px;
  padding: 8px 18px;
  border-radius: var(--radius-sm, 8px);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.city-modal__btn--ghost {
  background: transparent;
  color: var(--text-secondary, #475569);
  border-color: var(--border-color, #e2e8f0);
}

.city-modal__btn--ghost:hover {
  background: var(--bg-white, #fff);
  color: var(--text-primary, #0f172a);
}

.city-modal__btn--primary {
  background: var(--primary, #264593);
  color: #fff;
}

.city-modal__btn--primary:hover:not(:disabled) {
  background: var(--primary-dark, #1d3575);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12));
}

.city-modal__btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Мобильные */
@media (max-width: 768px) {
  .city-modal {
    align-items: flex-end;
    padding: 0;
  }

  .city-modal__dialog {
    max-width: none;
    max-height: 90vh;
    border-radius: var(--radius-md, 12px) var(--radius-md, 12px) 0 0;
    animation: citySlideBottom 0.25s cubic-bezier(0.34, 1.2, 0.64, 1);
  }

  @keyframes citySlideBottom {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
}