/* ==================== CSS Variables ==================== */
:root {
    --primary: #81c16a;
    --accent: #b7950b;
    --bg: #fdfdfd;
}

/* ==================== Base Styles ==================== */
body {
    margin: 0;
    font-family: "Source Han Serif SC", "Noto Serif SC", serif;
    background: var(--bg);
}

/* ==================== Navigation ==================== */
.navbar {
    background: var(--primary);
    color: white;
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-container {
    width: 100%;
    max-width: none;
    margin: 0;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0 30px;
    box-sizing: border-box;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 1px;
    color: white;
    margin-right: 40px;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 10px;
}

.nav-links button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 8px 20px;
    cursor: pointer;
    border-radius: 4px;
    transition: 0.3s;
    margin-left: 0;
}

.nav-links button.active {
    background: var(--accent);
    border-color: var(--accent);
}

/* ==================== PDF Viewer ==================== */
.pdf-container {
    height: calc(100vh - 70px);
    background: #525659;
}

#pdf-viewer {
    width: 100%;
    background-color: #525659;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
}

.page-container {
    margin-bottom: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    background-color: white;
    position: relative;
    min-height: 500px;
}

@media (max-width: 768px) {
    .page-container {
        width: 100% !important;
        margin-bottom: 5px;
    }

    .pdf-container {
        height: calc(100vh - 60px);
    }
}

@media (min-width: 769px) {
    .page-container {
        width: 80%;
        max-width: 900px;
    }
}

canvas {
    display: block;
    width: 100%;
    height: auto;
}

/* ==================== Loading Indicator ==================== */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100vh - 70px);
    background-color: #525659;
    color: white;
    font-size: 18px;
}

.loading-indicator p {
    margin-top: 20px;
}

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

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

.img-loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.img-loading-indicator .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--primary);
}

/* ==================== Test Layout (Desktop) ==================== */
.test-layout {
    display: flex;
    height: calc(100vh - 70px);
}

.sidebar {
    width: 220px;
    border-right: 1px solid #eee;
    background: #fff;
    overflow-y: auto;
    padding: 15px;
}

.side-title {
    margin-top: 0;
    font-size: 16px;
    color: #333;
}

.thumb-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.thumb-list img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.7;
    transition: 0.3s;
}

.thumb-list img:hover {
    opacity: 1;
}

.thumb-list img.active {
    opacity: 1;
    border-color: var(--accent);
}

.thumb-item-wrapper {
    margin-bottom: 15px;
    text-align: center;
}

.thumb-item-wrapper img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.thumb-item-wrapper.active img {
    border-color: #b7950b;
    background: #fffdf0;
}

.thumb-name {
    font-size: 11px;
    color: #777;
    margin-top: 3px;
    display: block;
}

.main-display {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    position: relative;
}

.center-stage {
    display: flex;
    justify-content: center;
    padding: 30px 0;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.main-img-container {
    text-align: center;
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
}

.main-img-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

#active-img {
    max-height: 350px;
    max-width: 100%;
    display: block;
    cursor: default;
    border-radius: 4px;
}

.img-name-label {
    margin-top: 10px;
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

/* ==================== Cards Grid ==================== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

@media (min-width: 769px) {
    .cards-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.res-card {
    background: #fff;
    padding: 0;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    height: 400px;
    cursor: pointer;
    transition: 0.2s;
}

.res-card:hover {
    border-color: #8ba9e8;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(107, 140, 206, 0.2);
}

.res-card.special {
    border: 2px solid #b7950b;
    background: linear-gradient(to bottom, #fffcf5, #fff);
    box-shadow: 0 2px 12px rgba(183, 149, 11, 0.15);
}

.card-header {
    padding: 14px 18px;
    background: linear-gradient(to right, #eef1f5, #e9ecf2);
    border-bottom: 1px solid #dde0e5;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.card-header .soft-name {
    font-weight: bold;
    font-size: 14px;
}

.card-header .click-hint {
    font-size: 12px;
    color: #b7950b;
    white-space: nowrap;
    margin-right: auto;
}

.card-header .click-hint::after {
    content: ' 🔍';
}

.card-header .char-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: linear-gradient(135deg, #6b8cce, #8ba9e8);
    color: white;
    border-radius: 18px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(107, 140, 206, 0.35);
    cursor: help;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-header .char-count-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(107, 140, 206, 0.45);
}

.card-header .char-count-badge::before {
    content: '📝';
    font-size: 11px;
}

/* Tooltip 提示 */
.card-header .char-count-badge::after {
    content: '只统计中文字符';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    background: #333;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
    z-index: 100;
}

.card-header .char-count-badge:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-8px);
}

.card-body {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    background: #fafafa;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: "Noto Serif SC", "SimSun", serif;
    line-height: 1.8;
    font-size: 1.05rem;
    color: #333;
}

.card-footer {
    padding: 12px 15px;
    background: linear-gradient(to right, #fffcf5, #fff8e8);
    border-top: 1px solid #f0e6d0;
    height: 80px;
    overflow-y: auto;
    font-size: 12px;
    color: #666;
    border-radius: 0 0 12px 12px;
}

/* ==================== Modal ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
}

.modal-content {
    position: relative;
    width: 95vw;
    height: 90vh;
    margin: 2vh auto;
    background: #fff;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.summary-box {
    width: 90vw;
    height: 80vh;
    min-height: 60vh;
    margin-left: auto;
    margin-right: auto;
}

/* Summary PDF viewer styles */
#summary-pdf-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #525659;
    overflow-y: auto;
    padding: 20px;
}

#summary-pdf-viewer {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #525659;
}

#summary-pdf-viewer .page-container {
    margin-bottom: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    background-color: white;
    position: relative;
    min-height: 300px;
    display: flex;
    justify-content: center;
}

.modal-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #5e80dc 0%, #7b95ec 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

#modal-title {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.modal-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.summary-box .modal-body {
    flex: 1;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
}

/* 限制summary中markdown渲染的图片大小 */
#summary-content img {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    display: block;
    margin: 15px 0;
}

.modal-left {
    flex: 2;
    background: #222;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
}

.modal-left:active {
    cursor: grabbing;
}

.modal-right {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    border-left: 1px solid #eee;
    background: #fff;
}

#modal-img {
    transition: transform 0.05s ease-out;
    transform-origin: center;
    max-width: 90%;
}

.zoom-tip {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
    pointer-events: none;
}

.modal-result-box pre {
    white-space: pre-wrap;
    background: #f8f9fa;
    padding: 18px 20px;
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1.8;
    border: 1px solid #e9ecef;
    color: #333;
    margin: 0;
}

.modal-review-box {
    margin-top: 20px;
    padding: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cd 100%);
    border: 1px solid #ffeeba;
    overflow: hidden;
}

.review-label {
    padding: 12px 20px;
    background: rgba(180, 140, 0, 0.1);
    color: #856404;
    font-size: 0.9rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(180, 140, 0, 0.2);
    letter-spacing: 0.5px;
}

.modal-review-box p {
    padding: 16px 20px;
    margin: 0;
    color: #555;
    line-height: 1.7;
}

.close-btn {
    position: absolute;
    right: 15px;
    top: 8px;
    font-size: 32px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    z-index: 2010;
    line-height: 1;
    user-select: none;
    transition: color 0.2s, transform 0.2s;
}

.close-btn:hover {
    color: #ff4d4d;
    transform: scale(1.1);
}

/* ==================== Mobile Responsive ==================== */
.mobile-test-ui {
    display: none;
}

.mobile-select-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 自定义下拉框基础样式 */
.custom-select {
    position: relative;
    background: white;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.custom-select:hover {
    border-color: #b0b0b0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.custom-select.open {
    border-color: #4a9eff;
    box-shadow: 0 4px 16px rgba(74, 158, 255, 0.15);
}

.custom-select:focus-within {
    border-color: #4a9eff;
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

.custom-select .selected {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    background: linear-gradient(135deg, #fafbfc, #fff);
    border-radius: 11px;
    position: relative;
}

.custom-select .selected::after {
    content: '';
    position: absolute;
    right: 16px;
    width: 10px;
    height: 10px;
    border-right: 2px solid #666;
    border-bottom: 2px solid #666;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.custom-select.open .selected::after {
    transform: rotate(-135deg);
}

.custom-select img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.custom-select span {
    flex: 1;
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.select-icon {
    width: 22px;
    height: 22px;
    color: #666;
}

.options {
    display: none;
    position: absolute;
    width: 100%;
    top: calc(100% + 6px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
    max-height: 280px;
    overflow-y: auto;
    z-index: 100;
    padding: 6px;
    border: 1px solid #e8e8e8;
}

.options::-webkit-scrollbar {
    width: 6px;
}

.options::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.options::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.options::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.custom-select.open .options {
    display: block;
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }

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

/* 选中项样式（可以通过JS添加active类） */
.option-item.active {
    background: linear-gradient(135deg, #e6f0ff, #dbeafe);
}

/* 图片选择框中显示图片时的特殊样式 */
#img-select-box img {
    max-width: 52px;
    max-height: 52px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.option-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.option-item:hover {
    background: linear-gradient(135deg, #f0f7ff, #e6f2ff);
}

.option-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}

.option-item span {
    font-size: 13px;
    color: #444;
}

/* 软件选择框选项没有图片，增加一些额外样式 */
#soft-options .option-item {
    padding: 12px 16px;
    justify-content: flex-start;
    position: relative;
}

#soft-options .option-item:hover {
    background: linear-gradient(135deg, #e6f0ff, #dbeafe);
}

#soft-options .option-item span {
    font-weight: 500;
}

/* 给软件选择框选项添加一个左侧指示条 */
#soft-options .option-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 2px;
    transition: height 0.15s ease;
}

#soft-options .option-item:hover::before {
    height: 60%;
}

.mobile-img-box {
    flex: 0 0 40%;
    overflow: hidden;
    text-align: center;
    background: #eee;
}

.mobile-img-box img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    touch-action: none;
}

.mobile-result-box {
    flex: 1;
    overflow-y: auto;
    background: linear-gradient(135deg, #fafbfc, #fff);
    padding: 16px;
    border: 1px solid #e8e8e8;
    white-space: pre-wrap;
    font-size: 15px;
    line-height: 1.7;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    position: relative;
}

/* 移动端字符数显示样式 */
#mobile-wordscount {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
    align-self: flex-start;
    box-shadow: 0 2px 6px rgba(149, 165, 166, 0.3);
}

#mobile-wordscount::before {
    content: '📝';
    font-size: 14px;
}

#mobile-wordscount .count-number {
    font-size: 15px;
    font-weight: 600;
}

#mobile-text {
    padding: 14px;
    margin-bottom: 0;
    color: #2c3e50;
    font-family: "Noto Serif SC", "SimSun", serif;
    line-height: 1.9;
    background: white;
    border-radius: 12px;
    border: 1px solid #e8ecf1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    word-break: break-all;
    margin-top: 8px;
}

#mobile-review {
    margin-top: 8px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #fffbf0, #fff8e7);
    border: 2px solid #f5a623;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(245, 166, 35, 0.15);
    position: relative;
    color: #5a4a1c;
}

/* 移动端结果框滚动条样式 */
.mobile-result-box::-webkit-scrollbar {
    width: 6px;
}

.mobile-result-box::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.mobile-result-box::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #c1c1c1, #a1a1a1);
    border-radius: 3px;
}

.mobile-result-box::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #a1a1a1, #818181);
}

select {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
    font-size: 14px;
}

@media (max-width: 768px) {

    /* Navbar */
    .logo {
        display: none;
    }

    .navbar {
        padding: 8px 0;
    }

    .nav-container {
        justify-content: center;
        padding: 0 10px;
    }

    .nav-links button {
        padding: 10px;
        font-size: 10px;
    }

    /* Hide desktop test layout, show mobile */
    .test-layout {
        display: none;
    }

    .mobile-test-ui {
        display: flex;
        flex-direction: column;
        height: calc(100vh - 60px);
        padding: 15px;
        gap: 15px;
    }

    .mobile-select-group {
        gap: 14px;
    }

    .mobile-img-box {
        background: linear-gradient(135deg, #ffffff, #f8f9fa);
        border-radius: 16px;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
        padding: 16px;
        min-height: 250px;
        border: 1px solid #e8ecf1;
    }

    .mobile-result-box {
        background: linear-gradient(135deg, #fafbfc, #fff);
        border-radius: 16px;
        padding: 16px;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
        min-height: 300px;
        flex-grow: 1;
        margin-bottom: 30px;
        border: 1px solid #e8ecf1;
    }

    /* Summary box移动端样式 */
    .summary-box {
        width: 95vw;
        height: 90vh;
        min-height: auto;
    }

    #summary-pdf-body {
        padding: 10px;
    }

    #summary-pdf-viewer .page-container {
        width: 100% !important;
        margin-bottom: 8px;
        min-height: 200px;
    }
}