/* ============================================
   Go在线运行工具 - 年轻化样式优化
   ============================================ */

/* CSS变量定义 - 统一颜色主题 */
:root {
    --go-primary: #667eea;
    --go-secondary: #764ba2;
    --go-accent: #f093fb;
    --go-success: #10b981;
    --go-dark: #1e1e1e;
    --go-dark-light: #2d2d2d;
    --go-text-light: #d4d4d4;
    --go-shadow-sm: 0 2px 4px rgba(102, 126, 234, 0.1);
    --go-shadow-md: 0 4px 6px -1px rgba(102, 126, 234, 0.2);
    --go-shadow-lg: 0 10px 15px -3px rgba(102, 126, 234, 0.3);
}

/* 基础样式 */
.row {
    display: flex;
    justify-content: center;
}

.ace_editor {
    min-width: 400px;
    min-height: 320px;
}

.h4-title {
    color: #337ab7;
    font-weight: bold;
    font-size: 22px;
}

#code {
    height: 400px;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.3s ease;
}

#code:focus-within {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
    border-color: var(--go-primary);
}

/* ============================================
   版本选择器
   ============================================ */
.version-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    border-radius: 12px;
    border: 2px solid rgba(102, 126, 234, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.version-selector-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.version-selector-wrapper:hover::before {
    left: 100%;
}

.version-selector-wrapper:hover {
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: var(--go-shadow-md);
    transform: translateY(-2px);
}

.version-selector-wrapper .form-label {
    margin-bottom: 0;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.3s ease;
}

.version-selector-wrapper:hover .form-label {
    color: var(--go-primary);
}

.version-selector-wrapper .form-label i {
    color: var(--go-primary);
    font-size: 1rem;
    animation: icon-bounce 2s ease-in-out infinite;
}

@keyframes icon-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

#codeSelect {
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    cursor: pointer;
    position: relative;
    max-width: 200px;
}

#codeSelect:hover {
    border-color: var(--go-primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    transform: scale(1.02);
}

#codeSelect:focus {
    border-color: var(--go-primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
    outline: none;
    transform: scale(1.02);
}

/* ============================================
   运行按钮
   ============================================ */
.run-button-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
    position: relative;
}

#run {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    padding: 0.75rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    letter-spacing: 0.3px;
}

#run::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

#run:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

#run:hover::before {
    width: 200px;
    height: 200px;
}

#run:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.2);
}

#run i {
    position: relative;
    z-index: 1;
    font-size: 1.1rem;
    transition: transform 0.3s ease;
}

#run:hover i {
    transform: scale(1.05);
}

#run span {
    position: relative;
    z-index: 1;
}

#run.loading {
    pointer-events: none;
    opacity: 0.7;
}

#run.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   输出区域
   ============================================ */
.output-wrapper {
    position: relative;
    margin-bottom: 1.5rem;
}

.output-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.output-label:hover {
    color: var(--go-secondary);
}

.output-label i {
    color: var(--go-secondary);
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.output-label:hover i {
    transform: scale(1.15);
}

.output-area {
    min-width: 400px;
    min-height: 190px;
    resize: none;
    background: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 50%, #1e1e1e 100%);
    background-size: 200% 100%;
    color: #d4d4d4 !important;
    font-family: 'Courier New', 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    border: 2px solid rgba(118, 75, 162, 0.3);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(118, 75, 162, 0.15);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow-y: auto;
}

.output-area::placeholder {
    color: #6b7280 !important;
    opacity: 0.7;
}

.output-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--go-secondary), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.output-area:focus {
    border-color: rgba(118, 75, 162, 0.7);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 0 4px rgba(118, 75, 162, 0.2);
    outline: none;
    background-position: right center;
    color: #d4d4d4 !important;
    background-color: #1e1e1e !important;
}

.output-area:focus::before {
    opacity: 1;
}

.output-area::-webkit-scrollbar {
    width: 8px;
}

.output-area::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.output-area::-webkit-scrollbar-thumb {
    background: rgba(118, 75, 162, 0.5);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.output-area::-webkit-scrollbar-thumb:hover {
    background: rgba(118, 75, 162, 0.7);
}

/* 确保选中文本时文字可见 */
.output-area::selection {
    background-color: rgba(118, 75, 162, 0.5);
    color: #ffffff;
}

.output-area::-moz-selection {
    background-color: rgba(118, 75, 162, 0.5);
    color: #ffffff;
}

/* ============================================
   加载和状态动画
   ============================================ */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* 成功状态 */
.output-area.success {
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* 错误状态 */
.output-area.error {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* ============================================
   响应式设计
   ============================================ */
@media (max-width: 768px) {
    .tool-page-title {
        font-size: 1.875rem;
    }
    
    .tool-page-title::after {
        width: 60px;
    }
    
    .version-selector-wrapper {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }
    
    #codeSelect {
        width: 80%;
        max-width: 200px;
    }
    
    #run {
        padding: 0.875rem 2rem;
        font-size: 1rem;
        width: 100%;
        max-width: 100%;
    }
    
    .ace_editor {
        min-width: 100%;
    }
    
    .output-area {
        min-width: 100%;
    }
    
    #code {
        height: 350px;
    }
}

@media (max-width: 480px) {
    .tool-page-title {
        font-size: 1.5rem;
    }
    
    .tool-page-header {
        margin-bottom: 2rem;
    }
    
    #code {
        height: 300px;
    }
}

/* ============================================
   页面加载动画
   ============================================ */
@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.tool-page-content {
    animation: fade-in 0.6s ease-out;
}

.version-selector-wrapper,
.editor-wrapper-container,
.run-button-wrapper,
.output-wrapper {
    animation: fade-in-up 0.6s ease-out both;
}

.version-selector-wrapper {
    animation-delay: 0.1s;
}

.editor-wrapper-container {
    animation-delay: 0.2s;
}

.run-button-wrapper {
    animation-delay: 0.3s;
}

.output-wrapper {
    animation-delay: 0.4s;
}