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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-bg: #eef2ff;
    --secondary: #ec4899;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1e293b;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Noto Sans SC', 'Poppins', sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    overflow: hidden;
    height: 100vh;
}

#app {
    display: flex;
    height: 100vh;
}

/* ===== 侧边导航栏 ===== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    flex-shrink: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.nav-group {
    margin-bottom: 24px;
}

.nav-group-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gray-400);
    padding: 0 12px;
    margin-bottom: 8px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--gray-300);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.nav-icon {
    font-size: 16px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
    white-space: nowrap;
}

.nav-item.has-submenu {
    justify-content: space-between;
}

.nav-item.has-submenu .arrow {
    font-size: 10px;
    transition: var(--transition);
    margin-left: auto;
}

.nav-item.has-submenu.expanded .arrow {
    transform: rotate(180deg);
}

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 8px;
}

.submenu.open {
    max-height: 300px;
}

.nav-item.sub {
    font-size: 13px;
    padding: 8px 12px 8px 28px;
    color: var(--gray-400);
}

.nav-item.sub:hover {
    color: var(--primary-light);
}

.nav-item.sub.active {
    background: var(--primary-dark);
    color: #fff;
}

/* ===== 主内容区 ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

.topbar {
    background: #fff;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray-700);
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-800);
    flex: 1;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-text {
    font-size: 14px;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 6px 14px;
    border-radius: 20px;
}

.content-container {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.content-container::-webkit-scrollbar {
    width: 6px;
}

.content-container::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 6px;
}

/* ===== 页脚 ===== */
.footer {
    background: #fff;
    border-top: 1px solid var(--gray-200);
    padding: 16px 32px;
    flex-shrink: 0;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--gray-400);
}

.footer-logo {
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.footer-divider {
    color: var(--gray-300);
}

.footer-copy {
    color: var(--gray-400);
}

/* ===== 按钮 ===== */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

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

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== 翻转卡片 ===== */
.flashcard-container {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.flashcard-counter {
    font-size: 16px;
    color: var(--gray-500);
    font-weight: 500;
}

.flashcard-counter .current {
    color: var(--primary);
    font-size: 20px;
    font-weight: 700;
}

.flashcard {
    width: 100%;
    height: 360px;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    box-shadow: var(--shadow-xl);
}

.flashcard-front {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
}

.flashcard-back {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    transform: rotateY(180deg);
}

.card-word {
    font-size: 42px;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    margin-bottom: 8px;
}

.card-phonetic {
    font-size: 18px;
    opacity: 0.8;
    font-style: italic;
}

.card-hint {
    margin-top: 24px;
    font-size: 13px;
    opacity: 0.6;
    letter-spacing: 0.5px;
}

.card-meaning {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.card-details {
    font-size: 15px;
    line-height: 1.8;
    text-align: left;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
}

.card-details .detail-row {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.card-details .detail-label {
    color: var(--primary-light);
    font-weight: 600;
    margin-right: 8px;
}

.card-details .detail-value {
    color: rgba(255, 255, 255, 0.9);
}

.flashcard-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.flashcard-actions {
    display: flex;
    gap: 12px;
}

/* ===== 练习模式 ===== */
.practice-container {
    max-width: 700px;
    margin: 0 auto;
}

.practice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 12px;
}

.practice-header h3 {
    font-size: 24px;
    color: var(--gray-800);
}

.practice-stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    font-size: 14px;
    color: var(--gray-500);
}

.stat-item strong {
    color: var(--primary);
    font-size: 18px;
}

.practice-question {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.practice-question .question-label {
    font-size: 13px;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.practice-question .question-text {
    font-size: 28px;
    font-weight: 600;
    color: var(--gray-800);
    font-family: 'Poppins', sans-serif;
}

.practice-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.option-btn {
    padding: 16px 20px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: #fff;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-family: inherit;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 12px;
}

.option-btn:hover:not(.disabled) {
    border-color: var(--primary);
    background: var(--primary-bg);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.option-btn .option-letter {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: var(--gray-500);
    flex-shrink: 0;
}

.option-btn.correct {
    border-color: var(--success);
    background: #d1fae5;
    color: var(--success);
}

.option-btn.correct .option-letter {
    background: var(--success);
    color: #fff;
}

.option-btn.wrong {
    border-color: var(--danger);
    background: #fee2e2;
    color: var(--danger);
}

.option-btn.wrong .option-letter {
    background: var(--danger);
    color: #fff;
}

.option-btn.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.practice-feedback {
    min-height: 60px;
    text-align: center;
    margin-bottom: 16px;
}

.feedback-correct {
    color: var(--success);
    font-size: 18px;
    font-weight: 600;
}

.feedback-wrong {
    color: var(--danger);
    font-size: 18px;
    font-weight: 600;
}

.feedback-explanation {
    color: var(--gray-600);
    font-size: 14px;
    margin-top: 8px;
}

.practice-controls {
    text-align: center;
}

/* ===== 练习结果 ===== */
.practice-result {
    text-align: center;
    padding: 48px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.result-score {
    font-size: 64px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
}

.result-label {
    font-size: 20px;
    color: var(--gray-600);
    margin-bottom: 32px;
}

.result-stars {
    font-size: 32px;
    margin-bottom: 24px;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--gray-400);
}

.empty-state .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state .empty-text {
    font-size: 16px;
}

/* ===== 模块说明卡片 ===== */
.module-info {
    background: var(--primary-bg);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
    border-left: 4px solid var(--primary);
    font-size: 14px;
    color: var(--gray-600);
    line-height: 1.6;
}

.module-info strong {
    color: var(--primary-dark);
}

/* ===== 词缀卡片特殊样式 ===== */
.affix-card .card-prefix {
    color: var(--warning);
    font-weight: 700;
}

.affix-card .card-root {
    color: #fff;
    font-weight: 700;
}

.affix-card .card-suffix {
    color: var(--success);
    font-weight: 700;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
    }

    .sidebar.collapsed {
        margin-left: calc(-1 * var(--sidebar-width));
    }

    .sidebar-toggle {
        display: block;
    }

    .menu-btn {
        display: block;
    }

    .content-container {
        padding: 16px;
    }

    .practice-options {
        grid-template-columns: 1fr;
    }

    .practice-stats {
        flex-wrap: wrap;
        gap: 12px;
    }

    .flashcard {
        height: 300px;
    }

    .card-word {
        font-size: 32px;
    }

    .flashcard-controls,
    .flashcard-actions {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ===== 动画 ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.shake {
    animation: shake 0.3s ease;
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

.bounce-in {
    animation: bounceIn 0.5s ease;
}
