/**
 * Стили для селектора города в header
 */

/* Основной контейнер */
.td-city-selector-widget {
    position: relative;
    display: inline-block;
    z-index: 1000;
}

/* Текущий город (кнопка) */
.td-city-current {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
    user-select: none;
}

.td-city-current:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Иконка маркера */
.td-city-icon {
    flex-shrink: 0;
    color: #f7641a;
}

/* Информация о городе */
.td-city-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.td-city-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1;
}

.td-city-name {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    line-height: 1;
    white-space: nowrap;
}

/* Шеврон */
.td-city-chevron {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.7);
    transition: transform 0.3s ease;
}

.td-city-current.active .td-city-chevron {
    transform: rotate(180deg);
}

/* Выпадающее меню */
.td-city-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 280px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    animation: tdFadeInDown 0.3s ease;
}

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

/* Header дропдауна */
.td-city-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}

.td-city-dropdown-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.td-city-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #999;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.td-city-close:hover {
    color: #333;
}

.td-city-close svg {
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Список городов */
.td-city-list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
    max-height: 300px;
    overflow-y: auto;
}

.td-city-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    color: #333;
}

.td-city-item:hover {
    background: #f5f5f5;
}

.td-city-item.active {
    background: #fff5f0;
    color: #f7641a;
    font-weight: 600;
}

.td-city-item-name {
    font-size: 14px;
}

.td-city-item-check {
    color: #f7641a;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.td-city-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Адрес */
.td-city-address {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #eee;
    font-size: 13px;
    color: #666;
}

.td-city-address svg {
    flex-shrink: 0;
    color: #999;
}

/* Мобильная версия */
@media (max-width: 768px) {
    .td-city-dropdown {
        position: fixed;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 400px;
    }

    .td-city-current {
        padding: 4px 8px;
    }

    .td-city-label {
        display: none;
    }

    .td-city-info {
        align-items: center;
    }

    .td-city-name {
        font-size: 13px;
    }
}

/* Для темного header */
.whb-color-dark .td-city-current {
    color: #333;
}

.whb-color-dark .td-city-label {
    color: rgba(0, 0, 0, 0.6);
}

.whb-color-dark .td-city-name {
    color: #333;
}

.whb-color-dark .td-city-chevron {
    color: rgba(0, 0, 0, 0.6);
}

.whb-color-dark .td-city-current:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Стики header */
.wd-sticky-enabled .td-city-selector-widget {
    font-size: 13px;
}

.wd-sticky-enabled .td-city-name {
    font-size: 13px;
}

/* Анимация появления */
.td-city-dropdown.show {
    display: block !important;
}

/* Overlay для мобильных */
.td-city-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    animation: tdFadeIn 0.3s ease;
}

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

.td-city-overlay.show {
    display: block;
}

/* Скроллбар для списка городов */
.td-city-list::-webkit-scrollbar {
    width: 6px;
}

.td-city-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.td-city-list::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.td-city-list::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* Loading состояние */
.td-city-item.loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #f7641a;
    border-radius: 50%;
    animation: tdSpin 0.8s linear infinite;
    margin-left: 10px;
}

@keyframes tdSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Интеграция с Woodmart header */
.whb-header .td-city-selector-widget {
    margin-right: 15px;
}

.whb-top-bar .td-city-selector-widget {
    margin: 0;
}

/* Для использования в топ-баре */
.whb-top-bar .td-city-current {
    padding: 0;
    background: none !important;
}

.whb-top-bar .td-city-icon {
    width: 14px;
    height: 14px;
}

.whb-top-bar .td-city-info {
    gap: 4px;
}

.whb-top-bar .td-city-label {
    font-size: 10px;
}

.whb-top-bar .td-city-name {
    font-size: 12px;
}

/* Адаптация под светлый header */
.whb-header:not(.whb-color-dark) .td-city-current {
    color: #fff;
}

/* Для RTL */
.rtl .td-city-dropdown {
    left: auto;
    right: 0;
}

.rtl .td-city-icon {
    margin-left: 8px;
    margin-right: 0;
}

/* Accessibility */
.td-city-current:focus {
    outline: 2px solid #f7641a;
    outline-offset: 2px;
}

.td-city-item:focus {
    outline: 2px solid #f7641a;
    outline-offset: -2px;
}

/* Предотвращение скролла body при открытом dropdown на мобильных */
body.td-city-dropdown-open {
    overflow: hidden;
}

@media (min-width: 769px) {
    body.td-city-dropdown-open {
        overflow: visible;
    }
}
