/**
 * AI 自对弈学习面板样式
 */

/* ===== 自对弈学习面板 ===== */
.self-play-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    width: 600px;
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

.self-play-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.self-play-header h3 {
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.self-play-header .close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.self-play-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.self-play-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* ===== 学习状态区域 ===== */
.learning-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 10px;
}

.status-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    background: #95a5a6;
    color: white;
}

.status-badge.learning {
    background: #3498db;
    animation: pulse 1.5s infinite;
}

.status-badge.training {
    background: #9b59b6;
}

.status-badge.evaluating {
    background: #e67e22;
}

.iteration-info {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: #666;
}

.iteration-info b {
    color: #333;
    font-size: 16px;
}

/* ===== 进度条 ===== */
.learning-progress {
    margin-bottom: 20px;
}

.progress-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-item label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.progress-bar-container {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

#progressText {
    font-size: 12px;
    color: #999;
    text-align: right;
}

/* ===== 统计卡片 ===== */
.learning-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 14px 10px;
    text-align: center;
    border: 1px solid #e0e0e0;
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #666;
}

/* ===== 迭代图表 ===== */
.iteration-chart {
    height: 150px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 20px;
    padding: 10px;
    border: 1px solid #e0e0e0;
}

.iteration-chart canvas {
    width: 100%;
    height: 100%;
}

/* ===== 控制按钮 ===== */
.learning-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.learning-controls .control-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.learning-controls .control-btn:not(.primary):not(.danger) {
    background: #f0f0f0;
    color: #333;
}

.learning-controls .control-btn:not(.primary):not(.danger):hover:not(:disabled) {
    background: #e0e0e0;
}

.learning-controls .control-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.learning-controls .control-btn.primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.learning-controls .control-btn.danger {
    background: #e74c3c;
    color: white;
}

.learning-controls .control-btn.danger:hover:not(:disabled) {
    background: #c0392b;
}

.learning-controls .control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== 配置区域 ===== */
.learning-config {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
}

.learning-config h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #333;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.config-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #666;
}

.config-grid input {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
}

.config-grid input:focus {
    border-color: #667eea;
    outline: none;
}

/* ===== 日志区域 ===== */
.learning-log {
    background: #1e1e1e;
    border-radius: 10px;
    padding: 12px;
    max-height: 150px;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
}

.log-entry {
    padding: 4px 0;
    color: #ccc;
    border-bottom: 1px solid #333;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.success {
    color: #4caf50;
}

.log-entry.warning {
    color: #ff9800;
}

.log-entry.error {
    color: #f44336;
}

.log-entry.info {
    color: #64b5f6;
}

/* ===== 动画 ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===== 打开按钮（添加到主界面） ===== */
.self-play-toggle {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
    z-index: 99;
    transition: all 0.3s ease;
}

.self-play-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.self-play-toggle .icon {
    font-size: 20px;
}

/* ===== 响应式适配 ===== */
@media (max-width: 600px) {
    .self-play-panel {
        width: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: none;
    }
    
    .self-play-header {
        border-radius: 0;
    }
    
    .learning-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }
    
    .learning-controls {
        flex-wrap: wrap;
    }
    
    .learning-controls .control-btn {
        flex: 1 1 40%;
    }
}
