/* MySQL学习挑战平台 - 现代化纯色设计 */

/* CSS变量定义 */
:root {
    /* 主色调 - 深蓝色系 */
    --primary-blue: #1E40AF;
    --primary-light: #3B82F6;
    --primary-dark: #1E3A8A;
    
    /* 辅助色 - 绿色系 */
    --success-green: #059669;
    --success-light: #10B981;
    
    /* 警告色 - 橙色系 */
    --warning-orange: #D97706;
    --warning-light: #F59E0B;
    
    /* 错误色 - 红色系 */
    --error-red: #DC2626;
    --error-light: #EF4444;
    
    /* 中性色 - 灰色系 */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    
    /* 字体 */
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-mono: 'Courier New', Consolas, monospace;
    
    /* 圆角 */
    --border-radius-sm: 4px;
    --border-radius-md: 6px;
    --border-radius-lg: 8px;
    
    /* 阴影 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--gray-800);
    background-color: var(--gray-50);
}

/* 导航栏 */
header {
    background-color: var(--gray-900);
    border-bottom: 1px solid var(--gray-700);
    padding: 1rem 0;
}

header .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

header h1 {
    color: white;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

nav a {
    color: var(--gray-100);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-md);
    transition: background-color 0.2s;
    font-size: 0.9rem;
}

nav a:hover {
    background-color: var(--gray-800);
}

nav a.active {
    background-color: var(--primary-blue);
    color: white;
}

/* 主要内容区域 */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Hero区域 */
.hero {
    background-color: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.hero h2 {
    color: var(--gray-900);
    font-size: 2rem;
    margin-bottom: 1rem;
}

.hero p {
    color: var(--gray-600);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

/* 按钮样式 */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    border-radius: var(--border-radius-md);
    font-weight: 500;
    transition: all 0.2s;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-success {
    background-color: var(--success-green);
    color: white;
    border-color: var(--success-green);
}

.btn-success:hover {
    background-color: #047857;
    border-color: #047857;
}

.btn-warning {
    background-color: var(--warning-orange);
    color: white;
    border-color: var(--warning-orange);
}

.btn-warning:hover {
    background-color: #B45309;
    border-color: #B45309;
}

.btn-error {
    background-color: var(--error-red);
    color: white;
    border-color: var(--error-red);
}

.btn-error:hover {
    background-color: #B91C1C;
    border-color: #B91C1C;
}

.btn-secondary {
    background-color: var(--gray-500);
    color: white;
    border-color: var(--gray-500);
}

.btn-secondary:hover {
    background-color: var(--gray-600);
    border-color: var(--gray-600);
}

/* 特色功能网格 */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.feature-card {
    background-color: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.feature-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.feature-card h4 {
    color: var(--gray-900);
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.feature-card p {
    color: var(--gray-600);
    line-height: 1.6;
}

/* 用户统计 */
.user-stats {
    background-color: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    margin-top: 2rem;
}

.user-stats p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
    color: var(--gray-700);
}

.user-stats strong {
    color: var(--primary-blue);
    font-weight: 600;
}

/* 练习页面布局 */
.practice-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* 题目列表 */
.question-list {
    background-color: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    max-height: 80vh;
    overflow-y: auto;
}

.question-list h3 {
    color: var(--gray-900);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.questions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.question-item {
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

.question-item a {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    text-decoration: none;
    color: var(--gray-700);
    transition: background-color 0.2s;
    border-radius: var(--border-radius-sm);
}

.question-item a:hover {
    background-color: var(--gray-100);
}

.question-item.completed a {
    background-color: var(--success-light);
    color: white;
}

.question-item.in-progress a {
    background-color: var(--warning-light);
    color: white;
}

/* 难度标签 */
.difficulty-badge {
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.5rem;
    text-transform: uppercase;
}

.difficulty-badge.easy {
    background-color: var(--success-green);
    color: white;
}

.difficulty-badge.medium {
    background-color: var(--warning-orange);
    color: white;
}

.difficulty-badge.hard {
    background-color: var(--error-red);
    color: white;
}

.question-title {
    flex: 1;
    font-weight: 500;
}

.points {
    color: var(--success-green);
    font-weight: 600;
    margin-left: 0.5rem;
    font-size: 0.9rem;
}

.status {
    color: var(--success-green);
    font-weight: 600;
    margin-left: 0.5rem;
}

/* 练习区域 */
.practice-area {
    background-color: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

.question-header {
    margin-bottom: 2rem;
}

.question-header h2 {
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.question-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.category {
    background-color: var(--primary-light);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.question-description {
    margin-bottom: 2rem;
}

.question-description h3 {
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.question-description p {
    color: var(--gray-600);
    line-height: 1.6;
}

/* SQL编辑器 */
.sql-editor-container {
    margin-bottom: 1rem;
}

.sql-editor-container h3 {
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.CodeMirror {
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius-md);
    height: 300px;
    font-family: var(--font-mono);
}

.editor-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

/* 结果显示 */
.result-container {
    margin-bottom: 2rem;
}

.result-container h3 {
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.result-output {
    background-color: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    min-height: 100px;
    margin-bottom: 1rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.result-output pre {
    margin: 0;
    white-space: pre-wrap;
}

.result-message {
    padding: 1rem;
    border-radius: var(--border-radius-md);
    font-weight: 500;
}

.result-message.success {
    background-color: var(--success-light);
    color: white;
    border: 1px solid var(--success-green);
}

.result-message.error {
    background-color: var(--error-light);
    color: white;
    border: 1px solid var(--error-red);
}

.loading {
    text-align: center;
    color: var(--gray-500);
    font-style: italic;
}

.expected-result {
    background-color: var(--warning-light);
    border: 1px solid var(--warning-orange);
    border-radius: var(--border-radius-md);
    padding: 1rem;
}

.expected-result h3 {
    color: white;
    margin-bottom: 0.5rem;
}

.expected-result p {
    color: white;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

/* 表单样式 */
form {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
}

form h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--gray-900);
    font-size: 1.5rem;
}

form div {
    margin-bottom: 1rem;
}

form label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
    font-weight: 500;
}

form label i {
    margin-right: 0.5rem;
    color: var(--primary-blue);
}

form input[type="text"],
form input[type="password"],
form input[type="email"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius-md);
    font-size: 1rem;
    transition: border-color 0.2s;
}

form input[type="text"]:focus,
form input[type="password"]:focus,
form input[type="email"]:focus {
    outline: none;
    border-color: var(--primary-light);
}

form button {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--primary-blue);
    color: white;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

form button:hover {
    background-color: var(--primary-dark);
}

/* 错误消息样式 */
.error-messages {
    background-color: var(--error-light);
    border: 1px solid var(--error-red);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.error-messages p {
    color: white;
    margin: 0.25rem 0;
    font-weight: 500;
}

.error-messages p i {
    margin-right: 0.5rem;
}

/* 表单底部 */
.form-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.form-footer a {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 500;
}

.form-footer a:hover {
    text-decoration: underline;
}

/* 排行榜 */
.leaderboard {
    max-width: 800px;
    margin: 2rem auto;
}

.leaderboard table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.leaderboard th,
.leaderboard td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.leaderboard th {
    background-color: var(--gray-800);
    color: white;
    font-weight: 600;
}

.leaderboard tr:nth-child(even) {
    background-color: var(--gray-50);
}

.leaderboard tr:hover {
    background-color: var(--gray-100);
}

/* 成就页面 */
.achievements-header {
    text-align: center;
    margin-bottom: 2rem;
}

.user-progress {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.progress-item {
    background-color: white;
    border: 1px solid var(--gray-200);
    padding: 1rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.progress-item .label {
    display: block;
    color: var(--gray-600);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.progress-item .value {
    display: block;
    color: var(--primary-blue);
    font-size: 1.5rem;
    font-weight: 600;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.achievement-card {
    background-color: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: all 0.2s;
}

.achievement-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.achievement-card.earned {
    border: 2px solid var(--success-green);
}

.achievement-card.locked {
    opacity: 0.7;
    border: 2px solid var(--gray-300);
}

.achievement-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
    text-align: center;
}

.achievement-info h4 {
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.achievement-info p {
    color: var(--gray-600);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.achievement-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.achievement-meta .points {
    color: var(--success-green);
    font-weight: 600;
}

/* 页脚 */
footer {
    text-align: center;
    padding: 2rem 1rem;
    background-color: var(--gray-900);
    color: var(--gray-300);
    margin-top: 3rem;
    border-top: 1px solid var(--gray-700);
}

/* 响应式设计 */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.25rem;
    }

    nav {
        gap: 0.25rem;
    }

    nav a {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .hero {
        padding: 2rem 1rem;
    }

    .hero h2 {
        font-size: 1.5rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .practice-container {
        grid-template-columns: 1fr;
    }

    .question-list {
        max-height: 300px;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }

    .user-progress {
        grid-template-columns: repeat(2, 1fr);
    }

    .achievements-grid {
        grid-template-columns: 1fr;
    }

    .editor-actions {
        flex-direction: column;
    }

    .CodeMirror {
        height: 200px;
    }

    .question-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    main {
        padding: 0 0.5rem;
    }

    .hero {
        padding: 1.5rem 0.5rem;
    }

    .practice-area {
        padding: 1rem;
    }

    .question-list {
        padding: 1rem;
    }

    .feature-card {
        padding: 1.5rem;
    }
}
