/* =========================================
   UI Kit - Profile Popup
   ========================================= */

/* Контейнер попапа */
.gc-profile-popup {
    position: fixed;
    z-index: var(--z-modal);
    display: none;
    pointer-events: auto;
    max-width: 95vw;
}

.gc-profile-popup.show {
    display: block;
    animation: popup-fade-in 0.15s ease;
}

@keyframes popup-fade-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Контент попапа */
.gc-profile-popup-content {
    background: var(--bg-content-main);
    border: 1px solid var(--ui-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 220px;
    overflow: hidden;
}

/* Секция с информацией о пользователе */
.gc-profile-popup-info {
    padding: var(--spacing-md);
    text-align: center;
}

.gc-profile-popup-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto var(--spacing-sm);
    display: block;
    background: var(--bg-content-secondary);
}

.gc-profile-popup-name {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--font-primary);
    margin: 0 0 var(--spacing-xs) 0;
    line-height: 1.3;
}

.gc-profile-popup-id {
    font-size: var(--font-size-sm);
    color: var(--font-secondary);
    margin: 0;
    line-height: 1.3;
}

.gc-profile-popup-telegram {
    font-size: var(--font-size-sm);
    color: var(--font-secondary);
    margin: var(--spacing-xs) 0 0 0;
    line-height: 1.3;
}

.gc-profile-popup-telegram a {
    color: var(--accent-link);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

.gc-profile-popup-telegram a:hover {
    opacity: 0.8;
}

/* Секция с действиями */
.gc-profile-popup-actions {
    display: flex;
    flex-direction: column;
}

/* Кнопки действий */
.gc-profile-popup-action {
    display: block;
    padding: var(--spacing-sm);
    background: transparent;
    border: none;
    border-top: 1px solid var(--ui-border);
    color: var(--font-primary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition-fast);
    width: 100%;
}

.gc-profile-popup-action:first-child {
    border-top: none;
}

/* В попапе оружия кнопка всегда идёт после медиа+инфо блока — граница нужна */
.gc-weapon-popup .gc-profile-popup-action:first-child {
    border-top: 1px solid var(--ui-border);
}

.gc-profile-popup-action:hover {
    background: var(--bg-content-secondary);
    color: var(--font-primary);
}

/* Скелетон загрузки (gc-skeleton из skeleton.css) */
.gc-profile-popup.is-loading .gc-profile-popup-loaded {
    display: none;
}

.gc-profile-popup:not(.is-loading) .gc-profile-popup-skeleton {
    display: none;
}

.gc-profile-popup-skeleton-inner {
    padding: var(--spacing-md);
    text-align: center;
}

.gc-profile-popup-skeleton-lines {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
    max-width: 12rem;
    margin-left: auto;
    margin-right: auto;
}

.gc-profile-popup-skeleton-lines .gc-skeleton {
    display: block;
}

.gc-profile-popup-skeleton-avatar {
    margin-left: auto;
    margin-right: auto;
}

/* Адаптивность */
@media (max-width: 767px) {
    .gc-profile-popup-content {
        min-width: 200px;
        max-width: 90vw;
    }
    
    .gc-profile-popup-avatar {
        width: 40px;
        height: 40px;
    }

    .gc-profile-popup-skeleton .gc-profile-popup-skeleton-avatar {
        width: 40px;
        height: 40px;
    }
}

/* Исправление для iOS */
@supports (-webkit-touch-callout: none) {
    .gc-profile-popup {
        transform: translateZ(0);
    }
}


/* =========================================
   Weapon Popup
   ========================================= */

.gc-weapon-popup {
    position: fixed;
    z-index: var(--z-modal);
    display: none;
    pointer-events: auto;
    max-width: min(280px, 94vw);
}

.gc-weapon-popup.show {
    display: block;
    /* Без popup-fade-in: при смене скелетона↔контент анимация с from{opacity:0} даёт «мигание/половина пропала» */
    opacity: 1;
    transform: none;
}

.gc-weapon-popup-stack {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 280px;
    max-width: min(280px, 94vw);
    box-sizing: border-box;
}

/* Полоса статуса — как у карточки оружия, с «заездом» контента снизу.
 * pointer-events: auto — иначе клик «по полосе» проваливается на триггер под попапом и не считается кликом по #weaponPopup. */
.gc-weapon-popup-strip.weapon-card-strip-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    position: relative;
    z-index: 0;
    padding: 0;
    pointer-events: auto;
}

.gc-weapon-popup-stack--has-strip .gc-weapon-popup-content {
    margin-top: calc(-1 * (var(--spacing-md) + var(--spacing-xs)));
    position: relative;
    z-index: 1;
}

.gc-weapon-popup-content {
    background: var(--bg-content-main);
    border: 1px solid var(--ui-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

/* Медиа-блок: 16:9 как у карточки оружия (.weapon-card-media) на /weapons */
.gc-weapon-popup-media {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    flex-shrink: 0;
    background: var(--bg-content-secondary);
    overflow: hidden;
}

/* Фото: blur + contain как .weapon-card-image на /weapons (см. cards.css) */

/* Заглушка: центр, единый размер SVG */
.gc-weapon-popup-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    box-sizing: border-box;
}

.gc-weapon-popup-media .gc-weapon-popup-fallback img.gc-weapon-popup-fallback-img {
    /* Широкие SVG (карабин, ружьё): до 96×64 по токенам, без крошечного квадрата 48×48 */
    width: min(92%, var(--spacing-4xl));
    height: auto;
    max-height: var(--spacing-3xl);
    flex-shrink: 0;
    object-fit: contain;
    object-position: center;
    display: block;
    /* SVG в файлах — светлый силуэт; без svg-theme-adaptive (не инвертировать в тёмной теме) */
    filter: none;
    opacity: 0.82;
}

[data-theme="light"] .gc-weapon-popup-media .gc-weapon-popup-fallback img.gc-weapon-popup-fallback-img {
    filter: invert(1);
    opacity: 0.42;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .gc-weapon-popup-media .gc-weapon-popup-fallback img.gc-weapon-popup-fallback-img {
        filter: invert(1);
        opacity: 0.42;
    }
}

.gc-weapon-popup-info {
    padding: var(--spacing-3sm);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.gc-weapon-popup-name {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--font-primary);
    margin: 0;
    line-height: 1.3;
}

.gc-weapon-popup-meta {
    font-size: var(--font-size-xs);
    color: var(--font-secondary);
    margin: 0;
    line-height: 1.4;
}

.gc-weapon-popup.is-loading .gc-weapon-popup-loaded {
    display: none;
}

.gc-weapon-popup:not(.is-loading) .gc-weapon-popup-skeleton {
    display: none;
}

.gc-weapon-popup-skeleton-media {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    flex-shrink: 0;
    background: var(--bg-content-secondary);
    overflow: hidden;
}

.gc-weapon-popup-skeleton-media-fill {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    display: block;
}

.gc-weapon-popup-skeleton-info {
    padding: var(--spacing-3sm);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.gc-weapon-popup-skeleton-meta {
    margin-top: var(--spacing-3xs);
}

.gc-weapon-popup-skeleton-actions {
    padding: 0 var(--spacing-3sm) var(--spacing-3sm);
}

.gc-weapon-popup-skeleton-action {
    height: var(--font-size-mdl);
    min-height: 2.75rem;
}

@media (max-width: 767px) {
    .gc-weapon-popup-stack {
        width: min(280px, 90vw);
        max-width: min(280px, 90vw);
    }
}

/* Попап «лучший результат» поверх Bootstrap-модалки превью брифинга (gc-modal ~9050) */
.gc-stage-best-result-popup {
    z-index: 9060;
}

.gc-stage-best-result-popup .gc-profile-popup-content {
    max-width: min(248px, 92vw);
    text-align: left;
}

.gc-stage-best-result-popup__body {
    padding: var(--spacing-mdl);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    align-items: stretch;
}

.gc-stage-best-result-popup__head {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--spacing-sm);
    min-width: 0;
}

.gc-stage-best-result-popup__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-content-secondary);
}

.gc-popup-head-text,
.gc-stage-best-result-popup__head-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.gc-stage-best-result-popup__name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--font-primary);
    margin: 0;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gc-stage-best-result-popup__meta {
    font-size: var(--font-size-xs);
    font-weight: 400;
    color: var(--font-secondary);
    margin: 0;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gc-stage-best-result-popup__zones {
    min-width: 0;
}

.gc-stage-best-result-popup__metrics {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    width: 100%;
    min-width: 0;
}

.gc-stage-best-result-popup__metrics[hidden] {
    display: none !important;
}

.gc-stage-best-result-popup__metrics--training {
    justify-content: center;
}

/* Строка метрик: как в Figma — слева HF (иконка + число), справа время (число + иконка), без gc-badge */
.gc-stage-best-result-popup__hit-factor {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-3xs);
    min-width: 0;
}

.gc-stage-best-result-popup__hf-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: block;
    object-fit: contain;
}

.gc-stage-best-result-popup__hf-value {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--font-primary);
    line-height: 1.2;
    white-space: nowrap;
}

.gc-stage-best-result-popup__time {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-3xs);
    min-width: 0;
}

.gc-stage-best-result-popup__time-value {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--font-primary);
    line-height: 1.2;
    white-space: nowrap;
}

/* Иконка таймера — вторичный цвет (как в макете); цвет задаём на обёртке, иконка наследует currentColor */
.gc-stage-best-result-popup__time-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    color: var(--font-primary);
    flex-shrink: 0;
}

.gc-stage-best-result-popup__time-icon .ph-fill {
    font-size: 20px;
}

.gc-stage-best-result-popup__training-only {
    width: 100%;
    text-align: center;
}

.gc-stage-best-result-popup .gc-profile-popup-actions {
    border-top: 1px solid var(--ui-border);
}

/* /weapons/{id} — мини-попап упражнений (как #stageBestResultPopup: fixed + позиция от клика) */
.gc-weapon-history-exercises-popup {
    z-index: 9060;
}

.gc-weapon-history-exercises-popup .gc-profile-popup-content {
    max-width: min(248px, 92vw);
    text-align: left;
}

/* Иконка + две строки текста — как в строке списка (иконка к верху блока текста) */
.gc-weapon-history-exercises-popup .gc-stage-best-result-popup__head {
    align-items: flex-start;
}

.gc-weapon-history-exercises-popup__head .gc-list-media-icon i {
    font-size: var(--font-size-md);
}

.gc-weapon-history-exercises-popup__list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    width: 100%;
    min-width: 0;
}

.gc-weapon-history-exercises-popup__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    width: 100%;
    min-width: 0;
}

.gc-weapon-history-exercises-popup__ex-label {
    font-size: var(--font-size-sm);
    font-weight: 400;
    line-height: 1.5;
    color: var(--font-secondary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gc-weapon-history-exercises-popup__ex-right {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--spacing-xs);
    flex-shrink: 0;
}

.gc-weapon-history-exercises-popup__hf-icon {
    width: var(--font-size-xl);
    height: var(--font-size-xl);
    object-fit: contain;
    flex-shrink: 0;
    display: block;
}

.gc-weapon-history-exercises-popup__hf-val {
    font-size: var(--font-size-sm);
    font-weight: 600;
    line-height: 1.5;
    color: var(--font-primary);
}

.gc-weapon-history-exercises-popup__ex-plain {
    font-size: var(--font-size-sm);
    font-weight: 400;
    color: var(--font-secondary);
}

.gc-weapon-history-exercises-popup .gc-profile-popup-actions {
    border-top: 1px solid var(--ui-border);
}
