/* 
 * 电动工具知识库 - 全局样式文件
 * 性能优化版 v3.0 - 移动端适配增强
 */

/* ===== 性能优化基础 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    will-change: transform;
    /* 状态栏安全区由全局 /assets/css/mobile.css 统一处理，避免重复顶 padding */
}

/* ===== 容器布局 ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== Header优化 ===== */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px 30px;
    margin-bottom: 20px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    text-align: center;
    will-change: box-shadow;
    transition: all 0.3s ease-out;
}

header:hover {
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
}

header h1 {
    color: #333;
    font-size: clamp(24px, 4vw, 32px);
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

header p {
    color: #666;
    font-size: clamp(14px, 2vw, 16px);
    margin-top: 5px;
}

/* ===== 导航优化 ===== */
.nav-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    justify-content: center;
}

.nav-tabs button {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
}

.nav-tabs button:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.nav-tabs button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* ===== 内容区域 ===== */
.content-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    display: none;
    animation: fadeIn 0.3s ease-out;
}

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

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

/* ===== 卡片设计 ===== */
.card {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.15);
    transform: translateX(3px);
}

.card h3 {
    color: #333;
    margin-bottom: 12px;
    font-size: 18px;
}

.card p {
    color: #666;
    line-height: 1.8;
}

/* ===== 标准列表 ===== */
.standard-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.standard-item {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e8e8e8;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.standard-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.standard-item:hover {
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.18);
    transform: translateY(-3px);
}

.standard-item:hover::before {
    transform: scaleY(1);
}

.standard-item.clickable {
    cursor: pointer;
}

.standard-item.clickable::after {
    content: '→';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: #667eea;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.standard-item.clickable:hover::after {
    opacity: 1;
}

.standard-item .code {
    font-weight: 700;
    color: #667eea;
    font-size: 15px;
    margin-bottom: 8px;
}

.standard-item .title {
    color: #333;
    margin-top: 8px;
    font-size: 14px;
}

.standard-item .category {
    display: inline-block;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1976d2;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    margin-top: 10px;
}

/* ===== 题库样式 ===== */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
}

.quiz-section {
    margin-bottom: 30px;
}

.quiz-section h2 {
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid #667eea;
    font-size: 20px;
}

.question-item {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    border: 1px solid #e8e8e8;
}

.question-item .question {
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
    font-size: 16px;
    line-height: 1.6;
}

.question-item .options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-btn {
    padding: 14px 18px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 15px;
    font-family: inherit;
}

.option-btn:hover {
    border-color: #667eea;
    background: #f5f7ff;
    transform: translateX(5px);
}

.option-btn.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #e8f4fd 0%, #e3f2fd 100%);
    color: #1976d2;
}

.option-btn.correct {
    border-color: #10b981;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #059669;
}

.option-btn.incorrect {
    border-color: #ef4444;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
}

/* ===== 按钮样式 ===== */
.btn {
    padding: 14px 36px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.btn-primary:active {
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
}

.btn-secondary:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
}

.btn-group {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 24px;
}

/* ===== 结果面板 ===== */
.result-panel {
    background: linear-gradient(145deg, #ffffff, #f8fafc);
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.result-panel h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 24px;
}

.result-panel .score {
    font-size: 56px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.result-panel .feedback {
    color: #666;
    font-size: 16px;
}

/* ===== 解析面板 ===== */
.explanation {
    background: linear-gradient(145deg, #fffbeb 0%, #fef3c7 100%);
    border-left: 4px solid #f59e0b;
    border-radius: 0 10px 10px 0;
    padding: 20px;
    margin-top: 16px;
    display: none;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.explanation.show {
    display: block;
}

.explanation h4 {
    color: #d97706;
    margin-bottom: 10px;
    font-size: 16px;
}

.explanation p {
    color: #78350f;
    font-size: 14px;
    line-height: 1.8;
}

/* ===== 知识库项目 ===== */
.knowledge-section {
    margin-bottom: 24px;
}

.knowledge-section h3 {
    color: #333;
    margin-bottom: 16px;
    font-size: 20px;
}

.knowledge-item {
    background: #fff;
    border-radius: 12px;
    padding: 22px;
    margin-bottom: 14px;
    border: 1px solid #e8e8e8;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: box-shadow, transform;
}

.knowledge-item.clickable {
    cursor: pointer;
}

.knowledge-item.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
    border-color: #667eea;
}

.knowledge-item.clickable::after {
    content: '→';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #667eea;
    font-size: 22px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.knowledge-item.clickable:hover::after {
    opacity: 1;
}

.knowledge-item .title {
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    font-size: 16px;
}

.knowledge-item .content {
    color: #666;
    font-size: 14px;
    line-height: 1.7;
}

/* ===== 表格样式 ===== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

table th, table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

table th {
    background: linear-gradient(135deg, #f5f7ff 0%, #e8eaf6 100%);
    color: #333;
    font-weight: 600;
}

table tr:hover {
    background: #fafafa;
}

table tr:last-child td {
    border-bottom: none;
}

/* ===== 进度条 ===== */
.progress-bar {
    height: 10px;
    background: #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 24px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 5px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 统计卡片 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 14px;
    padding: 24px;
    color: white;
    text-align: center;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.5);
}

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

.stat-card .label {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 8px;
}

/* ===== 页脚 ===== */
footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 40px;
    padding: 24px;
    font-size: 14px;
}

/* ===== 模态框优化 ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    overflow-y: auto;
    animation: fadeInModal 0.2s ease-out;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: #fff;
    margin: 3% auto;
    padding: 32px;
    border-radius: 20px;
    width: 90%;
    max-width: 1000px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 3px solid #667eea;
}

.modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #333;
}

.modal-close {
    font-size: 32px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: color 0.3s ease;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 10px;
}

.modal-body h1,
.modal-body h2,
.modal-body h3,
.modal-body h4 {
    color: #333;
    margin-top: 24px;
    margin-bottom: 12px;
}

.modal-body h1 {
    font-size: 28px;
}

.modal-body h2 {
    font-size: 22px;
}

.modal-body h3 {
    font-size: 19px;
}

.modal-body h4 {
    font-size: 17px;
}

.modal-body p,
.modal-body li {
    color: #555;
    line-height: 1.8;
    font-size: 15px;
}

.modal-body ul,
.modal-body ol {
    margin-left: 24px;
    margin-bottom: 18px;
}

.modal-body li {
    margin-bottom: 10px;
}

.modal-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.modal-body table th,
.modal-body table td {
    padding: 14px;
    text-align: left;
    border: 1px solid #e0e0e0;
}

.modal-body table th {
    background: #f5f7ff;
    color: #333;
    font-weight: 600;
}

.modal-body table tr:hover {
    background: #fafafa;
}

.modal-body code {
    background: #f5f5f5;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 14px;
}

.modal-body pre {
    background: #1e1e1e;
    padding: 20px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 20px 0;
}

.modal-body pre code {
    background: none;
    padding: 0;
    color: #d4d4d4;
}

.modal-body blockquote {
    border-left: 4px solid #667eea;
    padding-left: 20px;
    margin: 20px 0;
    color: #666;
    font-style: italic;
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 0 10px 10px 0;
}

.modal-body hr {
    border: none;
    border-top: 1px dashed #e0e0e0;
    margin: 24px 0;
}

/* ===== 相关标准 ===== */
.related-standards {
    margin-top: 24px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 12px;
}

.related-standards h4 {
    margin-top: 0;
    color: #333;
}

.standard-link {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    margin: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

.standard-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* ===== 搜索框优化 ===== */
.search-container {
    position: relative;
    max-width: 600px;
    margin: 20px auto 0;
}

.search-container input {
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 35px;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    background: #fff;
}

.search-container input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-height: 450px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
    margin-top: 12px;
    animation: dropdownIn 0.2s ease-out;
}

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

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 16px 20px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s ease;
}

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

.search-result-item:hover {
    background: #f8fafc;
}

.search-result-item .result-type {
    font-size: 11px;
    color: #667eea;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.search-result-item .result-title {
    color: #333;
    font-weight: 600;
    margin-bottom: 6px;
}

.search-result-item .result-desc {
    font-size: 14px;
    color: #888;
}

.search-no-results {
    padding: 24px;
    text-align: center;
    color: #999;
}

.search-highlight {
    background: rgba(102, 126, 234, 0.25);
    padding: 2px 6px;
    border-radius: 4px;
    color: #667eea;
    font-weight: 600;
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .nav-tabs {
        flex-direction: column;
        gap: 8px;
    }
    
    .nav-tabs button {
        width: 100%;
        padding: 14px 20px;
        font-size: 15px;
    }
    
    header {
        padding: 16px 20px;
    }
    
    header h1 {
        font-size: 22px;
    }
    
    .container {
        padding: 12px;
    }
    
    .content-section {
        padding: 16px;
    }
    
    .question-item {
        padding: 18px;
    }
    
    .result-panel .score {
        font-size: 40px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 18px;
    }
    
    .stat-card .value {
        font-size: 28px;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px;
        margin: 5% auto;
        border-radius: 16px;
    }
    
    .modal-body {
        max-height: 55vh;
    }
    
    .standard-list {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .btn-group {
        flex-direction: column;
        gap: 12px;
    }
    
    .btn {
        width: 100%;
        padding: 14px 24px;
    }
    
    .search-container {
        padding: 0 10px;
    }
    
    .search-container input {
        padding: 14px 20px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    header {
        padding: 12px 16px;
    }
    
    header h1 {
        font-size: 18px;
    }
    
    header p {
        font-size: 13px;
    }
    
    .content-section {
        padding: 12px;
    }
    
    .card {
        padding: 14px;
    }
    
    .question-item {
        padding: 14px;
    }
    
    .question-item .question {
        font-size: 14px;
    }
    
    .option-btn {
        padding: 12px 14px;
        font-size: 14px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        padding: 16px;
    }
    
    .modal-title {
        font-size: 20px;
    }
}

/* ===== 暗色模式支持（可选）===== */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    }
    
    header {
        background: rgba(30, 27, 75, 0.9);
    }
    
    header h1 {
        color: #e2e8f0;
    }
    
    header p {
        color: #94a3b8;
    }
    
    .nav-tabs button {
        background: rgba(51, 47, 123, 0.8);
        color: #e2e8f0;
    }
    
    .nav-tabs button:hover {
        background: rgba(63, 59, 139, 0.9);
    }
    
    .content-section {
        background: rgba(30, 27, 75, 0.95);
    }
    
    .card {
        background: rgba(47, 43, 119, 0.8);
        border-left-color: #818cf8;
    }
    
    .card h3 {
        color: #e2e8f0;
    }
    
    .card p {
        color: #94a3b8;
    }
}

/* ===== 打印样式 ===== */
@media print {
    body {
        background: white;
        font-size: 12px;
    }
    
    header,
    .nav-tabs,
    .btn-group,
    .search-container,
    footer {
        display: none;
    }
    
    .content-section {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
    
    .modal-content {
        position: static;
        width: 100%;
        box-shadow: none;
    }
}