/* Profiles listing page — filter bar, cards, filters modal, Tom Select */
/* Relies on public/css/site.css for --st-accent and related variables */

/* ----- Filter bar ----- */
.filter-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    max-width: 100%;
    background: var(--st-surface);
    border-bottom: 1px solid var(--st-border);
    box-sizing: border-box;
}

.filter-inner {
    max-width: 900px;
    width: 100%;
    min-width: 0;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    box-sizing: border-box;
}

/* Search */
.search-box {
    flex: 1 1 100%;
    display: flex;
    min-width: 0;
    max-width: 100%;
    background: var(--st-input-bg);
    border-radius: 999px;
    padding: 6px;
    box-sizing: border-box;
}

.search-box input {
    flex: 1 1 0%;
    min-width: 0;
    border: none;
    background: transparent;
    padding: 12px 16px;
    outline: none;
    font-size: 15px;
}

.search-box button {
    flex-shrink: 0;
    background: var(--st-accent);
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.15s ease;
}

.search-box button:hover {
    background: var(--st-accent-hover);
    box-shadow: 0 2px 8px rgba(var(--st-accent-rgb), 0.35);
}

.search-box button:active {
    background: var(--st-accent-press);
    transform: scale(0.98);
}

.search-box button:focus-visible {
    outline: 2px solid var(--st-accent);
    outline-offset: 2px;
}

/* Actions */
.filter-actions {
    flex: 1 1 100%;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-outline {
    border: 1px solid var(--st-border);
    background: var(--st-surface);
    padding: 10px 18px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: var(--st-text);
    transition:
        border-color 0.2s ease,
        color 0.2s ease,
        background 0.2s ease,
        box-shadow 0.2s ease;
}

.btn-outline:hover {
    border-color: var(--st-accent);
    color: var(--st-accent);
    background: var(--st-accent-soft);
}

.btn-outline:focus-visible {
    outline: 2px solid var(--st-accent);
    outline-offset: 2px;
}

.btn-outline.has-filters-active {
    border-color: var(--st-accent);
    color: var(--st-accent);
    background: rgba(var(--st-accent-rgb), 0.1);
    box-shadow: 0 0 0 1px rgba(var(--st-accent-rgb), 0.25);
}

.btn-outline.has-filters-active:hover {
    border-color: var(--st-accent-hover);
    color: var(--st-accent-hover);
    background: rgba(var(--st-accent-rgb), 0.14);
}

.btn-reset {
    border: 1px solid var(--st-border);
    background: var(--st-surface);
    color: var(--st-muted);
    padding: 10px 20px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition:
        border-color 0.2s ease,
        color 0.2s ease,
        background 0.2s ease,
        box-shadow 0.2s ease;
}

.btn-reset:hover {
    border-color: var(--st-accent);
    color: var(--st-accent);
    background: var(--st-accent-soft);
}

.btn-reset:focus-visible {
    outline: 2px solid var(--st-accent);
    outline-offset: 2px;
}

.btn-reset:active {
    transform: scale(0.98);
}

/* ----- Content width (avoid Bootstrap .container quirks on narrow viewports) ----- */
.profiles-page__content {
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    box-sizing: border-box;
}

/* ----- Grid ----- */
.profiles-grid {
    width: 100%;
    max-width: 420px;
    margin: 32px auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

/* ----- Card ----- */
.profile-card {
    --card-r: 18px;
    max-width: 100%;
    background: #111;
    border-radius: var(--card-r);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.image-slider {
    position: relative;
    height: 360px;
    flex-shrink: 0;
    border-radius: var(--card-r) var(--card-r) 0 0;
    overflow: hidden;
}

.image-slider img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.image-slider img:first-child {
    display: block;
}

/* Arrows (‹ › часто визуально ниже центра круга — оптический сдвиг вверх) */
.slider-arrow {
    position: absolute;
    top: 50%;
    left: auto;
    right: auto;
    transform: translateY(calc(-50% - 3px));
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 28px;
    line-height: 0;
    border: none;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.slider-arrow.left {
    left: 10px;
}

.slider-arrow.right {
    right: 10px;
}

.image-slider .slider-img {
    cursor: pointer;
}

/* Fullscreen image lightbox (как overlay на Fansly) */
.image-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    padding: 16px;
    box-sizing: border-box;
}

.image-lightbox.active {
    display: block;
}

.image-lightbox__backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(0, 0, 0, 0.88);
    cursor: pointer;
}

.image-lightbox__close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 3;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--st-accent);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.15s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.image-lightbox__close:hover {
    background: var(--st-accent-hover);
    box-shadow: 0 2px 8px rgba(var(--st-accent-rgb), 0.45);
}

.image-lightbox__close:active {
    transform: scale(0.96);
    background: var(--st-accent-press);
}

.image-lightbox__close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Ряд: стрелки сразу рядом с фото (ширина ряда = картинка + стрелки) */
.image-lightbox__stage {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: min(96vw, 1200px);
    width: max-content;
    box-sizing: border-box;
}

/* Стрелки в лайтбоксе — как в карточке (‹ › чуть ниже центра; сдвиг вверх) */
.image-lightbox__arrow {
    position: relative;
    flex-shrink: 0;
    z-index: 4;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 30px;
    line-height: 0;
    border: none;
    margin: 0;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    transform: translateY(-3px);
    transition:
        background 0.2s ease,
        transform 0.15s ease;
}

.image-lightbox__arrow:hover {
    background: rgba(0, 0, 0, 0.65);
}

.image-lightbox__arrow:active {
    transform: translateY(-3px) scale(0.96);
}

.image-lightbox__arrow:focus-visible {
    outline: 2px solid var(--st-accent);
    outline-offset: 2px;
}

.image-lightbox--single .image-lightbox__arrow {
    display: none;
}

.image-lightbox__counter {
    position: absolute;
    bottom: max(20px, env(safe-area-inset-bottom, 20px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    pointer-events: none;
}

.image-lightbox__counter:empty {
    display: none;
}

.image-lightbox__frame {
    position: relative;
    flex: 0 1 auto;
    min-width: 0;
    max-width: min(calc(96vw - 120px), 1080px);
    max-height: 88vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-lightbox__frame .image-lightbox__img {
    display: block;
    max-width: 100%;
    max-height: 88vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

/* Content */
.profile-bottom {
    background: var(--st-surface);
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    border-radius: 0 0 var(--card-r) var(--card-r);
    overflow: hidden;
}

.profile-title {
    font-size: 20px;
    font-weight: 600;
}

.profile-username {
    font-size: 14px;
    color: var(--st-muted);
    margin-bottom: 10px;
}

/* Badges */
.profile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.badge {
    font-size: 13px;
    background: var(--st-input-bg);
    color: var(--st-text);
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 600;
}

.badge-new {
    background: var(--st-text);
    color: var(--st-surface);
}

/* Bio */
.bio-text {
    font-size: 15px;
    line-height: 1.4;
    color: var(--st-text);
}

.line-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bio-toggle {
    background: none;
    border: none;
    color: var(--st-accent);
    margin-top: 4px;
    cursor: pointer;
}

/* CTA — те же hover/active/focus, что у кнопки Search в .search-box */
.profile-cta-btn {
    margin-top: auto;
    background: var(--st-accent);
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.15s ease;
}

.profile-cta-btn:hover {
    background: var(--st-accent-hover);
    box-shadow: 0 2px 8px rgba(var(--st-accent-rgb), 0.35);
}

.profile-cta-btn:active {
    background: var(--st-accent-press);
    transform: scale(0.98);
}

.profile-cta-btn:focus-visible {
    outline: 2px solid var(--st-accent);
    outline-offset: 2px;
}

/* ----- Filters modal ----- */
.filters-modal {
    position: fixed;
    inset: 0;
    background: var(--st-surface);
    z-index: 200;
    display: none;
    animation: profiles-modal-fade 0.25s ease;
}

.filters-modal.active {
    display: block;
}

@keyframes profiles-modal-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-inner {
    max-width: 600px;
    margin: 0 auto;
    padding: 24px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--st-input-bg);
    cursor: pointer;
    font-size: 18px;
    transition: 0.2s;
}

.modal-close:hover {
    background: var(--st-text);
    color: var(--st-surface);
    transform: scale(1.05);
}

/* Inputs */
.filter-group {
    margin-bottom: 20px;
}

.filter-group label {
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

.filter-group input#filter-location {
    width: 100%;
    border: 1px solid var(--st-border);
    border-radius: 999px;
    padding: 12px 16px;
    font-size: 15px;
    outline: none;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.filter-group input#filter-location:focus {
    border-color: var(--st-accent);
    box-shadow: 0 0 0 3px rgba(var(--st-accent-rgb), 0.15);
}

/* Tom Select (filters modal) */
.filters-modal .ts-wrapper {
    position: relative;
}

.filters-modal .ts-wrapper.dropdown-active {
    z-index: 50;
}

.filters-modal .ts-control {
    border: 1px solid var(--st-border) !important;
    border-radius: 999px !important;
    padding: 8px 12px 8px 16px !important;
    min-height: 48px !important;
    box-shadow: none !important;
    background: var(--st-surface) !important;
    transition:
        border-color 0.2s ease,
        border-radius 0.15s ease;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px 8px !important;
}

.filters-modal .ts-wrapper.multi .ts-control > input {
    flex: 1 1 80px !important;
    min-width: 4em !important;
}

.filters-modal .ts-wrapper.focus .ts-control,
.filters-modal .ts-wrapper.dropdown-active .ts-control {
    border-color: var(--st-accent) !important;
}

.filters-modal .ts-wrapper.dropdown-active .ts-control {
    border-radius: 22px 22px 0 0 !important;
    border-bottom-color: transparent !important;
}

.filters-modal .ts-dropdown {
    margin: 0 !important;
    margin-top: -1px !important;
    border: 1px solid var(--st-border) !important;
    border-top: none !important;
    border-radius: 0 0 22px 22px !important;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08) !important;
    overflow: hidden;
    background: var(--st-surface) !important;
}

.filters-modal .ts-wrapper.dropdown-active .ts-dropdown {
    border-color: var(--st-accent) !important;
}

.filters-modal .ts-dropdown .option {
    padding: 12px 16px !important;
    border-radius: 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    color: var(--st-text) !important;
}

.filters-modal .ts-dropdown .option:hover,
.filters-modal .ts-dropdown .option.active {
    background: rgba(var(--st-accent-rgb), 0.08) !important;
}

.filters-modal .ts-dropdown .option:first-child {
    padding-top: 10px !important;
}

.filters-modal .ts-dropdown .option:last-child {
    padding-bottom: 10px !important;
}

.filters-modal .ts-wrapper.multi .ts-control > .item {
    display: inline-flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 6px 6px 6px 12px !important;
    border-radius: 999px !important;
    background: var(--st-input-bg) !important;
    border: 1px solid var(--st-border) !important;
    color: var(--st-text) !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
}

.filters-modal .ts-wrapper.multi .ts-control .item .remove {
    border-radius: 50% !important;
    padding: 2px 4px !important;
    margin-left: 4px !important;
    font-size: 16px !important;
    line-height: 1 !important;
    color: var(--st-muted) !important;
    border: none !important;
    background: transparent !important;
    opacity: 1 !important;
    transition:
        color 0.15s ease,
        background 0.15s ease;
}

.filters-modal .ts-wrapper.multi .ts-control .item .remove:hover {
    color: var(--st-accent) !important;
    background: rgba(var(--st-accent-rgb), 0.12) !important;
}

.filters-modal .ts-wrapper.multi .ts-control .item .remove:focus {
    outline: none !important;
}

.apply-btn {
    width: 100%;
    background: var(--st-accent);
    color: #fff;
    border: none;
    padding: 16px;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 600;
}

.close-filters {
    box-sizing: border-box;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    border: none;
    color: var(--st-text);
    background: rgba(0, 0, 0, 0.08);
    font-size: 20px;
    line-height: 0;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    display: grid;
    place-items: center;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition:
        background 0.2s ease,
        transform 0.15s ease,
        box-shadow 0.2s ease;
}

.close-filters:hover {
    background: rgba(0, 0, 0, 0.15);
}

.close-filters:active {
    transform: scale(0.95);
}

.close-filters:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.45);
}

@media (max-width: 576px) {
    .profiles-grid {
        max-width: 100%;
    }

    .image-slider {
        height: 300px;
    }

    /* Лайтбокс: картинка на ширину экрана, прокрутка и pinch/pan */
    .image-lightbox {
        padding: 0;
        -webkit-tap-highlight-color: transparent;
    }

    .image-lightbox__close {
        top: max(12px, env(safe-area-inset-top, 12px));
        right: max(12px, env(safe-area-inset-right, 12px));
    }

    /* Картинка на всю ширину; стрелки поверх, как в карточке */
    .image-lightbox__stage {
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        transform: none;
        display: block;
        width: 100%;
        max-width: none;
        height: 100%;
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        padding-left: env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
        box-sizing: border-box;
        position: absolute;
    }

    .image-lightbox__arrow {
        position: absolute;
        top: 50%;
        transform: translateY(calc(-50% - 3px));
        width: 44px;
        height: 44px;
        font-size: 26px;
        line-height: 0;
        z-index: 5;
    }

    .image-lightbox__arrow:active {
        transform: translateY(calc(-50% - 3px)) scale(0.96);
    }

    .image-lightbox__arrow--left {
        left: max(8px, env(safe-area-inset-left, 8px));
    }

    .image-lightbox__arrow--right {
        right: max(8px, env(safe-area-inset-right, 8px));
    }

    .image-lightbox__counter {
        bottom: max(16px, env(safe-area-inset-bottom, 16px));
        font-size: 12px;
    }

    .image-lightbox__frame {
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        max-width: none;
        max-height: none;
        height: 100%;
        min-height: 0;
        flex: none;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: stretch;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-x pan-y pinch-zoom;
        box-sizing: border-box;
    }

    .image-lightbox__frame .image-lightbox__img {
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 0;
        max-height: none;
        display: block;
        flex-shrink: 0;
        object-fit: contain;
        object-position: center center;
        border-radius: 0;
        box-shadow: none;
        touch-action: pan-x pan-y pinch-zoom;
        user-select: none;
        -webkit-user-drag: none;
    }
}

/* ----- Loading skeleton & empty state ----- */
@keyframes profiles-skeleton-pulse {
    0% {
        opacity: 0.55;
    }
    50% {
        opacity: 0.9;
    }
    100% {
        opacity: 0.55;
    }
}

.profiles-skeleton {
    display: none;
    gap: 24px;
    margin: 32px auto;
    max-width: 1200px;
    padding: 0 16px;
    box-sizing: border-box;
}

.profiles-skeleton--visible {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.profiles-skeleton__card {
    background: #111;
    border-radius: 18px;
    overflow: hidden;
    min-width: 0;
}

.profiles-skeleton__media {
    height: 360px;
    background: linear-gradient(90deg, #2a2a2a 0%, #3d3d3d 50%, #2a2a2a 100%);
    background-size: 200% 100%;
    animation: profiles-skeleton-pulse 1.4s ease-in-out infinite;
}

.profiles-skeleton__lines {
    padding: 16px 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profiles-skeleton__line {
    height: 14px;
    border-radius: 8px;
    background: #2a2a2a;
    animation: profiles-skeleton-pulse 1.4s ease-in-out infinite;
}

.profiles-skeleton__line--title {
    width: 72%;
}

.profiles-skeleton__line--short {
    width: 42%;
}

.profiles-empty {
    text-align: center;
    padding: 48px 20px 64px;
    max-width: 420px;
    margin: 0 auto;
}

.profiles-empty__title {
    margin: 0 0 8px;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--st-text);
}

.profiles-empty__hint {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--st-muted);
}
