/* ==================== PK挑战页面专用样式 ==================== */

/* PK挑战页面容器 */
.pk-challenge-page {
    min-height: 100vh;
    background: var(--gray-50);
    padding: var(--space-6);
}

.pk-container {
    max-width: 1000px;
    margin: 0 auto;
}

/* PK挑战头部 */
.pk-challenge-header {
    background: var(--primary-gradient);
    color: white;
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    text-align: center;
    margin-bottom: var(--space-6);
    position: relative;
    overflow: hidden;
}

.pk-challenge-header::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    opacity: 0.3;
}

.pk-challenge-header::after {
    content: '';
    position: absolute;
    bottom: -30px;
    left: -30px;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    opacity: 0.2;
}

.pk-challenge-header h1 {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    margin-bottom: var(--space-2);
    position: relative;
    z-index: 1;
}

.pk-challenge-header p {
    opacity: 0.9;
    font-size: var(--font-size-lg);
    position: relative;
    z-index: 1;
}

/* 正在进行的PK区域 */
.active-pk-section {
    margin-bottom: var(--space-6);
}

.active-pk-section h3 {
    color: var(--gray-700);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-xl);
    font-weight: 700;
}

.pk-battle-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.pk-battle-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
}

.pk-participants {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
}

.pk-participant {
    text-align: center;
    flex: 1;
}

.pk-participant-avatar {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    margin: 0 auto var(--space-3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: var(--font-size-2xl);
    position: relative;
}

.pk-participant-avatar.user {
    background: var(--primary-gradient);
}

.pk-participant-avatar.opponent {
    background: var(--success-gradient);
    color: var(--gray-700);
}

.pk-participant h4 {
    font-weight: 700;
    font-size: var(--font-size-lg);
    margin-bottom: var(--space-1);
    color: var(--gray-700);
}

.pk-participant .steps {
    color: var(--gray-500);
    font-size: var(--font-size-sm);
}

.pk-vs-indicator {
    background: var(--accent-gradient);
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--gray-700);
    font-size: var(--font-size-lg);
    margin: 0 var(--space-4);
}

.pk-challenge-info {
    text-align: center;
    margin-bottom: var(--space-4);
}

.pk-challenge-info h4 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--gray-700);
}

.pk-challenge-info p {
    color: var(--gray-500);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-3);
}

.pk-status-badge {
    background: var(--gray-100);
    border-radius: var(--radius-full);
    padding: var(--space-2) var(--space-4);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.pk-status-badge i {
    color: var(--gray-500);
    font-size: var(--font-size-sm);
}

.pk-status-badge span {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--gray-700);
}

.pk-actions {
    display: flex;
    gap: var(--space-3);
}

.pk-actions .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

/* 发起新挑战区域 */
.pk-create-section {
    margin-bottom: var(--space-6);
}

.pk-create-section h3 {
    color: var(--gray-700);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-xl);
    font-weight: 700;
}

.pk-create-form {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
    max-width: 100%;
    overflow: visible; /* 允许下拉框显示 */
}

.pk-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
    overflow: visible; /* 允许下拉框显示 */
}

.pk-form-group {
    position: relative;
    overflow: visible; /* 允许下拉框显示 */
    max-width: 100%;
}

.pk-form-group label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-2);
    font-size: var(--font-size-sm);
}

.pk-form-group input,
.pk-form-group select {
    width: 100%;
    padding: var(--space-3);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    transition: all var(--duration-normal) var(--ease-out);
    background: white;
}

/* 限制select下拉选项宽度，防止超出屏幕 */
.pk-form-group select {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* 确保下拉选项不会超出父容器 */
.pk-form-group select option {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 强制select元素占满容器 */
#challengeDuration {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* ==================== 自定义下拉选择器 ==================== */
.pk-custom-select {
    position: relative;
    width: 100%;
    user-select: none;
}

.pk-custom-select-trigger {
    width: 100%;
    padding: var(--space-3);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all var(--duration-normal) var(--ease-out);
    font-size: var(--font-size-base);
}

.pk-custom-select-trigger:hover {
    border-color: var(--primary-300);
}

.pk-custom-select.open .pk-custom-select-trigger {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.pk-custom-select-trigger i {
    transition: transform var(--duration-normal) var(--ease-out);
    color: var(--gray-500);
    font-size: 0.875rem;
}

.pk-custom-select.open .pk-custom-select-trigger i {
    transform: rotate(180deg);
}

.pk-custom-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9999;
}

.pk-custom-select.open .pk-custom-select-dropdown {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
    opacity: 1;
    visibility: visible;
}

.pk-custom-select-option {
    padding: var(--space-3);
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-out);
    font-size: var(--font-size-base);
}

.pk-custom-select-option:hover {
    background-color: var(--primary-50);
}

.pk-custom-select-option.selected {
    background-color: var(--primary-100);
    color: var(--primary-700);
    font-weight: 600;
}

.pk-custom-select-option:not(:last-child) {
    border-bottom: 1px solid var(--gray-100);
}

.pk-form-group input:focus,
.pk-form-group select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.pk-form-group.full-width {
    grid-column: 1 / -1;
}

/* 搜索结果下拉 */
.pk-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--gray-200);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.pk-search-result-item {
    padding: var(--space-3);
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    transition: background-color var(--duration-fast) var(--ease-out);
}

.pk-search-result-item:hover {
    background: var(--gray-50);
}

.pk-search-result-item:last-child {
    border-bottom: none;
}

.pk-search-result-item .user-id {
    font-weight: 600;
    color: var(--gray-700);
    font-size: var(--font-size-sm);
}

.pk-search-result-item .user-email {
    color: var(--gray-500);
    font-size: var(--font-size-xs);
    margin-top: var(--space-1);
}

/* 挑战列表区域 */
.pk-challenges-section {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
}

.pk-challenges-section h3 {
    color: var(--gray-700);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-xl);
    font-weight: 700;
}

.pk-challenges-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.pk-challenge-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    background: var(--gray-50);
    transition: all var(--duration-normal) var(--ease-out);
}

.pk-challenge-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary-200);
}

.pk-challenge-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.pk-challenge-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--primary-600);
    margin: 0;
}

.pk-challenge-status {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: white;
}

.pk-challenge-status.pending {
    background: var(--warning-gradient);
    color: var(--gray-700);
}

.pk-challenge-status.active {
    background: var(--primary-gradient);
}

.pk-challenge-status.completed {
    background: var(--success-gradient);
    color: var(--gray-700);
}

.pk-challenge-status.rejected {
    background: var(--danger-gradient);
}

.pk-challenge-status.cancelled {
    background: var(--gray-400);
}

.pk-challenge-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.pk-detail-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.pk-detail-item label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pk-detail-item span {
    font-size: var(--font-size-sm);
    color: var(--gray-700);
    font-weight: 500;
}

/* 挑战进度条 */
.pk-challenge-progress {
    background: white;
    padding: var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.pk-challenge-progress h5 {
    margin: 0 0 var(--space-3) 0;
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--gray-700);
}

.pk-progress-bars {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.pk-progress-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.pk-progress-item label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--gray-600);
}

.pk-progress-bar {
    background: var(--gray-200);
    border-radius: var(--radius-sm);
    height: 20px;
    overflow: hidden;
    position: relative;
}

.pk-progress-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width var(--duration-normal) var(--ease-out);
    position: relative;
}

.pk-progress-fill.user {
    background: var(--primary-gradient);
}

.pk-progress-fill.opponent {
    background: var(--success-gradient);
}

.pk-progress-text {
    font-size: var(--font-size-sm);
    color: var(--gray-600);
    font-weight: 500;
    margin-top: var(--space-1);
}

/* 挑战结果 */
.pk-challenge-result {
    background: var(--success-gradient);
    color: var(--gray-700);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    text-align: center;
    margin-top: var(--space-4);
}

.pk-challenge-result h5 {
    margin: 0 0 var(--space-2) 0;
    font-size: var(--font-size-lg);
    font-weight: 700;
}

.pk-challenge-result p {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: 500;
}

/* 挑战操作按钮 */
.pk-challenge-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.pk-challenge-actions .btn {
    font-size: var(--font-size-sm);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all var(--duration-normal) var(--ease-out);
}

/* 空状态 */
.pk-empty-state {
    text-align: center;
    padding: var(--space-12);
    color: var(--gray-500);
}

.pk-empty-state .empty-icon {
    font-size: 4rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.pk-empty-state h4 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--gray-600);
}

.pk-empty-state p {
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-4);
}

/* 加载状态 */
.pk-loading {
    text-align: center;
    padding: var(--space-8);
}

.pk-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--primary-500);
    border-radius: 50%;
    animation: pk-spin 1s linear infinite;
    margin: 0 auto var(--space-3);
}

@keyframes pk-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pk-loading p {
    color: var(--gray-500);
    font-size: var(--font-size-sm);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .pk-challenge-page {
        padding: var(--space-4);
    }
    
    .pk-challenge-header {
        padding: var(--space-6);
    }
    
    .pk-challenge-header h1 {
        font-size: var(--font-size-2xl);
    }
    
    .pk-form-grid {
        grid-template-columns: 1fr;
    }
    
    /* 移动端确保select不溢出 */
    .pk-form-group select {
        width: 100%;
        max-width: 100%;
    }
    
    .pk-participants {
        flex-direction: column;
        gap: var(--space-4);
    }
    
    .pk-vs-indicator {
        margin: var(--space-2) 0;
        transform: rotate(90deg);
    }
    
    .pk-challenge-details {
        grid-template-columns: 1fr;
    }
    
    .pk-actions {
        flex-direction: column;
    }
    
    .pk-challenge-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .pk-challenge-page {
        padding: var(--space-3);
    }
    
    .pk-challenge-header {
        padding: var(--space-4);
    }
    
    .pk-create-form,
    .pk-challenges-section {
        padding: var(--space-4);
    }
    
    .pk-participant-avatar {
        width: 60px;
        height: 60px;
        font-size: var(--font-size-lg);
    }
    
    .pk-vs-indicator {
        width: 50px;
        height: 50px;
        font-size: var(--font-size-base);
    }
}

/* 动画效果 */
.pk-challenge-item {
    animation: pk-fadeInUp 0.3s var(--ease-out);
}

@keyframes pk-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pk-search-result-item {
    animation: pk-fadeIn 0.2s var(--ease-out);
}

@keyframes pk-fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 按钮悬停效果 */
.pk-challenge-item:hover .pk-challenge-title {
    color: var(--primary-700);
}

.pk-form-group input:hover,
.pk-form-group select:hover {
    border-color: var(--primary-300);
}

/* 状态指示器 */
.pk-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.pk-status-indicator.leading {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-600);
}

.pk-status-indicator.trailing {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-600);
}

.pk-status-indicator.tie {
    background: rgba(156, 163, 175, 0.1);
    color: var(--gray-600);
}

/* 表单提示文本 */
.pk-form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #6c757d;
}

.pk-form-hint.error {
    color: var(--danger, #dc3545);
}

.pk-form-hint.success {
    color: var(--success, #28a745);
}
