/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 标签页样式 */
.tab-container {
    margin-bottom: 20px;
}

.tab-buttons {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 15px;
}

.tab-btn {
    padding: 10px 20px;
    background-color: #f8f9fa;
    border: none;
    border-bottom: 3px solid transparent;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.3s;
    margin-right: 0;
}

.tab-btn.active {
    background-color: white;
    color: #4a9eff;
    border-bottom-color: #4a9eff;
}

.tab-btn:hover:not(.active) {
    background-color: #e9ecef;
}

.tab-content {
    display: none;
    padding: 10px 0;
}

.tab-content.active {
    display: block;
}

/* 网站URL输入样式 */
.website-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 15px;
    transition: border-color 0.3s;
}

.website-input:focus {
    outline: none;
    border-color: #4a9eff;
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.extract-btn {
    background-color: #28a745;
    color: white;
    margin-bottom: 15px;
}

.extract-btn:hover {
    background-color: #218838;
}

/* 提取图片区域样式 */
.extracted-images-section {
    margin-top: 20px;
    border-top: 1px solid #e9ecef;
    padding-top: 20px;
}

.extracted-images-section h3 {
    font-size: 16px;
    color: #34495e;
    margin-bottom: 15px;
}

.extracted-images-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background-color: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 15px;
}

.image-preview-card {
    position: relative;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    overflow: hidden;
    background-color: #f8f9fa;
    transition: transform 0.2s, box-shadow 0.2s;
}

.image-preview-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.image-preview-wrapper {
    position: relative;
    padding-top: 100%; /* 1:1 宽高比 */
    overflow: hidden;
}

.image-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.image-checkbox {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    z-index: 10;
    accent-color: #4a9eff;
}

.image-url {
    padding: 8px;
    font-size: 12px;
    color: #6c757d;
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    word-break: break-all;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.extracted-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.extracted-controls button {
    background-color: #6c757d;
    color: white;
    font-size: 13px;
    padding: 8px 15px;
}

.extracted-controls button:hover {
    background-color: #5a6268;
}

#addSelectedToQueue {
    background-color: #4a9eff;
}

#addSelectedToQueue:hover {
    background-color: #3a8eef;
}

/* 图片容器滚动条样式 */
.extracted-images-container::-webkit-scrollbar {
    width: 6px;
}

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

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

.extracted-images-container::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* 加载状态样式 */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4a9eff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 无图片提示 */
.no-images-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-style: italic;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .extracted-images-container {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
    
    .extracted-controls {
        flex-direction: column;
    }
    
    .extracted-controls button {
        width: 100%;
        margin-bottom: 5px;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 标题样式 */
h1 {
    font-size: 28px;
    color: #1a5c9d;
    margin-bottom: 25px;
    text-align: center;
    font-weight: 600;
}

h2 {
    font-size: 20px;
    color: #34495e;
    margin-bottom: 15px;
    font-weight: 500;
}

/* 输入区域样式 */
.input-section {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
}

.helper-text {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 10px;
    background-color: #e7f3ff;
    padding: 8px 12px;
    border-radius: 4px;
    border-left: 3px solid #4a9eff;
}

#streamUrls {
    width: 100%;
    height: 150px;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
}

#streamUrls:focus {
    outline: none;
    border-color: #4a9eff;
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

/* 选项区域 */
.options {
    display: flex;
    gap: 20px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.pack-download-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.pack-download-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.pack-download-option label {
    cursor: pointer;
    font-weight: 500;
    color: #333;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-group input,
.option-group select {
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.option-group input:focus,
.option-group select:focus {
    outline: none;
    border-color: #4a9eff;
}

/* 按钮样式 */
.container button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    margin-right: 10px;
}

#startDownload {
    background-color: #4a9eff;
    color: white;
}

#startDownload:hover {
    background-color: #3a8eef;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(74, 158, 255, 0.3);
}

#startDownload:disabled {
    background-color: #b8c2cc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 信息说明区域样式 */
.info-section {
    margin: 20px 0;
    padding: 0;
}

.info-details {
    width: 100%;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
}

.info-details summary {
    padding: 12px 16px;
    font-weight: 500;
    color: #495057;
    background-color: #f1f3f4;
    cursor: pointer;
    outline: none;
    user-select: none;
    transition: background-color 0.3s;
}

.info-details summary:hover {
    background-color: #e9ecef;
}

.info-details summary::-webkit-details-marker {
    float: right;
    color: #6c757d;
}

.info-content {
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    color: #495057;
    background-color: white;
}

.info-content p {
    margin-bottom: 12px;
}

.info-content ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.info-content li {
    margin-bottom: 8px;
}

.info-content strong {
    color: #4a9eff;
    font-weight: 600;
}

.secondary {
    background-color: #6c757d;
    color: white;
}

.secondary:hover {
    background-color: #5a6268;
}

/* 下载区域样式 */
.download-section {
    margin-top: 20px;
}

/* 完成状态提示样式 */
.completion-status {
    margin-top: 20px;
    padding: 20px;
    background-color: #f0f8ff;
    border: 1px solid #b8daff;
    border-radius: 8px;
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease-in-out;
}

.completion-status.visible {
    opacity: 1;
    transform: translateY(0);
}

.status-text {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin-bottom: 15px;
}

.action-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.primary-button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.primary-button:hover:not(:disabled) {
    background-color: #45a049;
}

.primary-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.secondary-button {
    background-color: #2196F3;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.secondary-button:hover:not(:disabled) {
    background-color: #0b7dda;
}

.secondary-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .primary-button,
    .secondary-button {
        width: 100%;
    }
}

.completion-status .status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.completion-status .status-icon.success {
    background-color: #4caf50;
}

.completion-status .status-icon.partial {
    background-color: #ff9800;
}

.completion-status .status-text {
    font-weight: 500;
}

/* 下载项信息区域样式 */
.item-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 10px;
}

/* 状态文本样式 */
.status {
    font-size: 13px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
}

.status.completed {
    color: #2e7d32;
    background-color: #e8f5e9;
}

.status.failed {
    color: #c62828;
    background-color: #ffebee;
}

.status.skipped {
    color: #f57c00;
    background-color: #fff3e0;
}
/* 保存链接状态 */
.status.saved-link {
    color: #1976d2;
    font-weight: bold;
    background-color: #e3f2fd;
}

/* 保存链接计数样式 */
.saved-count {
    color: #1976d2;
    font-weight: bold;
    font-size: 1.1em;
}

/* 统计信息颜色 */
#failedFiles {
    color: #c62828;
    font-weight: bold;
}

#skippedFiles {
    color: #f57c00;
    font-weight: bold;
}

#completedFiles {
    color: #2e7d32;
    font-weight: bold;
}

/* 完成状态提示颜色 */
.completion-status .failed-count {
    color: #c62828;
    font-weight: bold;
}

.completion-status .skipped-count {
    color: #f57c00;
    font-weight: bold;
}

.completion-status .success-count {
    color: #2e7d32;
    font-weight: bold;
}

/* 淡入淡出动画 */
.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease;
    color: #333;
}

.completion-status.fade-out {
    opacity: 0;
    transform: translateY(-10px);
}

/* 错误提示消息样式 */
.error-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-top: 15px;
    border-radius: 6px;
    background-color: #ffebee;
    border-left: 4px solid #f44336;
    transition: opacity 0.5s ease, transform 0.3s ease;
}

.error-message .error-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #f44336;
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.error-message .error-text {
    font-weight: 500;
    color: #333;
}

.error-message.fade-out {
    opacity: 0;
    transform: translateY(-10px);
}

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

.stats {
    font-size: 14px;
    color: #6c757d;
}

/* 进度条样式 */
.progress-container {
    width: 100%;
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: #4a9eff;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* 下载列表样式 */
.download-list {
    /* 计算每个download-item的大致高度：padding(12px*2) + margin-bottom(10px) + 内容高度 ≈ 45px */
    /* 5个项的总高度约为225px，加上一些缓冲 */
    max-height: 395px;
    overflow-y: auto;
    padding: 10px 0;
}

.download-item {
    padding: 12px;
    margin-bottom: 10px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #4a9eff;
    transition: all 0.3s;
}

.download-item.downloading {
    border-left-color: #4a9eff;
}

.download-item.completed {
    border-left-color: #28a745;
}

.download-item.failed {
    border-left-color: #dc3545;
}

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

.file-name {
    font-weight: 500;
    color: #495057;
    font-size: 14px;
    word-break: break-all;
    flex: 1;
    margin-right: 10px;
}

.status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    background-color: #e9ecef;
    color: #6c757d;
}

.status.downloading {
    background-color: #e3f2fd;
    color: #1976d2;
}

.status.completed {
    background-color: #e8f5e9;
    color: #388e3c;
}

.status.failed {
    background-color: #ffebee;
    color: #d32f2f;
}

/* 打开文件按钮样式 */
.open-file-btn {
    background-color: #2196F3;
    color: white;
    border: none;
    padding: 3px 8px;
    margin-left: 5px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    vertical-align: middle;
    transition: background-color 0.3s;
}

.open-file-btn:hover {
    background-color: #0b7dda;
}

.open-file-btn:active {
    transform: translateY(1px);
}

/* 调整带有打开按钮的状态元素 */
.status-completed.has-open-button {
    display: flex;
    align-items: center;
    gap: 5px;
}

.item-progress {
    width: 100%;
    height: 4px;
    background-color: #dee2e6;
    border-radius: 2px;
    margin-top: 5px;
    overflow: hidden;
}

.item-progress-bar {
    height: 100%;
    background-color: #4a9eff;
    transition: width 0.3s ease;
}

/* 查看按钮样式 */
.item-actions {
    margin: 0;
    display: flex;
    justify-content: flex-end;
}

.view-button {
    background: #2196f3;
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.view-button:hover {
    background: #1976d2;
}

.view-button:active {
    transform: translateY(1px);
}

/* 预览模态框样式 */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

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

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90vh;
    width: 800px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { 
        transform: translateY(-50px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

.close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    transition: color 0.2s ease;
    z-index: 10;
}

.close-button:hover {
    color: #333;
}

.preview-title {
    margin: 0;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    font-size: 18px;
    color: #333;
}

.preview-container {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    max-height: calc(90vh - 100px);
    overflow: auto;
}

.preview-container img,
.preview-container video {
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* 响应式调整 */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .preview-container {
        padding: 15px;
        min-height: 200px;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .options {
        flex-direction: column;
        gap: 10px;
    }
    
    .progress-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    button {
        margin-bottom: 10px;
        width: 100%;
    }
}

/* 滚动条样式 */
.download-list::-webkit-scrollbar {
    width: 6px;
}

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

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

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