/* ========== AI辅导系统 - Pad端优化样式 ========== */

/* 基础设置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #4A90D9;
    --primary-dark: #357ABD;
    --primary-light: #E8F0FE;
    --secondary: #6C757D;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    --bg: #F5F7FA;
    --card-bg: #FFFFFF;
    --text: #2C3E50;
    --text-light: #6C757D;
    --border: #E1E8ED;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-lg: 16px;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    /* Pad横屏优化 */
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: 80px;
}

/* 顶部导航 */
.app-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(74,144,217,0.3);
}

.app-header h1 {
    font-size: 1.3rem;
    font-weight: 600;
}

.student-selector select {
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
}

.student-selector select option {
    color: var(--text);
}

/* 步骤指示器 */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: white;
    margin: 12px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    opacity: 0.4;
    transition: all 0.3s;
}

.step.active {
    opacity: 1;
}

.step.completed {
    opacity: 1;
}

.step.completed .step-num {
    background: var(--success);
}

.step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.step-label {
    font-size: 0.75rem;
    color: var(--text-light);
}

.step.active .step-label {
    color: var(--primary);
    font-weight: 600;
}

.step-arrow {
    color: var(--border);
    font-size: 1.2rem;
    margin: 0 8px;
}

/* 主内容区 */
.main-container {
    max-width: 1024px;
    margin: 0 auto;
    padding: 0 12px;
}

/* Section管理 */
.section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.section.active {
    display: block;
}

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

/* 拍照区域 */
.capture-area {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    margin: 12px 0;
    box-shadow: var(--shadow);
}

.camera-preview {
    width: 100%;
    aspect-ratio: 4/3;
    background: #f0f0f0;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-preview video,
.camera-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-preview .placeholder {
    text-align: center;
    color: var(--text-light);
}

.placeholder .icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 12px;
}

.placeholder p {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.placeholder .hint {
    font-size: 0.85rem;
    color: #999;
}

.capture-controls {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 按钮样式 */
.btn {
    padding: 12px 24px;
    border-radius: 25px;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(74,144,217,0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(74,144,217,0.4);
}

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

.btn-secondary {
    background: #f0f0f0;
    color: var(--text);
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-large {
    padding: 14px 36px;
    font-size: 1.1rem;
    border-radius: 28px;
}

/* 学科选择 */
.subject-selector {
    margin: 16px 0;
}

.subject-selector h3 {
    font-size: 1.05rem;
    margin-bottom: 12px;
    color: var(--text);
}

.subject-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.subject-card {
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

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

.subject-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.subject-card .icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 6px;
}

.subject-card .name {
    font-size: 0.85rem;
    font-weight: 500;
}

/* 操作栏 */
.action-bar {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 20px 0;
}

/* 加载动画 */
.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: 1000;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    margin-top: 20px;
    font-size: 1.1rem;
    color: var(--text);
}

.loading-overlay .hint {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 8px;
}

/* 结果卡片 */
.result-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin: 12px 0;
    box-shadow: var(--shadow);
}

.result-card h3 {
    font-size: 1.15rem;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-light);
}

.field {
    margin-bottom: 14px;
}

.field label {
    font-size: 0.85rem;
    color: var(--text-light);
    display: block;
    margin-bottom: 4px;
}

.field .value {
    font-size: 1rem;
    color: var(--text);
    line-height: 1.6;
}

.field-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.math-text {
    font-family: "Courier New", monospace;
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    white-space: pre-wrap;
    word-break: break-all;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-block;
    padding: 4px 12px;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 12px;
    font-size: 0.85rem;
}

.difficulty-stars {
    color: var(--warning);
}

.edit-area {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.edit-area label {
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 8px;
    display: block;
}

.edit-area textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    resize: vertical;
    font-family: inherit;
    outline: none;
}

.edit-area textarea:focus {
    border-color: var(--primary);
}

/* 诊断结果样式 */
.diagnosis-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin: 12px 0;
    box-shadow: var(--shadow);
}

.diagnosis-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--primary-light);
}

.diagnosis-mode-badge {
    display: inline-block;
    padding: 6px 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 500;
}

.gap-alert {
    background: #FFF3E0;
    border-left: 4px solid #FF9800;
    padding: 16px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin: 16px 0;
}

.gap-alert h4 {
    color: #E65100;
    margin-bottom: 8px;
    font-size: 1.05rem;
}

.knowledge-chain {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 16px 0;
    padding-left: 20px;
}

.chain-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    position: relative;
    border-left: 3px solid var(--border);
    padding-left: 20px;
}

.chain-item::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 18px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border);
}

.chain-item.current {
    border-left-color: var(--danger);
}

.chain-item.current::before {
    background: var(--danger);
}

.chain-item.gap {
    border-left-color: var(--warning);
    background: #FFF8E1;
    border-radius: 0 8px 8px 0;
}

.chain-item.gap::before {
    background: var(--warning);
    width: 16px;
    height: 16px;
    left: -9px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,152,0,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(255,152,0,0); }
}

.chain-level {
    font-size: 0.75rem;
    color: white;
    background: var(--secondary);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.chain-item.current .chain-level {
    background: var(--danger);
}

.chain-item.gap .chain-level {
    background: var(--warning);
    color: var(--text);
}

.chain-content h4 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.chain-content p {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* 诊断题卡片 */
.diagnostic-questions {
    margin: 20px 0;
}

.question-card {
    background: #f8f9fa;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--primary);
}

.question-card .level-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.level-1 { background: #E8F5E9; color: #2E7D32; }
.level-2 { background: #FFF3E0; color: #EF6C00; }
.level-3 { background: #FCE4EC; color: #C62828; }

.question-text {
    font-size: 1rem;
    margin-bottom: 12px;
    line-height: 1.6;
}

.answer-reveal {
    color: var(--primary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

.answer-content {
    display: none;
    margin-top: 8px;
    padding: 12px;
    background: white;
    border-radius: 8px;
}

.answer-content.show {
    display: block;
}

/* 补砖方案 */
.remediation-box {
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    border-radius: var(--radius);
    padding: 20px;
    margin: 16px 0;
}

.remediation-box h4 {
    color: #2E7D32;
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.remediation-box .method {
    background: white;
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.remediation-box .method h5 {
    font-size: 0.95rem;
    margin-bottom: 8px;
    color: var(--text);
}

.remediation-box .method p {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.6;
}

/* 学生指导 */
.student-guidance {
    background: var(--primary-light);
    border-radius: var(--radius);
    padding: 20px;
    margin: 16px 0;
}

.student-guidance h4 {
    color: var(--primary);
    margin-bottom: 12px;
}

.student-guidance p {
    font-size: 1rem;
    line-height: 1.8;
}

/* 底部导航 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 20px;
    border: none;
    background: none;
    color: var(--text-light);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-item .icon {
    font-size: 1.5rem;
}

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

/* 知识图谱页面 */
.filter-bar {
    display: flex;
    gap: 12px;
    margin: 12px 0;
}

.filter-bar select {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: white;
    outline: none;
}

.filter-bar select:focus {
    border-color: var(--primary);
}

.knowledge-tree {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    margin: 12px 0;
    box-shadow: var(--shadow);
}

.kg-chapter {
    margin-bottom: 16px;
}

.kg-chapter-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary);
    padding: 10px 0;
    border-bottom: 2px solid var(--primary-light);
    margin-bottom: 10px;
}

.kg-node {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    transition: all 0.2s;
}

.kg-node:hover {
    background: #f8f9fa;
}

.kg-node-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
}

.kg-node-dot.mastered { background: var(--success); }
.kg-node-dot.weak { background: var(--warning); }
.kg-node-dot.unknown { background: var(--border); }

.kg-node-name {
    flex: 1;
    font-size: 0.95rem;
}

.kg-node-tag {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 8px;
    background: #f0f0f0;
    color: var(--text-light);
}

/* 错题本 */
.error-list {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    margin: 12px 0;
    box-shadow: var(--shadow);
}

.error-item {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

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

.error-item:hover {
    background: #f8f9fa;
}

.error-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.error-subject {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 500;
}

.error-subject.math { background: #E3F2FD; color: #1565C0; }
.error-subject.chinese { background: #F3E5F5; color: #6A1B9A; }
.error-subject.english { background: #E8F5E9; color: #2E7D32; }
.error-subject.physics { background: #FFF3E0; color: #EF6C00; }

.error-date {
    font-size: 0.8rem;
    color: var(--text-light);
}

.error-text {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.error-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    margin-top: 8px;
}

.error-status.diagnosed { background: #E3F2FD; color: #1565C0; }
.error-status.remediating { background: #FFF3E0; color: #EF6C00; }
.error-status.resolved { background: #E8F5E9; color: #2E7D32; }

/* 响应式优化 - Pad横屏 */
@media (min-width: 768px) {
    html {
        font-size: 18px;
    }
    
    .main-container {
        padding: 0 24px;
    }
    
    .subject-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
    }
    
    .capture-controls {
        gap: 20px;
    }
    
    .camera-preview {
        aspect-ratio: 16/10;
    }
}

@media (min-width: 1024px) {
    html {
        font-size: 20px;
    }
    
    .subject-grid {
        grid-template-columns: repeat(8, 1fr);
    }
    
    .step-indicator {
        max-width: 600px;
        margin: 16px auto;
    }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 600px) {
    .camera-preview {
        aspect-ratio: 16/9;
        max-height: 50vh;
    }
    
    .app-header {
        padding: 8px 20px;
    }
    
    .app-header h1 {
        font-size: 1.1rem;
    }
}

/* 隐藏滚动条但保持功能 */
::-webkit-scrollbar {
    width: 6px;
}

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

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

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