/* Anki卡包提取工具样式 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --success-color: #10B981;
    --error-color: #EF4444;
    --warning-color: #F59E0B;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --bg-primary: #F9FAFB;
    --bg-secondary: #FFFFFF;
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 页面头部 */
.page-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 0;
}

.page-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.page-header .subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* 上传区域 */
.upload-section {
    margin-bottom: 40px;
}

.upload-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 40px;
    box-shadow: var(--shadow-md);
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 60px 40px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: #F0F0FF;
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: var(--primary-color);
}

.upload-icon svg {
    width: 100%;
    height: 100%;
}

.upload-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.upload-hint {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.upload-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* 上传进度 */
.upload-progress {
    margin-top: 30px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.progress-bar {
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #818CF8);
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* 提取结果 */
.extract-result {
    margin-top: 30px;
    padding: 30px;
    background: linear-gradient(135deg, #F0FDF4 0%, #ECFDF5 100%);
    border-radius: 8px;
    border: 1px solid #BBF7D0;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.result-icon {
    width: 32px;
    height: 32px;
}

.result-icon.success {
    color: var(--success-color);
}

.result-header h3 {
    font-size: 1.5rem;
    color: var(--success-color);
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.stat-item {
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #D1FAE5;
}

/* 字段名展示区域 */
.field-names-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #D1FAE5;
}

.field-names-section h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

.field-names-list {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: visible;
    padding-bottom: 100px;
    position: relative;
}

.field-notetype-item {
    margin-bottom: 16px;
    padding: 12px 12px 80px 12px;
    background: #F9FAFB;
    border-radius: 6px;
    border: 1px solid #E5E7EB;
    overflow: visible;
    min-width: 500px;
    position: relative;
    z-index: 1;
}

.field-notetype-name {
    font-weight: 600;
    color: #4F46E5;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-notetype-name::before {
    content: "📝";
    font-size: 1.1rem;
}

.field-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.field-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #EEF2FF;
    color: #4338CA;
    border-radius: 6px;
    font-size: 0.85rem;
    border: 1px solid #C7D2FE;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 150px;
    max-width: 300px;
    z-index: 2;
}

.field-tag:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.field-tag.selected-front {
    background: #DEF7EC;
    border-color: #84E1BC;
    color: #03543F;
}

.field-tag.selected-back {
    background: #FCE7F3;
    border-color: #F9A8D4;
    color: #831843;
}

.field-tag-label-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0; /* 允许内容截断 */
}

.field-tag-label {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.field-tag-example {
    font-size: 0.75rem;
    color: #6B7280;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
}

.field-tag.selected-front .field-tag-example {
    color: #047857;
}

.field-tag.selected-back .field-tag-example {
    color: #9F1239;
}

.field-tag-badge {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 3px;
    background: white;
    font-weight: 600;
}

.field-tag.selected-front .field-tag-badge {
    background: #10B981;
    color: white;
}

.field-tag.selected-back .field-tag-badge {
    background: #EC4899;
    color: white;
}

.field-tag-actions {
    display: none;
    position: fixed;
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    min-width: 120px;
    white-space: nowrap;
    margin: 0;
}

.field-tag:hover .field-tag-actions {
    display: block;
}

.field-tag-action-btn {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: white;
    text-align: left;
    cursor: pointer;
    font-size: 0.85rem;
    color: #374151;
    transition: background 0.2s;
}

.field-tag-action-btn:hover {
    background: #F3F4F6;
}

.field-tag-action-btn:first-child {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.field-tag-action-btn:last-child {
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

.field-tag-action-btn.action-front {
    color: #10B981;
}

.field-tag-action-btn.action-back {
    color: #EC4899;
}

.field-tag-action-btn.action-clear {
    color: #6B7280;
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--success-color);
}

.view-detail-btn {
    flex: 1;
    background-color: var(--success-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.view-detail-btn:hover {
    background-color: #059669;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.convert-btn {
    flex: 1;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.convert-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.convert-btn:disabled {
    background-color: #9CA3AF;
    cursor: not-allowed;
    transform: none;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-textarea {
    resize: vertical;
    font-family: inherit;
}

.field-mapping-confirm {
    background: #F9FAFB;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #E5E7EB;
}

.field-mapping-confirm h4 {
    font-size: 0.95rem;
    color: #374151;
}

.btn-cancel,
.btn-primary {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-cancel {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-cancel:hover {
    background: #F9FAFB;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    background: #9CA3AF;
    cursor: not-allowed;
}

/* 历史记录 */
.history-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow-md);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.refresh-btn svg {
    width: 16px;
    height: 16px;
}

.refresh-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

/* 历史记录列表 */
.history-list {
    display: grid;
    gap: 15px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.history-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.history-item-left {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
}

.history-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), #818CF8);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
}

.history-info {
    flex: 1;
}

.history-filename {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.history-meta {
    display: flex;
    gap: 15px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.history-item-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
}

.status-badge.success {
    background-color: #D1FAE5;
    color: var(--success-color);
}

.status-badge.processing {
    background-color: #FEF3C7;
    color: var(--warning-color);
}

.status-badge.failed {
    background-color: #FEE2E2;
    color: var(--error-color);
}

.history-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.action-btn.view {
    background-color: var(--primary-color);
    color: white;
}

.action-btn.view:hover {
    background-color: var(--primary-hover);
}

.action-btn.delete {
    background-color: transparent;
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

.action-btn.delete:hover {
    background-color: var(--error-color);
    color: white;
}

.action-btn.reupload {
    background-color: transparent;
    color: #F59E0B;
    border: 1px solid #F59E0B;
}

.action-btn.reupload:hover {
    background-color: #F59E0B;
    color: white;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
}

.page-btn {
    padding: 8px 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.page-btn:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.page-btn:disabled {
    background-color: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.page-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 对话框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

/* 详情信息 */
.detail-info {
    margin-bottom: 30px;
}

.detail-info h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.info-item {
    display: flex;
    gap: 8px;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.info-value {
    color: var(--text-primary);
}

/* 笔记列表 */
.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.notes-header h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 0;
}

.deck-filter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.deck-filter label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.deck-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-primary);
    background-color: white;
    cursor: pointer;
    min-width: 200px;
    transition: all 0.3s ease;
}

.deck-select:hover {
    border-color: var(--primary-color);
}

.deck-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.notes-list {
    display: grid;
    gap: 15px;
}

.note-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
}

.note-type {
    font-weight: 600;
    color: var(--primary-color);
}

.note-deck {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: linear-gradient(135deg, #F0F0FF, #E8E8FF);
    border: 1px solid #D0D0FF;
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 500;
}

.note-deck::before {
    content: "📚";
    font-size: 0.9rem;
}

.note-tags {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.note-fields {
    display: grid;
    gap: 12px;
}

.note-field {
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.field-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 5px;
}

.field-value {
    color: var(--text-primary);
    line-height: 1.6;
}

.field-value img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 10px 0;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

/* 加载动画 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .page-header h1 {
        font-size: 2rem;
    }

    .upload-card {
        padding: 20px;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .result-stats {
        grid-template-columns: 1fr;
    }

    .history-item {
        flex-direction: column;
        gap: 15px;
    }

    .history-item-left {
        width: 100%;
    }

    .history-item-right {
        width: 100%;
        justify-content: space-between;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: 10px;
    }

    .modal-body {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .page-header {
        padding: 20px 0;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .section-header {
        flex-direction: column;
        gap: 10px;
    }
}

