/**
 * Apple-Inspired Design System
 * 简约 · 大气 · 艺术感
 * 支持亮色/暗色主题切换
 */

/* === 设计变量 === */
:root {
    /* 品牌色 */
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-light: #147ce5;

    /* 亮色主题 (默认) */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #fbfbfd;
    --bg-card: #ffffff;
    --bg-hover: rgba(0, 0, 0, 0.04);

    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #86868b;

    --border-color: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.12);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.08);

    /* 字体 */
    --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'PingFang SC', sans-serif;
    --font-mono: 'SF Mono', 'Menlo', 'Monaco', monospace;

    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 980px;

    /* 过渡 */
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-fast: 0.2s var(--ease-out);
    --transition-normal: 0.3s var(--ease-out);
}

/* === 暗色主题 === */
[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #1d1d1f;
    --bg-tertiary: #161617;
    --bg-card: #1d1d1f;
    --bg-hover: rgba(255, 255, 255, 0.08);

    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #6e6e73;

    --border-color: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.12);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.3);
}

/* === 基础重置 === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 17px;
    transition: background var(--transition-normal), color var(--transition-normal);
}

/* === 排版 === */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

h1 { font-size: 48px; line-height: 1.1; font-weight: 700; }
h2 { font-size: 40px; line-height: 1.1; }
h3 { font-size: 32px; line-height: 1.15; }
h4 { font-size: 24px; line-height: 1.2; }
h5 { font-size: 20px; line-height: 1.25; }
h6 { font-size: 17px; line-height: 1.3; }

p {
    color: var(--text-secondary);
    line-height: 1.6;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-hover);
}

/* === 容器 === */
.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 22px;
}

.container-wide {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 22px;
}

.container-fluid {
    width: 100%;
    padding: 0 22px;
}

/* === 导航栏 === */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 48px;
    background: rgba(251, 251, 253, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-normal);
}

[data-theme="dark"] .nav {
    background: rgba(22, 22, 23, 0.8);
}

.nav-inner {
    max-width: 1024px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
}

.nav-logo {
    font-size: 21px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-link {
    font-size: 14px;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.nav-link:hover {
    color: var(--text-primary);
}

.nav-link.active {
    color: var(--text-primary);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* === 按钮 === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-sans);
    font-size: 17px;
    font-weight: 400;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

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

.btn-secondary {
    background: transparent;
    color: var(--accent);
}

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

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

.btn-outline:hover {
    background: var(--accent);
    color: #fff;
}

.btn-sm {
    font-size: 14px;
    padding: 8px 16px;
}

.btn-lg {
    font-size: 19px;
    padding: 16px 32px;
}

/* === 卡片 === */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.card-body {
    padding: 24px;
}

.card-title {
    font-size: 21px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.card-text {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* === 表单 === */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    font-family: var(--font-sans);
    font-size: 17px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

/* === Hero 区域 === */
.hero {
    padding: 120px 0 80px;
    text-align: center;
}

.hero-title {
    font-size: 56px;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 16px;
    background: linear-gradient(180deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 24px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 32px;
    line-height: 1.4;
}

.hero-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* === Section === */
.section {
    padding: 80px 0;
}

.section-alt {
    background: var(--bg-secondary);
}

.section-title {
    font-size: 40px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 16px;
}

.section-subtitle {
    font-size: 19px;
    color: var(--text-secondary);
    text-align: center;
    max-width: 600px;
    margin: 0 auto 48px;
}

/* === 网格 === */
.grid {
    display: grid;
    gap: 24px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* === 课程卡片 === */
.course-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.course-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.course-cover {
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}

.course-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.course-content {
    padding: 20px;
}

.course-title {
    font-size: 19px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.course-desc {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.course-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.course-price {
    font-size: 19px;
    font-weight: 600;
    color: var(--accent);
}

.course-price.free {
    color: #34c759;
}

.course-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-tertiary);
}

/* === 徽章 === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-full);
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.badge-primary {
    background: rgba(0, 113, 227, 0.1);
    color: var(--accent);
}

.badge-success {
    background: rgba(52, 199, 89, 0.1);
    color: #34c759;
}

/* === 用户菜单 === */
.user-menu {
    position: relative;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.user-avatar:hover {
    transform: scale(1.05);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
    z-index: 100;
}

.dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* === 主题切换 === */
.theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-hover);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* === 页脚 === */
.footer {
    padding: 48px 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-text {
    font-size: 13px;
    color: var(--text-tertiary);
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-link {
    font-size: 13px;
    color: var(--text-tertiary);
}

.footer-link:hover {
    color: var(--text-secondary);
}

/* === 统计数字 === */
.stat {
    text-align: center;
    padding: 24px;
}

.stat-value {
    font-size: 48px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* === 加载状态 === */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* === 通知 === */
.toast {
    position: fixed;
    top: 64px;
    right: 22px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 15px;
    color: var(--text-primary);
    transform: translateX(120%);
    transition: transform var(--transition-normal);
    z-index: 2000;
}

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

/* === 响应式 === */
@media (max-width: 768px) {
    body { font-size: 15px; }
    h1 { font-size: 32px; }
    h2 { font-size: 28px; }
    h3 { font-size: 24px; }

    .hero { padding: 80px 0 60px; }
    .hero-title { font-size: 36px; }
    .hero-subtitle { font-size: 19px; }

    .section { padding: 60px 0; }
    .section-title { font-size: 28px; }

    .nav-menu { display: none; }

    .stat-value { font-size: 36px; }
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* === 选择高亮 === */
::selection {
    background: rgba(0, 113, 227, 0.2);
}
