/* =============================================================================
   РЕФЕРАЛЬНАЯ СИСТЕМА
   =============================================================================
   Использует дизайн-токены из tokens.css
   ============================================================================= */

/* ============= ОБЩИЕ СТИЛИ ============= */

#friendsTab {
    padding: 0;
}

/* ============= КАРТОЧКИ И КОНТЕЙНЕРЫ ============= */

/* Карточка статистики */
.referral-stats-card {
    background-color: var(--color-bg);
    border-radius: var(--radius-xl);
    padding: 0;
    margin-bottom: var(--space-1);
    width: 100%;
    box-sizing: border-box;
    transition: opacity var(--transition-normal);
}

.referral-stats-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

.referral-stats-card.loading * {
    transition: none !important;
    animation: none !important;
}

/* Карточка приглашения */
.referral-invite-card {
    background: linear-gradient(to top right, #0596FE, #0A74D8);
    border-radius: var(--radius-l);
    padding: var(--space-5);
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Паттерн звездочек как псевдоэлемент */
.referral-invite-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('../../images/icons/starspattern.svg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.1;
    pointer-events: none;
    z-index: 0;
}

/* Переопределение цвета текста для элементов внутри карточки приглашения */
.referral-invite-card .invite-title {
    color: #FFFFFF;
    position: relative;
    z-index: 1;
}

.referral-invite-card .invite-subtitle {
    color: rgba(255, 255, 255, 0.8);
    position: relative;
    z-index: 1;
}

/* Переопределение стилей кнопки внутри карточки приглашения */
.referral-invite-card .invite-button {
    background: transparent;
    color: #FFFFFF;
    border: 1px solid #FFFFFF;
    border-radius: var(--radius-full);
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-md);
    font-weight: var(--weight-medium);
    cursor: pointer;
    width: 100%;
    transition: all var(--transition-fast);
    position: relative;
    z-index: 1;
}

.referral-invite-card .invite-button:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* Карточка реферального баланса */
.referral-balance-card {
    border-radius: var(--radius-m);
    padding: 0 var(--space-3);
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 46px;
    box-sizing: border-box;
    border: 1px solid transparent;
    background: 
        linear-gradient(var(--color-surface), var(--color-surface)) padding-box,
        linear-gradient(to bottom left, var(--border-gradient-start), var(--border-gradient-end)) border-box;
}

/* ============= СТАТИСТИКА ============= */

.stats-row {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.stat-item {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: var(--radius-l);
    padding: var(--space-3) var(--space-2);
    border: 1px solid transparent;
    background: 
        linear-gradient(var(--color-surface), var(--color-surface)) padding-box,
        linear-gradient(to bottom left, var(--border-gradient-start), var(--border-gradient-end)) border-box;
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--color-text-tertiary);
    margin-bottom: var(--space-1);
}

.stat-value-container {
    display: flex;
    align-items: center;
    font-size: var(--text-lg);
}

.stat-value {
    font-size: inherit;
    font-weight: var(--weight-medium);
    color: var(--color-text);
}

.stat-icon {
    font-size: inherit;
    color: var(--color-text-tertiary);
    flex-shrink: 0;
}

.stat-value-container .profile-icon-stat {
    width: 1em;
    height: 1em;
    fill: currentColor;
    transform: none !important;
    animation: none !important;
    transition: none !important;
    position: static;
    flex-shrink: 0;
    margin-left: 3px;
}

.stat-value-container .crystal-icon {
    transform: none !important;
    animation: none !important;
    transition: none !important;
    position: static;
}

/* Цвет для SVG иконки кристалла в статистике */
.stat-value-container svg.crystal-icon,
.referral-history-item svg.crystal-icon--stats {
    fill: var(--color-text) !important;
    color: var(--color-text) !important;
}

/* ============= ФИЛЬТРЫ И ЗАГОЛОВКИ ============= */

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 var(--space-2) 0;
}

.stats-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-medium);
    color: var(--color-text);
    margin: 0;
}

.stats-period-filters {
    display: flex;
    border-radius: var(--radius-m);
    padding: 3px;
    gap: 2px;
    border: 1px solid transparent;
    background: 
        linear-gradient(var(--color-surface-secondary), var(--color-surface-secondary)) padding-box,
        linear-gradient(to bottom left, var(--border-gradient-start), var(--border-gradient-end)) border-box;
}

/* ============= БАЛАНС ============= */

.referral-balance-container {
    margin: 0;
    width: 100%;
}

.balance-info {
    display: flex;
    align-items: center;
    font-size: var(--text-md);
}

.balance-amount {
    font-size: inherit;
    font-weight: var(--weight-medium);
    color: var(--color-text);
}

/* ============= ТЕКСТ ============= */

.invite-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-medium);
    color: var(--color-text);
    margin: 0 0 var(--space-2) 0;
}

.invite-subtitle {
    font-size: var(--text-base);
    color: var(--color-text-tertiary);
    margin: 0 0 var(--space-5) 0;
}

.section-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-medium);
    color: var(--color-text);
    margin: 0 0 var(--space-4) 0;
}

/* ============= ИСТОРИЯ РЕФЕРАЛОВ ============= */

.referral-history-section {
    margin-top: var(--space-5);
}

.referral-history-container {
    width: 100%;
    margin-top: 0;
    max-height: 400px;
    overflow-y: auto;
    background-color: var(--color-bg);
    border-radius: var(--radius-xl);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.referral-history-container::-webkit-scrollbar {
    display: none;
}

.referral-history-list {
    width: 100%;
    background-color: var(--color-bg);
}

/* ============= ЭЛЕМЕНТЫ ИСТОРИИ - ТОЛЬКО РЕФЕРАЛЬНЫЕ ============= */

.referral-history-item {
    display: flex;
    align-items: center;
    padding: var(--space-2) 0;
    position: relative;
    gap: var(--space-3);
    background-color: var(--color-bg);
    width: 100%;
    box-sizing: border-box;
}

/* Разделительная линия */
.referral-history-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 44px;
    right: 0;
    height: 0.5px;
    background-color: var(--color-border);
    z-index: 1;
}

/* Убираем линию у последнего элемента */
.referral-history-item:last-child::after {
    display: none;
}

/* ============= АВАТАРЫ И ПОЛЬЗОВАТЕЛИ - ТОЛЬКО ДЛЯ REFERRAL ============= */

.referral-history-item .user-avatar {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    overflow: hidden;
    background-color: var(--color-surface-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.referral-history-item .user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    background-color: var(--color-surface);
}

.referral-history-item .user-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    color: var(--color-text-inverse);
    background: var(--gradient-button);
    border-radius: 50%;
}

.referral-history-item .user-name {
    flex: 1;
    font-size: var(--text-md);
    font-weight: var(--weight-normal);
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
}

.referral-history-item .user-name span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    display: block;
}

.referral-history-item .user-stats {
    font-size: var(--text-sm);
    color: var(--color-text-tertiary);
    margin-top: 1px;
    font-weight: var(--weight-normal);
}

.referral-history-item .user-position {
    font-size: var(--text-md);
    font-weight: var(--weight-normal);
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 40px;
    margin-left: auto;
    padding-left: var(--space-5);
    text-align: right;
}

.referral-history-item .user-position tgs-player {
    width: 30px !important;
    height: 30px !important;
    position: relative;
    transform: scale(1);
    margin: 0 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* ============= МОДАЛЬНОЕ ОКНО ============= */

.share-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-overlay);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    backdrop-filter: blur(var(--blur-sm));
}

.share-modal {
    background-color: var(--color-surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-width: 757px;
    height: 70vh;
    min-height: 400px;
    padding: var(--space-5);
    box-sizing: border-box;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.share-modal-overlay.show .share-modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-medium);
    color: var(--color-text);
    margin: 0;
}

.modal-close-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
}

.modal-close-button:hover {
    transform: scale(1.1);
}

.modal-close-button .close-icon {
    width: 24px;
    height: 24px;
    fill: var(--color-text);
    transform: rotate(45deg);
    transition: transform var(--transition-fast);
}

.modal-close-button:hover .close-icon {
    transform: rotate(45deg) scale(1.1);
}

.share-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.share-option {
    display: flex;
    align-items: center;
    padding: var(--space-4);
    border-radius: var(--radius-l);
    cursor: pointer;
    transition: all var(--transition-fast);
    gap: var(--space-4);
    border: 1px solid transparent;
    background: 
        linear-gradient(var(--color-surface-secondary), var(--color-surface-secondary)) padding-box,
        linear-gradient(to bottom left, var(--border-gradient-start), var(--border-gradient-end)) border-box;
}

.share-option:active {
    transform: scale(0.98);
    opacity: 0.8;
}

.share-option-icon {
    font-size: var(--text-xl);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.share-option-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.share-option-title {
    font-size: var(--text-md);
    font-weight: var(--weight-medium);
    color: var(--color-text);
}

.share-option-arrow {
    font-size: var(--text-lg);
    color: var(--color-text-tertiary);
    font-weight: var(--weight-light);
}

.referral-sticker {
    margin-top: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-6) 0 var(--space-8) 0;
    flex: 1;
}

.referral-sticker tgs-player {
    width: 120px !important;
    height: 120px !important;
    display: block;
    margin: 0 auto;
}

/* ============= АДАПТИВНОСТЬ ============= */

/* ============= ПУСТОЕ СОСТОЯНИЕ (НЕТ РЕФЕРАЛОВ) ============= */

.referral-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-6) var(--space-4);
    text-align: center;
}

.referral-empty-state tgs-player {
    width: 120px !important;
    height: 120px !important;
    display: block;
    margin: 0 auto var(--space-4) auto;
}

.referral-empty-state .empty-text {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    margin: 0;
}

/* ============= АДАПТИВНОСТЬ ============= */

@media (max-width: 360px) {
    .stats-row {
        flex-direction: column;
        gap: var(--space-3);
        margin-bottom: var(--space-3);
    }
    
    .stats-period-filters .stats-filter-button {
        font-size: var(--text-sm);
        padding: var(--space-2) var(--space-2);
    }
    
    .share-modal {
        padding: var(--space-4);
    }
    
    .share-option {
        padding: var(--space-3);
    }
}
