:root {
    --xtorg-dark-purple: #20043b;
    --xtorg-light-purple: #51168c;
    /* ИСПРАВЛЕНО: Новый оттенок розового для идеального контраста 4.5+:1 с белым текстом */
    --xtorg-neon-pink: #cd0b64;
    --bg-main: #f2f4f7;
    --card-bg: #ffffff;
    --text-primary: #002f34;
    --text-secondary: #406367;
    --border-color: #d8e2e3;
    --transition-fast: 0.2s ease-in-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 1250px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Шапка сайта */
.header {
    background-color: var(--xtorg-dark-purple);
    color: #fff;
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(32, 4, 59, 0.15);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo {
    font-size: 32px;
    font-weight: 900;
    cursor: pointer;
    letter-spacing: -1.5px;
    color: #fff;
    user-select: none;
    text-decoration: none;
    transition: var(--transition-fast);
}

.logo:hover {
    opacity: 0.9;
}

.lang-switcher {
    display: flex;
    gap: 6px;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    font-size: 11px;
    transition: var(--transition-fast);
}

.lang-btn.active,
.lang-btn:hover {
    background: var(--xtorg-neon-pink);
    border-color: var(--xtorg-neon-pink);
    color: #ffffff;
}

/* Стили для кнопки поиска */
.search-bar button {
    background-color: var(--xtorg-neon-pink);
    color: #ffffff;
    border: none;
    transition: var(--transition-fast);
}

.search-bar button:hover {
    background-color: #b50456;
}

/* ПОЛНОСТЬЮ ПЕРЕРАБОТАННЫЙ БЛОК ПРОФИЛЯ И ВЫПАДАЮЩЕГО МЕНЮ */
.profile-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.btn-profile {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
}

.btn-profile:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Новая контрастная темная плашка выпадающего меню */
/* Новая контрастная темная плашка выпадающего меню */
.profile-dropdown-menu {
    display: none;
    flex-direction: column;
    /* 👈 ДОБАВЛЕНО СЮДА: теперь контейнер ВСЕГДА будет вертикальным */
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background-color: var(--xtorg-dark-purple);
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    border-radius: 10px;
    padding: 6px 0;
    z-index: 9999;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Показываем меню и при .show, и при ховере */
.profile-dropdown-menu.show,
.profile-dropdown-wrapper:hover .profile-dropdown-menu {
    display: flex;
}

/* Элементы списка меню */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #bdaecf;
    text-decoration: none;
    background: none;
    border: none;
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    text-align: left;
    white-space: nowrap;
    /* 👈 РЕКОМЕНДУЕТСЯ: чтобы текст пункта меню не переносился на новую строку, если он длинный */
    transition: background-color 0.15s ease, color 0.15s ease;
}

.dropdown-item svg {
    stroke: #bdaecf;
    transition: stroke 0.15s ease;
    flex-shrink: 0;
    /* 👈 чтобы иконка не сжималась при длинном тексте */
}

/* Эффект наведения на пункт меню */
.dropdown-item:hover {
    background-color: var(--xtorg-light-purple);
    color: #ffffff;
}

.dropdown-item:hover svg {
    stroke: #ffffff;
}

/* Подсветка активного состояния "Обрані" */
.dropdown-item.btn-favorites.active {
    color: #ffffff;
    background-color: var(--xtorg-neon-pink);
}

.dropdown-item.btn-favorites.active svg {
    stroke: #ffffff;
    fill: #ffffff;
}

/* Фиксация иконки и круглого счетчика */
.fav-icon-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
}

.fav-icon-wrapper .counter {
    position: absolute;
    top: -5px;
    right: -6px;
    background-color: var(--xtorg-neon-pink);
    color: #ffffff;
    font-size: 10px;
    font-weight: bold;
    min-width: 15px;
    height: 15px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1;
    border: 1px solid var(--xtorg-dark-purple);
    /* Отделяем счетчик от плашки */
}

/* Если пункт меню с избранным активен, делаем счетчик белым с розовым текстом */
.dropdown-item.btn-favorites.active .counter {
    background-color: #ffffff;
    color: var(--xtorg-neon-pink);
    border-color: var(--xtorg-neon-pink);
}

/* Принудительно выравниваем кнопку "Обрані" в строку внутри выпадающего меню */
.profile-dropdown-menu .dropdown-item.btn-favorites {
    flex-direction: row !important;
    justify-content: flex-start !important;
    align-items: center !important;
    text-align: left !important;
}

/* Невидимый мостик, чтобы курсор не терял ховер при переходе на меню */
.profile-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -10px;
    /* Перекрывает 8px зазора + дает запас */
    left: 0;
    right: 0;
    height: 10px;
}

/* Подвал сайта */
.site-footer {
    background-color: var(--xtorg-dark-purple);
    color: #fff;
    padding: 25px 0;
    margin-top: auto;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.site-footer .footer-logo {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.site-footer .footer-copy {
    color: #bdaecf;
    font-size: 13px;
}

.btn-create-ad {
    background: var(--xtorg-light-purple);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 11px 24px;
    border-radius: 30px;
    font-weight: 700;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition-fast);
}

.btn-create-ad:hover {
    background: var(--xtorg-neon-pink, #cd0b64);
    box-shadow: 0 4px 12px rgba(205, 11, 100, 0.3);
}

.search-bar {
    flex-grow: 1;
    max-width: 550px;
    display: flex;
    background: #fff;
    border-radius: 30px;
    padding: 3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.search-bar input {
    width: 100%;
    border: none;
    padding: 10px 20px;
    outline: none;
    font-size: 15px;
    color: var(--text-primary);
    background: transparent;
}

.search-bar button {
    /* ИСПРАВЛЕНО: используем контрастный розовый */
    background: var(--xtorg-neon-pink, #cd0b64);
    color: #fff;
    border: none;
    padding: 0 24px;
    border-radius: 25px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-fast);
}

.search-bar button:hover {
    background: #b50456;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}

/* Адаптивная мобильная часть */
@media (max-width: 768px) {
    .header {
        padding: 10px 0;
    }

    .header-container {
        display: grid;
        grid-template-columns: auto 1fr;
        row-gap: 12px;
        column-gap: 10px;
        align-items: center;
    }

    .logo {
        font-size: 26px;
        grid-column: 1;
        grid-row: 1;
    }

    .lang-switcher {
        grid-column: 2;
        grid-row: 1;
        justify-content: flex-end;
        padding-right: 50px;
    }

    .header-actions {
        grid-column: 2;
        grid-row: 1;
        margin-left: auto;
        gap: 12px;
    }

    .btn-profile span[data-i18n="profileTitle"] {
        display: none;
    }

    .btn-profile {
        padding: 8px;
    }

    /* Адаптивное выпадающее меню на всю ширину экрана на мобилке */
    .profile-dropdown-menu {
        position: fixed;
        top: 56px;
        right: 20px;
        left: 20px;
        width: calc(100% - 40px);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    }

    .search-bar {
        grid-column: 1 / span 2;
        grid-row: 2;
        order: 3;
        max-width: 100%;
        width: 100%;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    }

    .search-bar input {
        padding: 8px 15px;
        font-size: 14px;
    }

    .search-bar button {
        padding: 0 16px;
    }

    .btn-create-ad {
        position: fixed;
        bottom: 24px;
        right: 24px;
        left: auto;
        transform: none;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 9999;
        background: var(--xtorg-neon-pink);
        box-shadow: 0 6px 20px rgba(205, 11, 100, 0.4);
        border: none;
        font-size: 0 !important;
        color: transparent !important;
        line-height: 0 !important;
        overflow: hidden;
        text-indent: -9999px;
    }

    .btn-create-ad::before {
        content: '+';
        font-size: 32px;
        font-weight: 300;
        color: #ffffff !important;
        display: block;
        text-indent: 0;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        line-height: 1;
    }

    .btn-create-ad:hover {
        background: #b50456;
        transform: scale(1.05);
        transition: var(--transition-fast);
    }

    .ads-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    .ad-info {
        padding: 10px;
    }

    .ad-price {
        font-size: 16px;
        margin-bottom: 4px;
    }

    .ad-title {
        font-size: 12px;
        height: 34px;
        margin-bottom: 8px;
    }

    .ad-location {
        font-size: 11px;
        margin-bottom: 10px;
    }

    .btn-action-view {
        padding: 8px;
        font-size: 12px;
    }

    .fav-badge {
        width: 30px;
        height: 30px;
        font-size: 14px;
        top: 8px;
        right: 8px;
    }
}