/*
 * Каталог аптек (/{город}/apteka): короткий список + карта на высоту окна.
 * Всё привязано к .apteka-catalog, чтобы не задеть другие страницы,
 * где используются .section-list__* и .section-top__card*.
 * Подключается после styles.pure.css (см. resources/views/apteka/catalog.blade.php).
 */

/* ---------- Карточка ---------- */

.apteka-catalog .apt-card {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    min-height: 88px;
    margin-bottom: 8px;
    padding: 12px;
    cursor: pointer;
}

.apteka-catalog .apt-card.active {
    border-color: var(--purple-25);
    background: #F8F5FF;
}

/* Логотип 40px, номер (тот же, что на метке карты) — бейдж на его углу. */
.apteka-catalog .apt-card__logo {
    position: relative;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
}

.apteka-catalog .apt-card__logo-img {
    display: block;
    width: 40px;
    height: 40px;
    margin: 0;
    border-radius: 8px;
    background: #fff;
    object-fit: contain;
}

.apteka-catalog .apt-card__num {
    position: absolute;
    top: -6px;
    left: -6px;
    box-sizing: border-box;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    border: 2px solid #fff;
    border-radius: 10px;
    background: #3f8b8b;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
}

/* Обёртка адрес+часы+телефон: на десктопе не влияет на вёрстку (одна строка собирается на мобильном). */
.apteka-catalog .apt-card__info {
    display: contents;
}

.apteka-catalog .apt-card__body {
    flex: 1 1 auto;
    min-width: 0;
}

.apteka-catalog .apt-card__title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    margin-bottom: 2px;
}

.apteka-catalog .apt-card__name {
    display: block;
    flex: 0 1 auto;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.apteka-catalog .apt-card__rating {
    flex: 0 0 auto;
    color: var(--gray-60);
    font-size: 13px;
}

.apteka-catalog .apt-card__address,
.apteka-catalog .apt-card__meta {
    overflow: hidden;
    font-size: 13px;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.apteka-catalog .apt-card__address {
    color: var(--gray-60);
}

.apteka-catalog .apt-card__meta {
    margin-top: 2px;
    color: var(--gray-60);
}

.apteka-catalog .apt-card__sep {
    margin: 0 6px;
}

.apteka-catalog .apt-card__phone {
    color: var(--green-text);
}

/* Сердечко: маленькая иконка справа (в общих стилях оно absolute в левом нижнем углу). */
.apteka-catalog .apt-card .favorite,
.apteka-catalog .apt-card .favorite.active {
    position: static;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    background-position: center;
    background-size: contain;
}

/* ---------- Метки на карте ---------- */

.apt-pin {
    box-sizing: border-box;
    width: 28px;
    height: 28px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #3f8b8b;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
    color: #fff;
    font: 600 13px/24px Arial, sans-serif;
    text-align: center;
    transition: transform .15s ease, background-color .15s ease;
}

/* Аптеки не с текущей страницы списка: точка без номера. */
.apt-pin--dot {
    width: 12px;
    height: 12px;
    font-size: 0;
    line-height: 0;
}

.apt-pin.is-hover,
.apt-pin.is-active {
    background: #2d6a6a;
    transform: scale(1.3);
}

/* ---------- Список по области карты ---------- */

.apteka-catalog .apt-area-info {
    margin: 0 0 8px;
    color: var(--gray-60);
    font-size: 13px;
}

.apteka-catalog .apt-area-info:empty {
    display: none;
}

.apteka-catalog .apt-empty {
    padding: 24px 12px;
    color: var(--gray-60);
    font-size: 14px;
    text-align: center;
    list-style: none;
}

.apteka-catalog .apt-more {
    display: block;
    width: 100%;
    margin: 4px 0 16px;
    padding: 12px;
    border: 1px solid var(--purple-25);
    border-radius: 8px;
    background: #fff;
    color: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.apteka-catalog .apt-more:hover {
    background: #F8F5FF;
}

/* Список следует за картой, постраничная навигация не нужна (ссылки остаются в HTML для поисковиков). */
.apteka-catalog.is-area-list #Pager {
    display: none;
}

/* ---------- Список и пагинация ---------- */

.apteka-catalog .section-list__pagination {
    flex-wrap: wrap;
}

/* ---------- Десктоп: список 400px + карта на высоту окна ---------- */

@media (min-width: 992px) {
    .apteka-catalog .section-list__content {
        /* Общие стили на max-width:992px (включая сам 992) ставят column-reverse. */
        flex-direction: row;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 16px;
    }

    .apteka-catalog .section-list__content-left {
        flex: 0 0 400px;
        width: 400px;
        padding-right: 0;
    }

    .apteka-catalog .section-list__right {
        position: sticky;
        top: 16px;
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        height: calc(100vh - 32px);
    }

    .apteka-catalog .section-list__right .section-list__map {
        display: block;
        width: 100%;
        max-width: none;
        max-height: none;
        height: 100%;
        border-radius: 16px;
        overflow: hidden;
    }

    .apteka-catalog .apt-seg {
        display: none;
    }
}

/* ---------- Шапка каталога: счётчик над поиском ---------- */

.apteka-catalog .apt-head__count {
    margin: 0 0 8px;
}

/* ---------- Мобильный: список или карта, переключатель в шапке ---------- */

@media (max-width: 991px) {
    /* Поиск, затем строка «Найдено N» + переключатель «Список | Карта». */
    .apteka-catalog .apt-head {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "search search"
            "count  seg";
        align-items: center;
        row-gap: 10px;
        margin-bottom: 4px;
    }

    .apteka-catalog .apt-head__search {
        grid-area: search;
        min-width: 0;
    }

    .apteka-catalog .apt-head__search .section-list__input {
        margin-bottom: 0;
    }

    .apteka-catalog .apt-head__count {
        grid-area: count;
        margin: 0;
        font-size: 14px;
    }

    .apteka-catalog .apt-seg {
        grid-area: seg;
        display: inline-flex;
        padding: 3px;
        border-radius: 999px;
        background: #eef1f3;
    }

    .apteka-catalog .apt-seg__btn {
        min-height: 32px;
        padding: 0 16px;
        border: 0;
        border-radius: 999px;
        background: transparent;
        color: #1b1b1b;
        font-size: 14px;
        font-weight: 600;
        line-height: 1;
        cursor: pointer;
        transition: background-color .15s ease, color .15s ease;
    }

    .apteka-catalog .apt-seg__btn.active {
        background: #3f8b8b;
        color: #fff;
    }

    /* Теги — лентой вбок, без переноса строк. */
    .apteka-catalog .apteka-filters {
        flex-wrap: nowrap;
        gap: 8px;
        margin: 8px 0 12px;
        padding-bottom: 2px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .apteka-catalog .apteka-filters::-webkit-scrollbar {
        display: none;
    }

    .apteka-catalog .apteka-filter {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .apteka-catalog .section-list__content {
        display: block;
    }

    .apteka-catalog .section-list__content-left {
        width: 100%;
        padding: 0;
    }

    /* Список одной рамкой, аптеки разделены линиями. */
    .apteka-catalog #search_result {
        margin: 0 0 12px;
        padding: 0;
        overflow: hidden;
        border: 1px solid #e5e7eb;
        border-radius: 14px;
        background: #fff;
    }

    .apteka-catalog .apt-card {
        min-height: 0;
        margin: 0;
        padding: 10px 12px;
        border: 0;
        border-bottom: 1px solid #e5e7eb;
        border-radius: 0;
    }

    .apteka-catalog .apt-card:last-child {
        border-bottom: 0;
    }

    /* Адрес · часы · телефон одной строкой с многоточием. */
    .apteka-catalog .apt-card__info {
        display: block;
        overflow: hidden;
        color: var(--gray-60);
        font-size: 13px;
        line-height: 1.4;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .apteka-catalog .apt-card__info .apt-card__address,
    .apteka-catalog .apt-card__info .apt-card__meta {
        display: inline;
        overflow: visible;
        margin: 0;
    }

    .apteka-catalog .apt-card__info .apt-card__meta::before {
        content: " · ";
        white-space: pre;
    }

    .apteka-catalog .section-list__right {
        position: static;
        width: 100%;
    }

    .apteka-catalog .section-list__right .section-list__map {
        display: none;
        width: 100%;
        max-width: none;
        max-height: none;
        height: calc(100vh - 200px);
        height: calc(100dvh - 200px);
        min-height: 300px;
        border-radius: 16px;
        overflow: hidden;
    }

    .apteka-catalog .section-list__content.is-map-mode .section-list__content-left {
        display: none;
    }

    .apteka-catalog .section-list__content.is-map-mode .section-list__right .section-list__map {
        display: block;
    }
}

/* ---------- Балун метки на карте ---------- */

.apteka-catalog .popover {
    border: 0;
    border-radius: 18px;
    background: #fff;
    /* drop-shadow повторяет контур вместе со стрелкой, в отличие от box-shadow */
    filter: drop-shadow(0 6px 18px rgba(16, 24, 40, .18)) drop-shadow(0 1px 3px rgba(16, 24, 40, .12));
}

.apteka-catalog .popover .popover-title {
    padding: 14px 36px 2px 16px;
    border: 0;
    border-radius: 18px 18px 0 0;
    background: transparent;
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
}

.apteka-catalog .popover .popover-title a {
    color: #1b1b1b;
    text-decoration: none;
}

.apteka-catalog .popover .popover-title a:hover {
    color: #3f8b8b;
}

.apteka-catalog .popover .popover-content {
    padding: 4px 16px 14px;
    font-size: 13px;
    line-height: 1.5;
    color: #5b6470;
}

.apteka-catalog .popover a.pharmacy_phone_on_map {
    display: inline-block;
    margin-top: 6px;
    color: #3f8b8b;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
}

.apteka-catalog .popover a.pharmacy_phone_on_map:hover {
    color: #2d6a6a;
}

.apteka-catalog .popover .close {
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #f1f3f5;
    color: #6b7280;
    font-size: 18px;
    line-height: 23px;
    text-align: center;
    text-decoration: none;
}

.apteka-catalog .popover .close:hover {
    background: #e4e7ea;
    color: #1b1b1b;
}

/* Стрелка без серой обводки, белая часть остаётся */
.apteka-catalog .popover.top .arrow {
    border-top-color: transparent;
}
