/* ===== 变量定义 ===== */
:root {
    --primary-color: #5B5FC7;
    --primary-light: #E8E9FC;
    --primary-dark: #4547A9;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --success-light: #d4edda;
    --warning-color: #ffc107;
    --warning-light: #fff3cd;
    --info-color: #17a2b8;
    --info-light: #d1ecf1;
    --danger-color: #dc3545;
    --danger-light: #f8d7da;
    --sidebar-width: 260px;
    --sidebar-bg: #ffffff;
    --body-bg: #f5f7fa;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease;
}

/* ===== 全局样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: var(--body-bg);
    min-height: 100vh;
}

/* ===== 侧边栏 ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    padding: 20px 0;
    overflow-y: auto;
}

.sidebar-header {
    padding: 0 20px 15px;
}

.sidebar-header h4 {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.sidebar-header i {
    margin-right: 8px;
}

.sidebar hr {
    margin: 0 20px;
    opacity: 0.1;
}

.sidebar .nav-link {
    color: #555;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    transition: var(--transition);
    border-left: 3px solid transparent;
    font-size: 0.95rem;
}

.sidebar .nav-link i {
    margin-right: 12px;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar .nav-link:hover {
    background: var(--primary-light);
    color: var(--primary-color);
}

.sidebar .nav-link.active {
    background: var(--primary-light);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.sidebar-footer {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
}

/* ===== 主内容区 ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 0 20px;
}

/* ===== 欢迎区 ===== */
.welcome-section {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
}

.welcome-section h2 {
    color: white;
}

.welcome-section .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
}

.bg-primary-light {
    background-color: var(--primary-light) !important;
}

.bg-success-light {
    background-color: var(--success-light) !important;
}

.bg-warning-light {
    background-color: var(--warning-light) !important;
}

.bg-info-light {
    background-color: var(--info-light) !important;
}

/* ===== 统计卡片 ===== */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-right: 15px;
}

.stat-info h3 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0;
    color: #333;
}

.stat-info p {
    margin-bottom: 0;
    color: var(--secondary-color);
    font-size: 0.9rem;
}

/* ===== 功能卡片 ===== */
.feature-card {
    background: white;
    border-radius: 16px;
    padding: 25px;
    height: 100%;
    position: relative;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.feature-card-1::before {
    background: var(--primary-color);
}

.feature-card-2::before {
    background: var(--success-color);
}

.feature-card-3::before {
    background: var(--warning-color);
}

.feature-card-4::before {
    background: var(--info-color);
}

.feature-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.feature-card-1 .feature-icon {
    background: var(--primary-light);
    color: var(--primary-color);
}

.feature-card-2 .feature-icon {
    background: var(--success-light);
    color: var(--success-color);
}

.feature-card-3 .feature-icon {
    background: var(--warning-light);
    color: var(--warning-color);
}

.feature-card-4 .feature-icon {
    background: var(--info-light);
    color: var(--info-color);
}

.feature-card h5 {
    color: #333;
    font-weight: 600;
    margin-bottom: 10px;
}

.feature-card p {
    color: var(--secondary-color);
    font-size: 0.9rem;
    margin-bottom: 0;
}

.feature-arrow {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--body-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-color);
    transition: var(--transition);
}

.feature-card:hover .feature-arrow {
    background: var(--primary-color);
    color: white;
}

/* ===== 学习建议 ===== */
.tip-item {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    background: var(--body-bg);
    border-radius: 10px;
    transition: var(--transition);
}

.tip-item:hover {
    background: var(--primary-light);
}

.tip-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    margin-right: 12px;
    flex-shrink: 0;
}

.tip-item h6 {
    margin-bottom: 2px;
    font-weight: 600;
    color: #333;
}

/* ===== 最近学习列表 ===== */
.recent-list li {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.recent-list li:last-child {
    border-bottom: none;
}

/* ===== 词根网格 ===== */
.root-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
}

.root-item {
    background: var(--primary-light);
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    color: var(--primary-color);
}

.root-item:hover,
.root-item.active {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.root-item.learned {
    background: var(--success-light);
    color: var(--success-color);
}

.root-item.learned:hover,
.root-item.learned.active {
    background: var(--success-color);
    color: white;
}

/* ===== 词根详情区 ===== */
.root-detail {
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--card-shadow);
}

.root-detail-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.root-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    font-style: italic;
}

.root-meaning {
    display: flex;
    align-items: center;
    margin-top: 10px;
}

.root-meaning .badge {
    margin-right: 10px;
}

.word-example {
    background: var(--body-bg);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    transition: var(--transition);
}

.word-example:hover {
    background: var(--primary-light);
}

.word-example h5 {
    font-style: italic;
    color: #333;
    margin-bottom: 5px;
}

.word-example .phonetic {
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.word-example .meaning {
    color: #555;
    margin-top: 5px;
}

.word-example .composition {
    color: var(--primary-color);
    font-size: 0.85rem;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #ddd;
}

/* ===== 发音按钮 ===== */
.btn-speak {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--primary-light);
    color: var(--primary-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-speak:hover {
    background: var(--primary-color);
    color: white;
}

/* ===== 练习页面 ===== */
.practice-container {
    max-width: 800px;
    margin: 0 auto;
}

.practice-header {
    text-align: center;
    margin-bottom: 30px;
}

.practice-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.practice-question {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--card-shadow);
    text-align: center;
}

.practice-word {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    font-style: italic;
    margin-bottom: 10px;
}

.practice-meaning {
    color: var(--secondary-color);
    font-size: 1.1rem;
    margin-bottom: 25px;
}

/* 拆词练习 - 可选项 */
.split-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.split-option {
    padding: 10px 20px;
    background: var(--body-bg);
    border: 2px solid transparent;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.split-option:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.split-option.selected {
    background: var(--primary-color);
    color: white;
}

/* 拆词练习 - 答案区 */
.split-answer {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    min-height: 80px;
    background: var(--body-bg);
    border-radius: 12px;
    margin-bottom: 20px;
}

.split-slot {
    padding: 10px 20px;
    background: white;
    border: 2px dashed #ddd;
    border-radius: 8px;
    min-width: 80px;
    transition: var(--transition);
}

.split-slot.filled {
    border-style: solid;
    border-color: var(--primary-color);
    background: var(--primary-light);
}

/* 拼词练习 - 输入区 */
.spell-input-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.spell-letter-input {
    width: 45px;
    height: 55px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    border: 2px solid #ddd;
    border-radius: 8px;
    text-transform: uppercase;
    transition: var(--transition);
}

.spell-letter-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.spell-letter-input.correct {
    border-color: var(--success-color);
    background: var(--success-light);
}

.spell-letter-input.wrong {
    border-color: var(--danger-color);
    background: var(--danger-light);
}

.spell-letter-input.hint {
    background: var(--warning-light);
    border-color: var(--warning-color);
}

/* 练习反馈 */
.practice-feedback {
    padding: 15px;
    border-radius: 10px;
    margin-top: 20px;
    display: none;
}

.practice-feedback.correct {
    display: block;
    background: var(--success-light);
    color: var(--success-color);
}

.practice-feedback.wrong {
    display: block;
    background: var(--danger-light);
    color: var(--danger-color);
}

/* 练习按钮组 */
.practice-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
}

/* ===== 学习报告 ===== */
.report-card {
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--card-shadow);
    height: 100%;
}

.report-card h5 {
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.report-stat {
    text-align: center;
    padding: 20px;
}

.report-stat-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.report-stat-label {
    color: var(--secondary-color);
    margin-top: 5px;
}

.error-word-list {
    max-height: 300px;
    overflow-y: auto;
}

.error-word-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--body-bg);
    border-radius: 8px;
    margin-bottom: 8px;
}

.error-word-item:hover {
    background: var(--danger-light);
}

/* ===== 合成词卡片 ===== */
.compound-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    height: 100%;
}

.compound-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.compound-word {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-color);
    font-style: italic;
    margin-bottom: 10px;
}

.compound-parts {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.compound-part {
    padding: 4px 12px;
    background: var(--primary-light);
    color: var(--primary-color);
    border-radius: 20px;
    font-size: 0.85rem;
}

.compound-plus {
    color: var(--secondary-color);
}

.compound-meaning {
    color: #555;
    font-size: 0.95rem;
}

/* ===== 筛选区 ===== */
.filter-section {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow);
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: white;
    color: #555;
    cursor: pointer;
    transition: var(--transition);
    margin-right: 8px;
    margin-bottom: 8px;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ===== 搜索框 ===== */
.search-box {
    position: relative;
}

.search-box input {
    padding-left: 40px;
    border-radius: 25px;
    border: 1px solid #ddd;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary-color);
}

/* ===== 通用按钮 ===== */
.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.text-primary {
    color: var(--primary-color) !important;
}

/* ===== 响应式适配 ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: var(--transition);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-toggle {
        display: block !important;
    }
}

@media (max-width: 767.98px) {
    .stat-card {
        padding: 15px;
    }

    .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }

    .stat-info h3 {
        font-size: 1.4rem;
    }

    .feature-card {
        padding: 20px;
    }

    .root-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }

    .root-item {
        padding: 12px 8px;
        font-size: 0.9rem;
    }

    .practice-word {
        font-size: 1.8rem;
    }

    .spell-letter-input {
        width: 38px;
        height: 48px;
        font-size: 1.2rem;
    }
}

/* ===== 移动端菜单按钮 ===== */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1100;
    width: 45px;
    height: 45px;
    border-radius: 10px;
    background: white;
    border: none;
    box-shadow: var(--card-shadow);
    cursor: pointer;
}

/* ===== 加载动画 ===== */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid var(--primary-light);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

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

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}