/* ===== 通用基础样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 主题色 */
    --primary-color: #4a90d9;
    --primary-light: #6ba3e0;
    --primary-dark: #3a7bc8;

    /* 状态色 */
    --success-color: #52c41a;
    --error-color: #ff4d4f;
    --warning-color: #faad14;

    /* 背景色 */
    --bg-color: #f5f7fa;
    --bg-secondary: #eef1f5;
    --card-bg: #ffffff;

    /* 文字色 */
    --text-color: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;

    /* 边框和阴影 */
    --border-color: #e8e8e8;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);

    /* 圆角 */
    --radius-sm: 6px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* 安全区域 */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);

    /* 底部导航高度 */
    --bottom-nav-height: 60px;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 容器 */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== 通用组件 ===== */

/* 按钮基础样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

/* 返回按钮 */
.back-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-color);
    border-radius: 50%;
    transition: background 0.2s;
}

.back-btn:hover {
    background: var(--bg-secondary);
}

/* 图标按钮 */
.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--bg-secondary);
}

/* ===== 底部导航 ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    padding-bottom: var(--safe-area-bottom);
    background: var(--card-bg);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    text-decoration: none;
    color: var(--text-muted);
    transition: color 0.2s;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-icon {
    font-size: 22px;
    margin-bottom: 2px;
}

.nav-text {
    font-size: 11px;
}

/* ===== 进度条 ===== */
.progress-bar {
    height: 3px;
    background: var(--bg-secondary);
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

/* ===== 题型标签 ===== */
.question-type {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.question-type.single { background: #e6f7ff; color: #1890ff; }
.question-type.multiple { background: #f6ffed; color: #52c41a; }
.question-type.judge { background: #fff7e6; color: #fa8c16; }
.question-type.fill { background: #f9f0ff; color: #722ed1; }

/* ===== 空状态 ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-text {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ===== 响应式：隐藏元素 ===== */

/* 默认情况（移动端优先） */
.desktop-only {
    display: none !important;
}

/* PC端 */
@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }

    .desktop-only {
        display: block !important;
    }

    .desktop-only.flex,
    aside.desktop-only {
        display: flex !important;
    }
}

/* 移动端 */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }

    /* 移动端有底部导航时的内边距 */
    body.has-bottom-nav .app-container {
        padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    }
}

/* ===== 深色模式 ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a2e;
        --bg-secondary: #232342;
        --card-bg: #16213e;
        --text-color: #e8e8e8;
        --text-secondary: #a0a0a0;
        --text-muted: #777777;
        --border-color: #2a2a4a;
    }
}

/* ===== 动画 ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-up {
    animation: slideUp 0.3s ease;
}

/* ===== 加载遮罩 ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s, visibility 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-secondary);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 深色模式下的加载遮罩 */
@media (prefers-color-scheme: dark) {
    .loading-overlay {
        background: rgba(26, 26, 46, 0.95);
    }
}

