/* iOS风格样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary-color: #007AFF;
    --success-color: #34C759;
    --warning-color: #FF9500;
    --danger-color: #FF3B30;
    --gray-color: #8E8E93;
    --light-gray: #F2F2F7;
    --bg-color: #F5F5F7;
    --card-bg: #FFFFFF;
    --text-primary: #000000;
    --text-secondary: #6C6C70;
    --border-color: #E5E5EA;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-color);
    height: 100%;
    overflow: hidden;
}

.app {
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
}

/* 页面切换 */
.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-color);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding-bottom: 80px;
}

.page.active {
    opacity: 1;
    visibility: visible;
}

/* 登录页面 */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(180deg, #FAFAFA 0%, var(--bg-color) 100%);
}

.login-container {
    width: 100%;
    max-width: 360px;
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.logo {
    width: 80px;
    height: 80px;
    background: var(--primary-color);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: var(--shadow);
}

.logo i {
    font-size: 40px;
    color: white;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.login-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

.login-form {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.input-group {
    position: relative;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    background: var(--light-gray);
    border-radius: var(--radius-md);
    padding: 0 16px;
    height: 50px;
    transition: all 0.2s ease;
}

.input-group:focus-within {
    background: #E8E8ED;
    box-shadow: inset 0 0 0 2px var(--primary-color);
}

.input-group i {
    color: var(--gray-color);
    font-size: 18px;
    margin-right: 12px;
}

.input-group input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    outline: none;
    color: var(--text-primary);
    height: 100%;
}

.input-group input::placeholder {
    color: var(--gray-color);
}

.toggle-password {
    cursor: pointer;
    padding: 8px;
    margin-right: -8px !important;
}

.login-btn {
    width: 100%;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.login-btn:hover {
    background: #0056D3;
    transform: translateY(-1px);
}

.login-btn:active {
    transform: scale(0.98);
}

.login-btn:disabled {
    background: var(--gray-color);
    cursor: not-allowed;
    transform: none;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
}

.login-footer p {
    font-size: 12px;
    color: var(--gray-color);
    margin-bottom: 4px;
}

.login-footer .version {
    opacity: 0.6;
}

/* 页面头部 */
.page-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h2 {
    font-size: 18px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.back-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease;
}

.back-btn:hover {
    background: var(--light-gray);
}

.back-btn i {
    font-size: 18px;
    color: var(--primary-color);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--light-gray);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: #E8E8ED;
}

.icon-btn i {
    font-size: 16px;
    color: var(--text-secondary);
}

/* 课程列表 */
.courses-list {
    padding: 12px 16px;
}

.course-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

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

.course-card:active {
    transform: scale(0.98);
}

.course-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), #5AC8FA);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.course-icon i {
    font-size: 24px;
    color: white;
}

.course-info {
    flex: 1;
    min-width: 0;
}

.course-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.course-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.course-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.course-arrow {
    color: var(--gray-color);
    font-size: 14px;
}

/* 课程详情 */
.detail-content {
    padding: 16px;
}

.course-info-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.course-info-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.course-info-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary-color), #5AC8FA);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.course-info-icon i {
    font-size: 28px;
    color: white;
}

.course-info-title {
    flex: 1;
}

.course-info-title h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
}

.course-info-title p {
    font-size: 13px;
    color: var(--text-secondary);
}

.course-info-stats {
    display: flex;
    gap: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.stat-item i {
    color: var(--primary-color);
}

/* 标签页 */
.tabs {
    display: flex;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.tab {
    flex: 1;
    text-align: center;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.tab.active {
    background: var(--primary-color);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 章节列表 */
.chapters-list {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.chapter-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s ease;
}

.chapter-item:last-child {
    border-bottom: none;
}

.chapter-item:hover {
    background: var(--light-gray);
}

.chapter-status {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chapter-status.completed {
    background: var(--success-color);
}

.chapter-status.pending {
    background: var(--light-gray);
    border: 2px solid var(--border-color);
}

.chapter-status.locked {
    background: var(--light-gray);
}

.chapter-status i {
    font-size: 12px;
    color: white;
}

.chapter-status.pending i,
.chapter-status.locked i {
    color: var(--gray-color);
}

.chapter-info {
    flex: 1;
    min-width: 0;
}

.chapter-title {
    font-size: 14px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chapter-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.chapter-jobs {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--gray-color);
}

/* 日志容器 */
.logs-container {
    background: #1C1C1E;
    border-radius: var(--radius-lg);
    padding: 12px;
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 12px;
    line-height: 1.6;
}

.log-item {
    padding: 4px 0;
    border-bottom: 1px solid #2C2C2E;
    color: #E5E5EA;
}

.log-item:last-child {
    border-bottom: none;
}

.log-time {
    color: #8E8E93;
    margin-right: 8px;
}

.log-level-info {
    color: #5AC8FA;
}

.log-level-success {
    color: #34C759;
}

.log-level-warning {
    color: #FF9500;
}

.log-level-error {
    color: #FF3B30;
}

.log-empty {
    text-align: center;
    color: #8E8E93;
    padding: 40px;
}

/* 任务列表 */
.jobs-list {
    margin-top: 12px;
}

.job-item {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.job-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.job-icon.video {
    background: #FFECF0;
    color: #FF2D55;
}

.job-icon.document {
    background: #E8F5E9;
    color: #34C759;
}

.job-icon.read {
    background: #FFF3E0;
    color: #FF9500;
}

.job-icon.work {
    background: #E3F2FD;
    color: #007AFF;
}

.job-icon.live {
    background: #F3E5F5;
    color: #AF52DE;
}

.job-info {
    flex: 1;
}

.job-name {
    font-size: 14px;
    margin-bottom: 2px;
}

.job-type {
    font-size: 12px;
    color: var(--text-secondary);
}

.job-status {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--light-gray);
    color: var(--text-secondary);
}

.job-status.running {
    background: #E3F2FD;
    color: var(--primary-color);
}

.job-status.completed {
    background: #E8F5E9;
    color: var(--success-color);
}

/* 底部操作栏 */
.action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    z-index: 100;
}

.action-btn {
    flex: 1;
    height: 48px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

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

.action-btn.primary:hover {
    background: #0056D3;
}

.action-btn.danger {
    background: var(--danger-color);
    color: white;
}

.action-btn.danger:hover {
    background: #D32F2F;
}

.action-btn:disabled {
    background: var(--gray-color) !important;
    cursor: not-allowed;
}

/* 加载遮罩 */
.loading-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-mask.active {
    display: flex;
}

.loading-spinner {
    background: white;
    padding: 24px 32px;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.loading-spinner i {
    font-size: 32px;
    color: var(--primary-color);
}

.loading-spinner span {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Toast提示 */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1001;
    text-align: center;
    max-width: 80%;
}

.toast.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--border-color);
}

.empty-state p {
    font-size: 14px;
}

/* 进度条 */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--light-gray);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* 响应式适配 */
@media (max-width: 380px) {
    .login-header h1 {
        font-size: 22px;
    }
    
    .course-title {
        font-size: 15px;
    }
    
    .chapter-title {
        font-size: 13px;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6C6C70;
}

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

.course-card,
.chapter-item,
.job-item {
    animation: fadeIn 0.3s ease;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.running {
    animation: pulse 1.5s ease-in-out infinite;
}
