/* 引典 - 古籍引文匹配系統樣式表 */
/* 東方雅韻設計系統 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 東方雅韻色彩系統 */
    --paper-white: #F7F4ED;
    --paper-cream: #FAF8F3;
    --paper-old: #EDE8DD;
    --ink-black: #1A1A1A;
    --ink-light: #4A4A4A;
    --ink-muted: #8A8A8A;
    --cinnabar: #C73E1D;
    --cinnabar-light: #E85D3C;
    --cinnabar-pale: #FDF2EF;
    --bamboo: #7CB9A8;
    --bamboo-pale: #E8F5F1;
    --indigo: #4A6741;
    --gold: #C9A961;
    --border-default: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
    background-color: var(--paper-white);
    color: var(--ink-black);
    min-height: 100vh;
    overflow-x: hidden;
}

/* 宣紙紋理背景 */
.app-container {
    display: flex;
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at top left, rgba(199, 62, 29, 0.02) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(124, 185, 168, 0.03) 0%, transparent 50%);
}

/* ========== 左側導航欄 ========== */
.sidebar {
    width: 80px;
    background: linear-gradient(180deg, #1A1A1A 0%, #242220 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 0;
    flex-shrink: 0;
}

.logo {
    width: 44px;
    height: 44px;
    background: var(--cinnabar);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    font-family: 'KaiTi', 'STKaiti', serif;
}

.brand {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    margin-bottom: 32px;
    letter-spacing: 0.1em;
}

.nav-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    align-items: center;
    flex: 1;
}

.nav-item {
    width: 64px;
    height: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    background: transparent;
}

.nav-item .nav-icon {
    width: 22px;
    height: 22px;
    color: #8A8A8A;
    transition: color 0.2s ease;
}

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

.nav-item:hover .nav-icon {
    color: rgba(255, 255, 255, 0.7);
}

.nav-item .label {
    font-size: 10px;
    color: #8A8A8A;
    font-weight: 500;
    transition: color 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
}

.nav-item.active .label {
    color: var(--cinnabar);
    font-weight: 600;
}

.nav-item:hover .label {
    color: rgba(255, 255, 255, 0.7);
}

.nav-item.help {
    margin-top: auto;
}

/* ========== 主內容區 ========== */
.main-content {
    flex: 1;
    padding: 36px 48px 24px;
    display: flex;
    flex-direction: column;
    max-width: calc(100% - 80px);
    overflow-y: auto;
}

/* 標題區 */
.header {
    text-align: center;
    margin-bottom: 48px;
}

.header h1 {
    font-size: 36px;
    font-weight: 600;
    color: var(--ink-black);
    margin-bottom: 8px;
    letter-spacing: 0.05em;
    font-family: 'KaiTi', 'STKaiti', 'Noto Serif SC', serif;
}

.header .subtitle {
    font-size: 14px;
    color: var(--ink-muted);
    letter-spacing: 0.1em;
}

/* 視圖切換 */
.view {
    display: none;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.view.active {
    display: flex;
}

/* ========== 上傳卡片 ========== */
.cards-container {
    display: flex;
    gap: 32px;
    margin-bottom: 32px;
    flex: 1;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 1000px;
}

.upload-card {
    flex: 1;
    max-width: 480px;
    background: var(--paper-cream);
    border: 1px solid var(--border-default);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.upload-card:hover {
    border-color: rgba(199, 62, 29, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.upload-card.dragover {
    border-color: var(--cinnabar);
    background: var(--cinnabar-pale);
    border-style: dashed;
}

.upload-card.has-files .drop-zone {
    display: none;
}

.card-header {
    height: 64px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-default);
}

.card-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.card-dot.source { background: var(--cinnabar); }
.card-dot.target { background: var(--indigo); }

.card-icon {
    font-size: 18px;
}

.card-title-group {
    flex: 1;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink-black);
    margin-bottom: 2px;
}

.card-subtitle {
    font-size: 12px;
    color: var(--ink-muted);
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
}

.card-count {
    width: 28px;
    height: 28px;
    border-radius: 14px;
    background: var(--paper-old);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-muted);
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

.card-count.has-files {
    background: var(--cinnabar);
    color: white;
}

.drop-zone {
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: linear-gradient(180deg, var(--paper-white) 0%, rgba(247, 244, 237, 0.5) 100%);
    border: 2px dashed var(--border-default);
    border-radius: 0 0 16px 16px;
    margin: -1px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-card:hover .drop-zone {
    border-color: rgba(199, 62, 29, 0.2);
}

.drop-pattern {
    font-size: 48px;
    color: var(--border-strong);
    opacity: 0.5;
    font-family: Georgia, serif;
}

.drop-hint {
    font-size: 15px;
    color: var(--ink-light);
    font-weight: 500;
}

.drop-subhint {
    font-size: 12px;
    color: var(--ink-muted);
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
}

.file-input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    top: 0;
    left: 0;
    z-index: -1;
}

/* 文件列表 */
.file-list {
    padding: 12px 16px;
    max-height: 200px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: white;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    margin-bottom: 8px;
}

.file-item:last-child {
    margin-bottom: 0;
}

.file-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--ink-light);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--ink-muted);
    transition: all 0.2s;
}

.remove-btn:hover {
    background: var(--cinnabar-pale);
    color: var(--cinnabar);
}

/* ========== 操作區 ========== */
.action-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.btn-group {
    display: flex;
    gap: 16px;
}

.btn {
    height: 48px;
    padding: 0 32px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: 'Noto Serif SC', 'PingFang SC', sans-serif;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--cinnabar);
    color: white;
    min-width: 180px;
}

.btn-primary:hover:not(:disabled) {
    background: var(--cinnabar-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(199, 62, 29, 0.3);
}

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

.btn-secondary {
    background: transparent;
    color: var(--ink-light);
    border: 1px solid var(--border-default);
    min-width: 140px;
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.02);
    border-color: var(--border-strong);
}

.status-text {
    font-size: 13px;
    color: var(--ink-muted);
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
}

/* ========== 進度區域 ========== */
.progress-area {
    background: var(--paper-cream);
    border: 1px solid var(--border-default);
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 700px;
}

.steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.step-dot {
    font-size: 10px;
    color: var(--ink-muted);
}

.step.active .step-dot {
    color: var(--cinnabar);
}

.step.completed .step-dot {
    color: var(--bamboo);
}

.step-label {
    font-size: 12px;
    color: var(--ink-muted);
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
}

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

.step.completed .step-label {
    color: var(--bamboo);
}

.step-line {
    flex: 1;
    height: 2px;
    background: var(--border-default);
    max-width: 60px;
}

.progress-bar {
    height: 8px;
    background: var(--border-default);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-fill {
    height: 100%;
    background: var(--cinnabar);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.stage-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-black);
}

.stage-progress {
    font-size: 14px;
    font-weight: 600;
    color: var(--cinnabar);
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

.progress-message {
    text-align: center;
    font-size: 13px;
    color: var(--ink-light);
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
}

/* 實時匹配 */
.live-matches-section {
    background: var(--paper-cream);
    border: 1px solid var(--border-default);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 700px;
}

.live-matches-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--ink-black);
}

.matches-list {
    max-height: 300px;
    overflow-y: auto;
}

.no-matches {
    text-align: center;
    color: var(--ink-muted);
    padding: 24px;
}

.match-item {
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    margin-bottom: 8px;
}

.match-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--ink-muted);
    margin-bottom: 6px;
}

.confidence {
    color: var(--cinnabar);
    font-weight: 600;
}

.match-text {
    font-size: 13px;
    color: var(--ink-light);
    line-height: 1.5;
}

/* ========== 結果視圖 ========== */
.results-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    width: 100%;
    max-width: 800px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 20px;
    background: var(--paper-cream);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--cinnabar);
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

.stat-label {
    font-size: 13px;
    color: var(--ink-muted);
    margin-top: 4px;
}

.results-list {
    width: 100%;
    max-width: 800px;
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 24px;
}

.result-item {
    padding: 16px 20px;
    background: var(--paper-cream);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    margin-bottom: 12px;
}

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

.result-meta {
    font-size: 12px;
    color: var(--ink-muted);
}

.result-confidence {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--paper-old);
    color: var(--ink-muted);
}

.result-confidence.high {
    background: var(--bamboo-pale);
    color: var(--bamboo);
}

.result-confidence.medium {
    background: #FEF3C7;
    color: #D97706;
}

.result-texts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.text-block {
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-default);
}

.text-label {
    display: block;
    font-size: 11px;
    color: var(--ink-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.text-content {
    font-size: 13px;
    color: var(--ink-light);
    line-height: 1.6;
}

/* ========== 底部 ========== */
.footer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--border-default);
    margin-top: auto;
}

.version {
    font-size: 12px;
    color: var(--ink-muted);
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ========== 模態框 ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 420px;
    max-width: 90%;
    background: var(--paper-cream);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-default);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--ink-black);
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    color: var(--ink-muted);
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--paper-old);
    color: var(--ink-black);
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-black);
}

.setting-group select,
.setting-group input[type="number"] {
    padding: 10px 14px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    color: var(--ink-black);
    font-family: inherit;
}

.setting-group select:focus,
.setting-group input:focus {
    outline: none;
    border-color: var(--cinnabar);
}

.range-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-group input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--border-default);
    border-radius: 3px;
}

.range-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--cinnabar);
    border-radius: 50%;
    cursor: pointer;
}

.range-group span {
    font-size: 14px;
    font-weight: 600;
    color: var(--cinnabar);
    min-width: 32px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-default);
    display: flex;
    justify-content: flex-end;
}

/* ========== 響應式 ========== */
@media (max-width: 900px) {
    .sidebar {
        width: 60px;
        padding: 16px 0;
    }

    .logo {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .brand {
        display: none;
    }

    .nav-item {
        width: 48px;
        height: 56px;
    }

    .nav-item .label {
        display: none;
    }

    .main-content {
        padding: 24px;
        max-width: calc(100% - 60px);
    }

    .header h1 {
        font-size: 28px;
    }

    .cards-container {
        flex-direction: column;
    }

    .upload-card {
        max-width: 100%;
    }

    .results-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .result-texts {
        grid-template-columns: 1fr;
    }
}

/* 滾動條樣式 */
::-webkit-scrollbar {
    width: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background-color: var(--ink-muted);
}

/* 動畫 */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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