/**
 * Reference Manager - Base Styles
 *
 * 职责：参考文献管理器基础样式
 * 作用域：模态框、工具栏、表格
 * 依赖：variables.css
 *
 * 提取自：reference-manager-base.css
 *
 * 包含：
 * - 模态框基础样式
 * - 工具栏和按钮样式
 * - 表格样式
 * - 表单和编辑样式
 * - 进度提示样式
 */

/* ==================== 1. 模态框基础样式 ==================== */

.reference-modal {
    display: none;
    position: fixed;
    z-index: var(--z-modal);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-base) ease;
}

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

.reference-modal-content {
    background: linear-gradient(180deg, var(--color-bg-primary), var(--color-bg-secondary));
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 1400px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-2xl);
    animation: slideUp var(--transition-base) ease;
}

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

.reference-edit-content {
    max-width: 800px;
}

/* ==================== 2. 头部样式 ==================== */

.reference-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg) 30px;
    border-bottom: 1px solid var(--color-border);
    background: linear-gradient(135deg, var(--color-primary-light), #eef2ff);
}

.reference-modal-header h2 {
    margin: 0;
    font-size: var(--font-size-2xl);
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.reference-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: color var(--transition-fast);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.reference-modal-close:hover {
    color: var(--color-text-primary);
    background-color: var(--color-bg-secondary);
}

/* ==================== 3. 工具栏样式 ==================== */

.reference-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    border-bottom: 1px solid var(--color-border);
    background: linear-gradient(90deg, var(--color-bg-primary), var(--color-bg-secondary));
    backdrop-filter: blur(4px);
}

.reference-toolbar-left,
.reference-toolbar-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ref-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-border-light);
    background-color: var(--color-bg-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: var(--font-weight-medium);
    box-shadow: var(--shadow-sm);
}

.ref-btn:hover {
    background-color: var(--color-bg-secondary);
    border-color: var(--color-border);
}

.ref-btn-primary {
    background-color: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.ref-btn-primary:hover {
    background-color: var(--color-primary-hover);
}

.ref-btn-success {
    background-color: var(--color-success);
    color: white;
    border-color: var(--color-success);
}

.ref-btn-success:hover {
    background-color: #0ea873;
    border-color: #0ea873;
}

.ref-btn-danger {
    background-color: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
}

.ref-btn-danger:hover {
    background-color: #dc2626;
}

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

#ref-search-input {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    width: 250px;
    font-size: var(--font-size-sm);
    background: var(--color-bg-primary);
}

#ref-filter-select {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    background: var(--color-bg-primary);
    cursor: pointer;
}

/* ==================== 4. 统计信息样式 ==================== */

.reference-stats {
    display: flex;
    gap: 30px;
    padding: 15px 30px;
    background: linear-gradient(90deg, #f8fafc, #eef2ff);
    border-bottom: 1px solid var(--color-border);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.reference-stats strong {
    color: var(--color-text-primary);
    font-weight: var(--font-weight-semibold);
}

/* ==================== 5. 表格容器样式 ==================== */

.reference-table-container {
    flex: 1;
    overflow: auto;
    padding: 0;
}

/* ==================== 6. 表格样式 ==================== */

.reference-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.reference-table thead {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background-color: var(--color-bg-primary);
}

.reference-table th {
    padding: var(--spacing-md) var(--spacing-md);
    text-align: left;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    border-bottom: 2px solid var(--color-border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.reference-table th:hover {
    background-color: var(--color-bg-secondary);
}

.reference-table th[data-sort]::after {
    content: ' ⇅';
    opacity: 0.3;
}

.reference-table td {
    padding: var(--spacing-md) var(--spacing-md);
    border-bottom: 1px solid var(--color-border-light);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reference-table tbody tr:hover {
    background-color: var(--color-primary-light);
}

.reference-table tbody tr:nth-child(even) {
    background-color: var(--color-bg-secondary);
}

.ref-empty-state {
    text-align: center;
    color: var(--color-text-secondary);
    padding: 40px !important;
    font-style: italic;
    background: var(--color-bg-secondary);
}

/* ==================== 7. 表格特定列样式 ==================== */

.ref-authors,
.ref-title,
.ref-journal {
    max-width: 200px;
}

.ref-title {
    font-weight: var(--font-weight-medium);
}

.ref-doi {
    color: var(--color-primary);
    text-decoration: none;
}

.ref-doi:hover {
    text-decoration: underline;
}

.ref-tag {
    display: inline-block;
    padding: 2px var(--spacing-sm);
    background-color: var(--color-primary-light);
    color: var(--color-primary);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    margin-right: 4px;
}

.ref-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.ref-action-btn {
    background: none;
    border: none;
    font-size: var(--font-size-base);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

.ref-action-btn:hover {
    background-color: var(--color-border);
}

/* ==================== 8. 复选框样式 ==================== */

.ref-checkbox {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

/* ==================== 9. 底部样式 ==================== */

.reference-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    border-top: 1px solid var(--color-border);
    background-color: var(--color-bg-secondary);
}

.reference-footer-left {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.reference-footer-right {
    display: flex;
    gap: 10px;
}

/* ==================== 10. 编辑表单样式 ==================== */

.reference-edit-form {
    padding: var(--spacing-lg) 30px;
    max-height: 60vh;
    overflow-y: auto;
}

.ref-form-row {
    margin-bottom: var(--spacing-lg);
}

.ref-form-row label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
}

.ref-form-row input,
.ref-form-row select {
    width: 100%;
    padding: 10px var(--spacing-md);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    transition: border-color var(--transition-fast);
}

.ref-form-row input:focus,
.ref-form-row select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.ref-form-row-half {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* ==================== 11. 进度提示样式 ==================== */

.ref-progress {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: calc(var(--z-modal) + 1);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: var(--spacing-lg) 40px;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    text-align: center;
}

.ref-progress-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.ref-progress-content::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 3px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ==================== 12. 侧栏菜单样式 ==================== */

.ref-sidebar-menu {
    padding: var(--spacing-sm) 0;
}

.ref-sidebar-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 10px var(--spacing-lg);
    cursor: pointer;
    transition: background-color var(--transition-fast);
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
}

.ref-sidebar-item:hover {
    background-color: var(--color-bg-secondary);
}

.ref-sidebar-item.active {
    background-color: #e3f2fd;
    color: #1976d2;
}

/* ==================== 13. 提取方式选择模态框 ==================== */

.extraction-method-options {
    display: grid;
    gap: var(--spacing-md);
}

.extraction-method-item {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, #ffffff, #f8f9fa);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base) cubic-bezier(0.4, 0, 0.2, 1);
}

.extraction-method-item:hover {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-color: var(--color-primary);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.method-icon {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary), #2563eb);
    border-radius: var(--radius-lg);
    color: white;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.extraction-method-item:hover .method-icon {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.method-info {
    flex: 1;
}

.method-info h3 {
    margin: 0 0 var(--spacing-sm) 0;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
}

.method-info p {
    margin: 0 0 var(--spacing-md) 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    line-height: var(--leading-relaxed);
}

.method-info ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.method-info li {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: var(--leading-normal);
}

/* 特殊标记混合模式 */
.extraction-method-item[data-method="hybrid"] {
    border-color: #10b981;
    position: relative;
}

.extraction-method-item[data-method="hybrid"]::before {
    content: '推荐';
    position: absolute;
    top: -12px;
    right: 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    padding: 4px var(--spacing-md);
    border-radius: var(--radius-full);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.extraction-method-item[data-method="hybrid"]:hover {
    border-color: #10b981;
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
}

.extraction-method-item[data-method="hybrid"] .method-icon {
    background: linear-gradient(135deg, #10b981, #059669);
}

/* ==================== 14. 响应式设计 ==================== */

@media (max-width: 1200px) {
    .reference-modal-content {
        width: 95%;
    }

    .reference-toolbar {
        flex-direction: column;
        gap: 10px;
    }

    .reference-toolbar-left,
    .reference-toolbar-right {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 768px) {
    .reference-modal-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .reference-table th,
    .reference-table td {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-xs);
    }

    .ref-authors,
    .ref-title,
    .ref-journal {
        max-width: 150px;
    }

    .reference-stats {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
}

/* ==================== 15. 深色模式支持 ==================== */

@media (prefers-color-scheme: dark) {
    .reference-modal {
        background-color: rgba(0, 0, 0, 0.8);
    }

    .reference-modal-content {
        background-color: #1e1e1e;
        color: #e0e0e0;
    }

    .reference-modal-header,
    .reference-toolbar,
    .reference-modal-footer {
        background-color: #2d2d2d;
        border-color: #3d3d3d;
    }

    .reference-modal-header h2 {
        color: #e0e0e0;
    }

    .reference-stats {
        background-color: #252525;
        border-color: #3d3d3d;
        color: #aaa;
    }

    .reference-stats strong {
        color: #e0e0e0;
    }

    .reference-table {
        background-color: #1e1e1e;
    }

    .reference-table th {
        background-color: #2d2d2d;
        color: #e0e0e0;
        border-color: #3d3d3d;
    }

    .reference-table td {
        border-color: #2d2d2d;
    }

    .reference-table tbody tr:hover {
        background-color: #252525;
    }

    .ref-btn {
        background-color: #2d2d2d;
        border-color: #3d3d3d;
        color: #e0e0e0;
    }

    .ref-btn:hover {
        background-color: #3d3d3d;
    }

    #ref-search-input,
    #ref-filter-select,
    .ref-form-row input,
    .ref-form-row select {
        background-color: #2d2d2d;
        border-color: #3d3d3d;
        color: #e0e0e0;
    }

    .ref-tag {
        background-color: #1a3a52;
        color: #64b5f6;
    }
}
