/* ==================== 变量 ==================== */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ==================== 重置 ==================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.6;
}

/* ==================== 布局 ==================== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    padding: 40px 20px 30px;
    color: white;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.footer {
    text-align: center;
    padding: 20px;
    color: white;
    opacity: 0.8;
    font-size: 0.875rem;
}

/* ==================== 上传区域 ==================== */
.upload-section {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 48px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: var(--gray-50);
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--primary);
    margin-bottom: 12px;
}

.upload-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.upload-hint {
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* ==================== 进度条 ==================== */
.upload-progress {
    padding: 0;
}

.upload-progress[hidden] {
    display: none;
}

.resume-upload-card {
    margin-top: 16px;
    border: 1px solid #c7d2fe;
    background: #eef2ff;
    border-radius: var(--radius);
    padding: 16px 18px;
}

.resume-upload-card[hidden] {
    display: none;
}

.resume-upload-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.resume-upload-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.resume-upload-text {
    font-size: 0.85rem;
    color: var(--gray-700);
}

.resume-upload-meta {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 4px;
}

.resume-upload-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.progress-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
}

.progress-icon {
    width: 40px;
    height: 40px;
    color: var(--primary);
}

.progress-icon svg {
    width: 100%;
    height: 100%;
}

.progress-icon svg.spin {
    animation: spin 1s linear infinite;
}

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

.progress-text {
    text-align: center;
}

.progress-status {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.progress-filename {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-500);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
}

.progress-bar-wrap {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar, .status-bar {
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    flex: 1;
}

.progress-fill, .status-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-percent {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    min-width: 36px;
    text-align: right;
}

/* ==================== 状态卡片 ==================== */
.status-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
}

.status-card[hidden] {
    display: none;
}

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

.status-label {
    font-weight: 600;
    color: var(--gray-700);
}

.status-progress {
    color: var(--primary);
    font-weight: 600;
}

.status-message {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* ==================== 结果卡片 ==================== */
.result-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.result-card[hidden] {
    display: none;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
    gap: 10px;
}

.result-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.result-actions {
    display: flex;
    gap: 8px;
}

.result-content {
    padding: 16px 20px;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.875rem;
    line-height: 1.8;
    color: var(--gray-700);
    background: var(--gray-50);
}

/* ==================== 历史记录区域 ==================== */
.history-section {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
    gap: 10px;
}

.section-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.section-actions {
    display: flex;
    gap: 8px;
}

.section-actions .btn svg {
    width: 16px;
    height: 16px;
}

/* ==================== 搜索和筛选 ==================== */
.filter-bar {
    display: flex;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--gray-100);
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--gray-400);
}

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-group select {
    padding: 8px 28px 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 0.875rem;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
    appearance: none;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ==================== 加载/空状态 ==================== */
.loading, .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.loading[hidden], .empty-state[hidden] {
    display: none;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.empty-state p {
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* ==================== 任务列表 ==================== */
.task-list {
    display: flex;
    flex-direction: column;
}

.task-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.2s;
    gap: 12px;
}

.task-item:hover {
    background: var(--gray-50);
}

.task-item:last-child {
    border-bottom: none;
}

.task-item-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.task-item-name-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.task-item-name {
    font-weight: 500;
    color: var(--gray-800);
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 桌面端编辑状态 - 水平排列 */
.task-item-name.editing {
    flex-wrap: nowrap;
    overflow: visible;
}

.task-item-name.editing .name-input {
    width: auto;
    min-width: 120px;
    max-width: 200px;
}

.task-item-name.editing .edit-actions {
    display: flex;
    gap: 6px;
}

.edit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    flex-shrink: 0;
}

.task-item:hover .edit-btn {
    opacity: 1;
}

.edit-btn:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.edit-btn svg {
    width: 14px;
    height: 14px;
}

.name-input {
    padding: 4px 8px;
    border: 1px solid var(--primary);
    border-radius: 4px;
    font-size: 0.875rem;
    width: 150px;
    outline: none;
}

.edit-confirm, .edit-cancel {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.edit-confirm {
    background: var(--success);
    color: white;
}

.edit-confirm:hover {
    background: #059669;
}

.edit-cancel {
    background: var(--gray-200);
    color: var(--gray-600);
}

.edit-cancel:hover {
    background: var(--gray-300);
}

.edit-confirm svg, .edit-cancel svg {
    width: 14px;
    height: 14px;
}

.task-item-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 2px;
}

.task-status {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
    flex-shrink: 0;
    min-width: 50px;
    text-align: center;
}

.task-status.processing {
    background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    font-weight: 600;
}

/* ==================== 操作按钮 ==================== */
.task-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.action-btn.success { color: var(--success); }
.action-btn.success:hover { background: #d1fae5; }
.action-btn.primary { color: var(--primary); }
.action-btn.primary:hover { background: #e0e7ff; }
.action-btn.danger { color: var(--error); }
.action-btn.danger:hover { background: #fee2e2; }

.action-btn svg {
    width: 18px;
    height: 18px;
}

.action-btn[hidden] {
    display: none;
}

.task-status.pending { background: var(--gray-100); color: var(--gray-600); }
.task-status.processing { background: #fef3c7; color: #92400e; }
.task-status.uploading { background: #dbeafe; color: #1d4ed8; }
.task-status.completed { background: #d1fae5; color: #065f46; }
.task-status.failed { background: #fee2e2; color: #991b1b; }

/* ==================== 分页 ==================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    border-top: 1px solid var(--gray-100);
}

.pagination[hidden] {
    display: none;
}

.page-count {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.page-info {
    font-size: 0.8rem;
    color: var(--gray-600);
    min-width: 60px;
    text-align: center;
}

.page-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-btn svg {
    width: 16px;
    height: 16px;
}

.page-info {
    font-size: 0.8rem;
    color: var(--gray-600);
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn svg {
    width: 16px;
    height: 16px;
}

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

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

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

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

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

/* ==================== 弹窗 ==================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--gray-500);
    cursor: pointer;
}

.modal-close:hover {
    background: var(--gray-100);
}

.modal-close svg {
    width: 18px;
    height: 18px;
}

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

.detail-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-100);
}

.detail-info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-info-label {
    font-size: 0.7rem;
    color: var(--gray-500);
    text-transform: uppercase;
}

.detail-info-value {
    font-size: 0.875rem;
    color: var(--gray-800);
}

.detail-result {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.875rem;
    line-height: 1.8;
    color: var(--gray-700);
    background: var(--gray-50);
    padding: 12px;
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--gray-200);
    flex-wrap: wrap;
}

.modal-footer .btn {
    flex: 1;
    justify-content: center;
}

/* 文字+图标按钮 */
.action-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--gray-600);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.action-text:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.action-text svg {
    width: 16px;
    height: 16px;
}

.action-text.danger:hover {
    background: #fee2e2;
    color: var(--error);
}

/* 详情结果区域 */
.detail-result-wrap {
    margin-top: 16px;
}

.result-loading {
    color: var(--gray-400);
    font-style: italic;
}

/* ==================== 确认对话框 ==================== */
.confirm-dialog {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-dialog[hidden] {
    display: none;
}

.confirm-content {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 24px;
    width: 90%;
    max-width: 320px;
}

.confirm-content p {
    text-align: center;
    font-size: 0.9375rem;
    color: var(--gray-800);
    margin-bottom: 16px;
}

.confirm-actions {
    display: flex;
    gap: 12px;
}

.confirm-actions .btn {
    flex: 1;
    justify-content: center;
}

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.8rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toast.show {
    opacity: 1;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }

/* ==================== 响应式 ==================== */
@media (max-width: 640px) {
    .container {
        padding: 12px;
    }

    /* 移动端编辑按钮始终显示 */
    .edit-btn {
        opacity: 1;
        background: var(--gray-100);
    }

    /* 移动端快速编辑适配 - 编辑时垂直布局 */
    .task-item {
        align-items: flex-start;
    }

    .task-item-name-wrap {
        min-width: 0;
        flex: 1;
        width: 100%;
    }

    .task-item-name {
        white-space: normal;
        overflow: visible;
        flex-wrap: wrap;
    }

    .task-item-name.editing {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        width: 100%;
    }

    .task-item-name.editing .name-input {
        width: 100%;
        font-size: 0.9rem;
        padding: 8px 12px;
        box-sizing: border-box;
    }

    .task-item-name.editing .edit-actions {
        display: flex;
        gap: 10px;
        justify-content: flex-end;
    }

    .task-item-name.editing .edit-confirm,
    .task-item-name.editing .edit-cancel {
        width: 44px;
        height: 44px;
    }

    .task-item-name.editing .edit-confirm svg,
    .task-item-name.editing .edit-cancel svg {
        width: 22px;
        height: 22px;
    }

    .header {
        padding: 24px 12px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .upload-area {
        padding: 32px 16px;
    }

    .resume-upload-body {
        flex-direction: column;
        align-items: flex-start;
    }

    .resume-upload-actions {
        width: 100%;
        flex-direction: column;
    }

    .resume-upload-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-actions {
        width: 100%;
    }

    .result-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .modal-content {
        width: 95%;
        max-height: 85vh;
    }

    .detail-info {
        grid-template-columns: 1fr;
    }

    .modal-footer {
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        min-width: calc(50% - 4px);
    }
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}
