/* 软考练题系统 - 左右布局样式 */

:root {
    --primary: #18c3ff;
    --primary-dark: #0f9bd7;
    --accent: #ff7b72;
    --accent-soft: #ffb86c;
    --success: #15d17c;
    --error: #f55f5f;
    --warning: #ffb020;
    --text: #1f2937;
    --text-light: #6b7280;
    --sidebar-width: 280px;
    --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    --main-bg: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.95);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    --radius: 16px;
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background: var(--main-bg);
    min-height: 100vh;
    color: var(--text);
    display: flex;
    overflow-x: hidden;
}

/* ========== Sidebar ========== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: white;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-main {
    flex: 0 1 auto;
    overflow-y: auto;
    min-height: 0;
    max-height: 35vh;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header {
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.sidebar-header p {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.25rem;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chapter-item {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    background: transparent;
    border: none;
    text-align: left;
    width: 100%;
    font-family: var(--font-main);
}

.chapter-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chapter-item.active {
    background: rgba(24, 195, 255, 0.2);
    color: var(--primary);
    font-weight: 600;
}

/* 统计卡片 */
.stats-sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.stat-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.stat-item .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-item .label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.25rem;
}

.stat-item.success .value {
    color: var(--success);
}

.stat-item.error .value {
    color: var(--error);
}

.stat-item.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.stat-item.clickable:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

/* 功能按钮 */
.action-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-main);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
}

.action-btn.danger {
    color: var(--error);
    border-color: rgba(245, 95, 95, 0.3);
}

.action-btn.active {
    background: rgba(24, 195, 255, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

/* ========== Main Content ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 100px;
}

.main-header {
    padding: 1.25rem 2rem;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.main-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: #f3f4f6;
    cursor: pointer;
    font-size: 1.25rem;
    align-items: center;
    justify-content: center;
}

.progress-bar-container {
    height: 3px;
    background: #e5e7eb;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #5ee7ff);
    width: 0%;
    transition: width 0.4s ease;
}

/* 错题模式横幅 */
.wrong-mode-banner {
    background: linear-gradient(90deg, #fee2e2, #fecaca);
    color: #b91c1c;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.wrong-mode-banner button {
    background: #b91c1c;
    color: white;
    border: none;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
}

.wrong-mode-banner button:hover {
    background: #991b1b;
    transform: scale(1.05);
}

.question-container {
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.question-meta {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.question-text {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 1.5rem;
}

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.option-card:hover:not(.disabled) {
    border-color: var(--primary);
    transform: translateX(4px);
}

.option-key {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-light);
    flex-shrink: 0;
}

.option-content {
    flex: 1;
    font-size: 1rem;
    line-height: 1.6;
}

.option-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(24, 195, 255, 0.08), white);
}

.option-card.selected .option-key {
    background: var(--primary);
    color: white;
}

.option-card.correct {
    border-color: var(--success);
    background: linear-gradient(135deg, rgba(21, 209, 124, 0.08), white);
}

.option-card.correct .option-key {
    background: var(--success);
    color: white;
}

.option-card.wrong {
    border-color: var(--error);
    background: linear-gradient(135deg, rgba(245, 95, 95, 0.08), white);
}

.option-card.wrong .option-key {
    background: var(--error);
    color: white;
}

.option-card.disabled {
    cursor: default;
    opacity: 0.7;
}

.explanation-card {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border-left: 4px solid var(--accent-soft);
    border-radius: 12px;
    display: none;
}

.explanation-card.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

.explanation-title {
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ========== 悬浮底栏 ========== */
.floating-footer {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    margin-left: calc(var(--sidebar-width) / 2);
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: white;
    border-radius: 50px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 90;
}

.nav-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-main);
}

.nav-btn.prev {
    background: #f3f4f6;
    color: var(--text);
}

.nav-btn.exit-wrong {
    background: linear-gradient(135deg, #f87171, #ef4444);
    color: white;
}

.nav-btn.prev:hover:not(:disabled) {
    background: #e5e7eb;
}

.nav-btn.next {
    background: linear-gradient(135deg, var(--primary), #5ee7ff);
    color: #0b2538;
}

.nav-btn.next:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(24, 195, 255, 0.4);
}

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

/* ========== Modal ========== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

/* 题目列表弹窗 */
.question-list-modal {
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
    margin: 0;
}

.close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f3f4f6;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #e5e7eb;
}

.question-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 8px;
    overflow-y: auto;
    max-height: 50vh;
    padding: 0.5rem;
}

.question-cell {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    border: 2px solid #e5e7eb;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.question-cell:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.question-cell.current {
    border-color: var(--primary);
    background: rgba(24, 195, 255, 0.1);
    color: var(--primary);
}

.question-cell.correct {
    border-color: var(--success);
    background: rgba(21, 209, 124, 0.1);
    color: var(--success);
}

.question-cell.wrong {
    border-color: var(--error);
    background: rgba(245, 95, 95, 0.1);
    color: var(--error);
}

.modal-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
    font-size: 0.85rem;
    color: var(--text-light);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-item .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
}

.legend-item .dot.correct {
    border-color: var(--success);
    background: rgba(21, 209, 124, 0.3);
}

.legend-item .dot.wrong {
    border-color: var(--error);
    background: rgba(245, 95, 95, 0.3);
}

.modal h3 {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.modal p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.modal input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    font-size: 1rem;
    font-family: var(--font-main);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
}

.mini-btn {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: white;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-main);
}

.mini-btn:hover {
    background: #f9fafb;
}

.mini-btn.primary {
    background: linear-gradient(135deg, var(--primary), #5ee7ff);
    color: #0b2538;
    border-color: transparent;
}

.mini-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(24, 195, 255, 0.3);
}

/* 拖拽上传区域 */
.upload-modal {
    max-width: 480px;
}

.drop-zone {
    border: 2px dashed #d1d5db;
    border-radius: 16px;
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9fafb;
    position: relative;
    margin-bottom: 1rem;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(24, 195, 255, 0.05);
}

.drop-zone.dragover {
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(24, 195, 255, 0.2);
}

.drop-zone-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.drop-zone-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.drop-zone-hint {
    font-size: 0.85rem;
    color: var(--text-light);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.selected-file {
    padding: 0.75rem 1rem;
    background: rgba(24, 195, 255, 0.1);
    border-radius: 10px;
    font-size: 0.9rem;
    color: var(--primary-dark);
    display: none;
    margin-bottom: 0.5rem;
}

.selected-file.show {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#uploadStatus {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    min-height: 1.5rem;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
}

.toast {
    padding: 12px 24px;
    background: white;
    border-radius: 50px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

.toast.success {
    color: var(--success);
}

.toast.error {
    color: var(--error);
}

/* History Panel */
.history-panel {
    display: none;
    padding: 1rem;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.history-item {
    padding: 0.85rem 1rem;
    background: white;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    margin-bottom: 0.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
}

.history-item:hover {
    border-color: var(--primary);
}

.rich-block img,
.question-image {
    max-width: 100%;
    border-radius: 10px;
    margin: 0.5rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.question-images,
.explanation-images {
    margin-top: 1rem;
}

.option-content .question-image {
    margin-top: 0.5rem;
    max-width: 200px;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: none;
}

.sidebar-overlay.show {
    display: block;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* ========== 移动端响应式 ========== */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .floating-footer {
        margin-left: 0;
        bottom: 16px;
    }

    .question-container {
        padding: 1.5rem;
    }

    .question-text {
        font-size: 1.1rem;
    }
}