/* =========================================
   1. 全局基础样式 (Global Reset)
   ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    /* 核心背景：深邃的蓝紫渐变 */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    color: #2d3748;
    line-height: 1.6;
    min-height: 100vh;
}

a { text-decoration: none; }

/* =========================================
   2. 登录与注册页面 (Auth Pages)
   ========================================= */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-card {
    background: #ffffff;
    width: 100%;
    max-width: 420px;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    text-align: center;
    transition: transform 0.3s;
}
.auth-card:hover { transform: translateY(-5px); }

.auth-header { margin-bottom: 30px; }
.auth-icon { font-size: 48px; display: block; margin-bottom: 10px; }
.auth-title { font-size: 24px; font-weight: 700; color: #1a202c; }
.auth-subtitle { font-size: 14px; color: #718096; margin-top: 5px; }

.form-group { margin-bottom: 20px; text-align: left; }
.input-label { display: block; font-size: 14px; font-weight: 600; color: #4a5568; margin-bottom: 8px; }

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    background: #f7fafc;
    transition: 0.3s;
    outline: none;
}
.form-control:focus {
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 10px;
}
.btn-primary:hover { opacity: 0.9; transform: scale(1.02); }

.auth-footer { margin-top: 25px; font-size: 14px; color: #718096; }
.link { color: #667eea; font-weight: 600; }
.link:hover { text-decoration: underline; }

.flash-message {
    padding: 12px;
    background-color: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
    border-radius: 8px;
    margin-top: 20px;
    font-size: 14px;
}

/* =========================================
   3. 顶部导航栏 (Navbar)
   ========================================= */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav-brand { font-size: 20px; font-weight: 800; color: white; display: flex; align-items: center; gap: 10px; }
.nav-user { color: white; font-size: 15px; display: flex; align-items: center; }

.btn-logout {
    padding: 6px 16px;
    background: rgba(0, 0, 0, 0.25);
    color: white;
    border-radius: 20px;
    margin-left: 15px;
    font-size: 13px;
    transition: 0.2s;
    border: 1px solid rgba(255,255,255,0.2);
}
.btn-logout:hover { background: rgba(0, 0, 0, 0.5); }

/* =========================================
   4. 首页控制台 (Dashboard)
   ========================================= */
.dashboard-container {
    max-width: 1000px;
    margin: 100px auto 40px;
    padding: 20px;
}

.hero-section { text-align: center; color: white; margin-bottom: 40px; }
.hero-title { font-size: 2.8em; font-weight: 800; margin-bottom: 10px; text-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.hero-subtitle { font-size: 1.2em; opacity: 0.9; font-weight: 300; }

.modes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
}

.mode-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 35px;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.mode-card:hover { transform: translateY(-10px); box-shadow: 0 20px 40px rgba(0,0,0,0.25); }

.mode-icon { font-size: 4.5em; margin-bottom: 15px; display: block; }
.mode-title { font-size: 1.6em; color: #2d3748; margin-bottom: 10px; font-weight: 700; }
.mode-desc { color: #718096; margin-bottom: 30px; font-size: 0.95em; }

.btn-mode { display: block; width: 100%; padding: 14px; border-radius: 10px; font-weight: 700; text-align: center; transition: 0.2s; }

.btn-endless {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5253 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(238, 82, 83, 0.3);
}
.btn-endless:hover { filter: brightness(1.1); transform: scale(1.02); }

.papers-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.btn-paper { background-color: #edf2f7; color: #4a5568; padding: 10px; }
.btn-paper:hover { background-color: #667eea; color: white; }

/* =========================================
   5. 考试做题页面 (Exam Page)
   ========================================= */
.container {
    max-width: 850px;
    margin: 90px auto 60px;
    padding: 0 20px;
}

.header {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 12px;
    margin-bottom: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.header h2 { font-size: 1.4rem; color: #2d3748; margin: 0; }

.section-title {
    color: white;
    font-size: 1.4rem;
    font-weight: 800;
    margin: 40px 0 20px;
    display: flex;
    align-items: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.section-title::before {
    content: ''; width: 6px; height: 24px; background: #fff; margin-right: 12px; border-radius: 4px;
}

.question-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 25px 30px;
    margin-bottom: 25px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    border: 2px solid transparent;
    transition: transform 0.2s;
    position: relative;
}
.question-card:hover { transform: translateY(-2px); box-shadow: 0 10px 25px rgba(0,0,0,0.08); }
.question-card p strong { color: #2d3748; font-size: 1.1rem; }

/* 题目描述里的代码块美化 */
.question-card pre {
    background: #f6f8fa;
    color: #24292e;
    padding: 15px;
    border-radius: 6px;
    border-left: 5px solid #667eea;
    font-family: 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.5;
    margin: 15px 0;
    white-space: pre-wrap; /* 允许换行，解决滚动条问题 */
    word-wrap: break-word;
    max-width: 100%;
    overflow-x: hidden;
    max-height: none;      /* 允许垂直撑开 */
}

/* 选项列表 */
.options-list { display: flex; flex-direction: column; gap: 10px; margin-top: 15px; }

.option-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8fafc;
    color: #4a5568;
    font-weight: 500;
}
.option-item:hover { background: #ebf4ff; border-color: #667eea; color: #2b6cb0; }
.option-item input { margin-right: 10px; transform: scale(1.2); }

/* 填空题输入 */
.fill-input {
    width: 100%;
    max-width: 400px;
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    margin-top: 10px;
    background: #f7fafc;
    outline: none;
}
.fill-input:focus { border-color: #667eea; background: white; }

/* 底部工具栏 */
.question-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed #edf2f7;
    /* 【关键修改】取消 Flex 布局，改回默认 Block，防止左右乱挤 */
    display: block; 
    text-align: left; /* 强制内容左对齐 */
}

/* 查看答案按钮 */
.btn-peek {
    background: #f6ad55;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px; /*稍微方一点，看起来更严谨*/
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
    display: inline-block; /* 确保它是个块块 */
}
.btn-peek:hover {
    background: #ed8936;
}

.btn-submit-paper {
    background: linear-gradient(90deg, #48bb78 0%, #38a169 100%);
    color: white;
    width: 100%;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: 800;
    border: none;
    border-radius: 50px;
    margin-top: 40px;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(72, 187, 120, 0.4);
    transition: 0.3s;
}
.btn-submit-paper:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(72, 187, 120, 0.5); }

/* =========================================
   6. 智能代码编辑器 (Smart Code Editor)
   ========================================= */
.code-editor-container {
    margin-top: 15px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    border: 1px solid #333;
}

.code-textarea {
    width: 100%;
    /* 【核心】自动高度逻辑的初始状态 */
    min-height: 200px;
    height: auto;
    background-color: #1e1e1e; /* 深色背景 */
    color: #d4d4d4;            /* 代码白 */
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 15px;
    padding: 20px;
    border: none;
    resize: none;              /* 禁止手动拖拽，交给JS */
    outline: none;
    line-height: 1.6;
    white-space: pre;          /* 保持格式 */
    tab-size: 4;
    overflow-y: hidden;        /* 隐藏垂直滚动条，靠JS撑开 */
}

.code-textarea:focus { box-shadow: inset 0 0 0 2px #5caef3; }

/* =========================================
   7. 无尽模式专用 (Endless Mode)
   ========================================= */
#next-btn {
    background: linear-gradient(135deg, #6B73FF 0%, #000DFF 100%);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 16px 30px;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0, 13, 255, 0.3);
    width: 100%;
    margin-top: 30px;
    display: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#next-btn:hover { transform: translateY(-4px) scale(1.01); box-shadow: 0 15px 30px rgba(0, 13, 255, 0.4); }

.btn-confirm {
    background: linear-gradient(90deg, #00b09b 0%, #96c93d 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 10px;
    box-shadow: 0 4px 10px rgba(150, 201, 61, 0.3);
}

.q-category {
    background: #805ad5; color: white; padding: 4px 10px; border-radius: 6px;
    font-size: 0.8em; font-weight: bold; margin-bottom: 10px; display: inline-block;
}

.card-correct { border-color: #48bb78; background: #f0fff4; }
.card-wrong { border-color: #f56565; background: #fff5f5; }
.feedback { margin-top: 20px; padding: 15px; border-radius: 8px; display: none; line-height: 1.6; }
.feedback.correct { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.feedback.wrong { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* 答案显示框 */
.peek-box {
    margin-top: 15px; 
    padding: 15px; 
    background: #2d3748; /* 改成深色背景，和代码题更搭 */
    border-left: 5px solid #ed8936; /* 橙色竖条 */
    color: #edf2f7; /* 浅色文字 */
    font-weight: 500; 
    display: none; 
    
    /* 【核心修复】确保内容左对齐，且保留格式 */
    text-align: left; 
    font-family: 'Consolas', 'Monaco', monospace; 
    white-space: pre-wrap; /* 保留换行和空格 */
    word-break: break-all; /* 防止长代码撑破框 */
    line-height: 1.6;
    border-radius: 4px;
}
.ans-hint { margin-top: 10px; padding: 10px; background: #fff5f5; color: #e53e3e; border-radius: 6px; }