/* =========================
   ШАПКА (компактная, одна строка)
========================= */
.site-header {
    background: var(--panel);
    position: sticky;
    top: 0;
    z-index: 1000;
    margin-bottom: 24px;
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 64px;
    padding: 9px 0;
}

/* ЛОГО */
.logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.logo-img {
    width: 132px;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

/* КНОПКА КАТАЛОГА (выпадающий список категорий на <details>) */
.catalog-picker {
    flex: 0 0 auto;
    position: relative;
}

.catalog-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 46px;
    padding: 0 16px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    list-style: none;
    user-select: none;
    transition: background 0.2s ease;
}

/* Убираем стандартный маркер <summary> */
.catalog-btn::-webkit-details-marker {
    display: none;
}

.catalog-btn:hover,
.catalog-picker[open] .catalog-btn {
    background: var(--accent-hover);
}

.catalog-dots {
    display: grid;
    grid-template-columns: repeat(3, 4px);
    gap: 3px;
    flex: 0 0 auto;
}

.catalog-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #ffffff;
    display: block;
}

.catalog-caret {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    transition: transform 0.2s ease;
}

.catalog-picker[open] .catalog-caret {
    transform: rotate(180deg);
}

.catalog-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    width: 300px;
    padding: 8px;
    background: var(--card);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    /* overflow: visible — чтобы каскадные подменю могли выходить за пределы */
}

.catalog-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.catalog-menu-item:hover,
.catalog-menu-item:focus-visible {
    background: var(--accent);
    color: #ffffff;
    outline: none;
}

.catalog-menu-item.is-active {
    color: var(--accent);
}

.catalog-menu-item.is-active:hover,
.catalog-menu-item.is-active:focus-visible {
    color: #ffffff;
}

/* «Весь каталог» — первым пунктом, с разделителем снизу */
.catalog-menu-all {
    font-weight: 700;
    margin-bottom: 4px;
    padding-bottom: 11px;
    border-bottom: 1px solid rgba(24, 193, 210, 0.18);
    border-radius: 10px 10px 0 0;
}

.catalog-menu-emoji {
    font-size: 17px;
    line-height: 1;
    flex: 0 0 auto;
}

/* --- Каскадное меню: категория → подкатегория → подподкатегория --- */
.catalog-node {
    position: relative;
}

/* Строка категории внутри узла должна занимать всю ширину */
.catalog-node > .catalog-menu-item {
    width: 100%;
}

/* Стрелка «есть вложенные» (›) — прижата вправо */
.catalog-arrow {
    margin-left: auto;
    padding-left: 10px;
    color: var(--muted);
    font-weight: 700;
    line-height: 1;
    flex: 0 0 auto;
}

.catalog-menu-item:hover .catalog-arrow,
.catalog-subitem:hover .catalog-arrow,
.catalog-node:hover > .catalog-menu-item .catalog-arrow,
.catalog-node:hover > .catalog-subitem .catalog-arrow {
    color: inherit;
}

/* Выпадающая панель следующего уровня (одна и та же для 2-го и 3-го) */
.catalog-flyout {
    position: absolute;
    top: -8px;
    left: 100%;
    z-index: 1200;
    display: none;
    flex-direction: column;
    width: 264px;
    padding: 8px;
    background: var(--card);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

/* Показываем панель при наведении/фокусе на её узел */
.catalog-node:hover > .catalog-flyout,
.catalog-node:focus-within > .catalog-flyout {
    display: flex;
}

/* Если места справа не хватает — открываем влево (класс ставит JS) */
.catalog-node.flip-left > .catalog-flyout {
    left: auto;
    right: 100%;
}

/* Пункт подкатегории / подподкатегории */
.catalog-subitem {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 9px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.catalog-subitem:hover,
.catalog-subitem:focus-visible {
    background: var(--accent);
    color: #ffffff;
    outline: none;
}

/* ПОИСК */
.search-box {
    flex: 1 1 280px;
    min-width: 0;
    display: flex;
    align-items: center;
    height: 46px;
    background: var(--input);
    border: 2px solid var(--accent);
    border-radius: 12px;
    overflow: hidden;
}

.search-icon {
    flex: 0 0 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-icon-img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    display: none;
}

body.theme-dark .search-dark {
    display: block;
}

body.theme-light .search-light {
    display: block;
}

.search-box input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 15px;
    padding: 0 12px 0 2px;
}

.search-box input::placeholder {
    color: #7c8b93;
}

.search-btn {
    flex: 0 0 auto;
    height: 100%;
    padding: 0 22px;
    border: none;
    background: var(--accent);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease;
}

.search-btn:hover {
    background: var(--accent-hover);
}

/* КНОПКА ПУБЛИКАЦИИ */
.publish-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    padding: 0 18px;
    border-radius: 12px;
    border: 2px solid var(--accent);
    background: var(--accent);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
    transition: 0.2s ease;
}

.publish-btn:hover {
    background: var(--panel);
    color: var(--accent);
}

.publish-btn-plus {
    font-size: 20px;
    line-height: 1;
}

/* ВКЛАДКИ (Мои объявления / Новости) */
.header-tabs {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 18px;
}

/* ДЕЙСТВИЯ СПРАВА */
.header-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

/* КНОПКА ВЫБОРА ГОРОДА (выпадающий список на <details>) */
.city-picker {
    flex: 0 0 auto;
    position: relative;
}

/* Кнопка-«ручка» дропдауна (это <summary>) — убираем стандартный маркер */
.city-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    background: transparent;
    border: none;
    color: var(--text);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.city-link::-webkit-details-marker {
    display: none;
}

.city-link:hover {
    color: var(--accent);
}

.city-pin {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
    color: var(--accent);
}

.city-caret {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    transition: transform 0.2s ease;
}

.city-picker[open] .city-caret {
    transform: rotate(180deg);
}

.city-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    width: 260px;
    max-height: 64vh;
    padding: 8px;
    background: var(--card);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.city-search {
    flex: 0 0 auto;
    height: 38px;
    margin-bottom: 6px;
    padding: 0 12px;
    border: 1px solid var(--accent);
    border-radius: 10px;
    background: var(--input);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.city-search::placeholder {
    color: #7c8b93;
}

.city-results {
    min-height: 0;
    overflow-y: auto;
}

.city-empty {
    padding: 10px 12px;
    color: var(--muted);
    font-size: 14px;
}

.city-menu-item {
    display: block;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.city-menu-item:hover,
.city-menu-item:focus-visible {
    background: var(--accent);
    color: #ffffff;
    outline: none;
}

.city-menu-item.is-active {
    color: var(--accent);
}

.city-menu-item.is-active:hover,
.city-menu-item.is-active:focus-visible {
    color: #ffffff;
}

.header-link {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 15px;
    cursor: pointer;
    transition: color 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
}

.header-link:hover {
    color: var(--accent);
}

.login-link {
    font-weight: 700;
    color: var(--accent);
}

.logout-form {
    margin: 0;
    padding: 0;
    display: flex;
}

.logout-btn {
    padding: 0;
    font-family: inherit;
}

/* ИКОНКИ */
.icon-btn {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* МЕНЮ ПРОФИЛЯ: клик по иконке — в личный кабинет, наведение (десктоп) —
   быстрое меню. Чистый CSS: :hover + :focus-within для клавиатуры. */
.profile-menu {
    position: relative;
    flex: 0 0 auto;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 210px;
    padding: 8px;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid rgba(24, 193, 210, 0.18);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
    z-index: 60;
}

/* Невидимый «мостик» над меню — курсор не проваливается в зазор между
   иконкой и выпадающим списком, меню не закрывается на полпути. */
.profile-dropdown::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
}

.profile-menu:hover .profile-dropdown,
.profile-menu:focus-within .profile-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.profile-dropdown-item:hover {
    background: rgba(24, 193, 210, 0.12);
    color: var(--accent);
}

.profile-dropdown-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--accent);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
}

.profile-dropdown-sep {
    height: 1px;
    margin: 4px 6px;
    background: rgba(24, 193, 210, 0.18);
}

.profile-dropdown-logout {
    margin: 0;
}

.icon-img {
    width: 23px;
    height: 23px;
    object-fit: contain;
    display: none;
}

body.theme-dark .icon-dark {
    display: block;
}

body.theme-light .icon-light {
    display: block;
}

/* Смена темы. Иконка показывает, КУДА переключит клик: в тёмной теме — солнце
   (включить светлую), в светлой — луна; видимость на тех же классах body.theme-*,
   что и у .icon-dark/.icon-light. */
.theme-btn {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    color: var(--text);
}

.theme-btn:hover {
    color: var(--accent);
}

.theme-icon {
    width: 23px;
    height: 23px;
    display: none;
}

body.theme-dark .theme-icon-sun {
    display: block;
}

body.theme-light .theme-icon-moon {
    display: block;
}

/* Нижняя панель и выезжающее меню «Ещё» существуют только на телефонах —
   на десктопе/планшете скрыты, включаются в responsive.css (<=1023px). */
.drawer-backdrop,
.mobile-drawer,
.bottom-nav {
    display: none;
}


/* =========================
   Бейдж непрочитанных сообщений (иконка чата в шапке и пункт в мобильном меню)
========================= */
.unread-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: #e5484d;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--panel);
}

.drawer-unread {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #e5484d;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}
