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

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
}

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

header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    margin-bottom: 15px;
    color: #333;
    font-size: 24px;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 15px;
}

.upload-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.upload-btn:hover {
    background: #0056b3;
}

.refresh-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.refresh-btn:hover {
    background: #5a6268;
}

/* 上传弹窗样式 */
.upload-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.upload-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
}

.upload-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 0 20px;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
}

.upload-modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 20px;
}

.upload-modal-body {
    padding: 0 20px 20px 20px;
}

.upload-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    background: #fafafa;
    cursor: pointer;
    transition: border-color 0.3s ease, background-color 0.3s ease;
    margin-bottom: 15px;
    position: relative;
}

.upload-area:hover {
    border-color: #007bff;
    background: #f0f8ff;
}

.upload-area.drag-over {
    border-color: #28a745;
    background: #f0fff0;
    border-style: solid;
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    pointer-events: none;
}

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

.upload-icon svg {
    color: #666;
    pointer-events: none;
}

.upload-title {
    font-size: 18px;
    color: #333;
    margin: 0;
    pointer-events: none;
}

.upload-subtitle {
    font-size: 14px;
    color: #666;
    margin: 0;
    pointer-events: none;
}

.upload-link {
    color: #007bff;
    text-decoration: underline;
    pointer-events: none;
}

.upload-hint {
    font-size: 12px;
    color: #999;
    margin: 0;
    pointer-events: none;
}

/* 上传进度条 */
.upload-progress {
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: #007bff;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    color: #666;
    font-size: 14px;
}

.upload-actions {
    text-align: center;
}

/* 文件网格优化 */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    padding: 20px 0;
}

.file-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.file-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.file-preview {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 10px;
    cursor: pointer;
    background: #f5f5f5;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 5px;
    word-break: break-all;
    color: #333;
}

.file-size {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
}

.file-tags {
    margin-bottom: 10px;
    min-height: 20px;
}

.file-tag {
    display: inline-block;
    background: #e9ecef;
    color: #495057;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    margin: 2px;
}

.file-actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
}

.file-actions button {
    padding: 4px 8px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    flex: 1;
    min-width: 45px;
}

.copy-btn {
    background: #007bff;
    color: white;
}

.copy-btn:hover {
    background: #0056b3;
}

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

.tag-btn:hover {
    background: #545b62;
}

.delete-btn {
    background: #dc3545;
    color: white;
}

.delete-btn:hover {
    background: #c82333;
}

/* 置顶样式 */
.file-item.pinned {
    border-color: #ffc107;
    background: #fffbf0;
}

.pinned-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #ffc107;
    color: #212529;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
}

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

.pin-btn:hover {
    background: #545b62;
}

.pin-btn.pinned {
    background: #ffc107;
    color: #212529;
}

/* Toast样式 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    background: #28a745;
}

.toast-error {
    background: #dc3545;
}

.toast-warning {
    background: #ffc107;
    color: #212529;
}

.toast-content {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 12px;
}

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

.toast-success .toast-icon {
    background: #28a745;
}

.toast-error .toast-icon {
    background: #dc3545;
}

.toast-warning .toast-icon {
    background: #ffc107;
    color: #212529;
}

.toast-content span {
    color: #495057;
    font-weight: 500;
    font-size: 14px;
}

/* 优化的Toast样式 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    z-index: 10000;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
    border-left: 4px solid #28a745;
    min-width: 280px;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-success {
    border-left-color: #28a745;
}

.toast-error {
    border-left-color: #dc3545;
}

.toast-warning {
    border-left-color: #ffc107;
}

.toast-content {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 12px;
}

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

.toast-success .toast-icon {
    background: #28a745;
}

.toast-error .toast-icon {
    background: #dc3545;
}

.toast-warning .toast-icon {
    background: #ffc107;
    color: #212529;
}

.toast-content span {
    color: #495057;
    font-weight: 500;
    font-size: 14px;
}

/* 置顶文件样式 */
.file-item.pinned {
    border: 2px solid #ffc107;
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cd 100%);
    position: relative;
}

.pinned-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #ffc107;
    color: #212529;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* 置顶按钮样式 */
.pin-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.pin-btn:hover {
    background: #5a6268;
}

.pin-btn.pinned {
    background: #ffc107;
    color: #212529;
}

.pin-btn.pinned:hover {
    background: #e0a800;
}

/* 提示框样式 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 10000;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
    font-weight: 500;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
}

.modal-content {
    position: relative;
    margin: 5% auto;
    padding: 20px;
    width: 90%;
    max-width: 800px;
    background: white;
    border-radius: 8px;
    max-height: 90vh;
    overflow: auto;
}

.close {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #000;
}

.modal img, .modal video {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.file-tags {
    margin: 5px 0;
    min-height: 20px;
}

.file-tag {
    display: inline-block;
    background: #007bff;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    margin: 2px;
}

/* 标签筛选区域 */
.tag-filter-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tag-filter-section h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
}

.tag-filter-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.selected-tags {
    min-height: 40px;
    padding: 10px;
    border: 2px dashed #007bff;
    border-radius: 6px;
    background: #f8f9fa;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.selected-tag {
    background: #007bff;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.remove-selected {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-selected:hover {
    background: rgba(255,255,255,0.2);
}

.filter-placeholder {
    color: #6c757d;
    font-style: italic;
}

.available-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-tag {
    background: #e9ecef;
    color: #495057;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tag:hover {
    background: #007bff;
    color: white;
    transform: translateY(-1px);
}

.clear-filter {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    align-self: flex-start;
}

.clear-filter:hover {
    background: #c82333;
}

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

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

.tag-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
}

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

.tag-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 0 20px;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
}

.tag-modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 20px;
}

.close-btn {
    font-size: 24px;
    cursor: pointer;
    color: #999;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.file-info {
    padding: 0 20px;
    margin-bottom: 20px;
}

.file-info .file-name {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: monospace;
    color: #495057;
    border: 1px solid #dee2e6;
}

.tag-section {
    padding: 0 20px;
    margin-bottom: 25px;
}

.tag-section:last-child {
    padding-bottom: 20px;
}

.tag-section h4 {
    margin-bottom: 12px;
    color: #495057;
    font-size: 16px;
    font-weight: 600;
}

.current-tags, .available-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
    padding: 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #f8f9fa;
}

.tag-item.current {
    background: #28a745;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tag-item.available {
    background: #007bff;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.tag-item.available:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.remove-tag {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-tag:hover {
    background: rgba(255,255,255,0.2);
}

.no-tags {
    color: #6c757d;
    font-style: italic;
    padding: 8px 0;
}

.new-tag-input {
    display: flex;
    gap: 10px;
    align-items: center;
}

.new-tag-input input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
}

.new-tag-input input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.add-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.add-btn:hover {
    background: #0056b3;
}

.no-files {
    text-align: center;
    color: #6c757d;
    font-size: 18px;
    padding: 40px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .upload-area {
        padding: 15px 10px;
    }
    
    .upload-content {
        flex-direction: column;
        gap: 10px;
    }
    
    .upload-text {
        text-align: center;
    }
    
    .upload-title {
        font-size: 14px;
    }
    
    .upload-subtitle {
        font-size: 12px;
    }
    
    .upload-hint {
        font-size: 11px;
    }
    
    .sort-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .sort-options {
        justify-content: space-between;
        gap: 8px;
    }
    
    .sort-btn {
        flex: 1;
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .batch-operations {
        justify-content: space-between;
    }
    
    .file-checkbox {
        width: 16px;
        height: 16px;
        top: 6px;
        left: 6px;
    }
    
    .file-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 10px 0;
    }
    
    .file-item {
        padding: 8px;
    }
    
    .file-preview {
        width: 100%;
        height: 100px;
        object-fit: cover;
        border-radius: 4px;
        margin-bottom: 8px;
        background: #f5f5f5;
        cursor: pointer;
    }
    
    .file-name {
        font-size: 11px;
        margin-bottom: 3px;
        line-height: 1.2;
        max-height: 2.4em;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    
    .file-size {
        font-size: 10px;
        margin-bottom: 6px;
    }
    
    .file-tags {
        margin-bottom: 6px;
        min-height: 16px;
    }
    
    .file-tag {
        font-size: 9px;
        padding: 1px 4px;
        margin: 1px;
    }
    
    .file-actions {
        gap: 2px;
        flex-direction: column;
    }
    
    .file-actions button {
        padding: 4px 6px;
        font-size: 9px;
        min-width: auto;
        width: 100%;
    }
}

/* 更小屏幕优化 */
@media (max-width: 480px) {
    .file-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    
    .file-item {
        padding: 6px;
    }
    
    .file-preview {
        margin-bottom: 6px;
    }
    
    .file-name {
        font-size: 10px;
    }
    
    .file-size {
        font-size: 9px;
    }
    
    .sort-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .batch-operations {
        flex-direction: column;
        gap: 8px;
    }
    
    .batch-operations button,
    #selectedCount {
        width: 100%;
        text-align: center;
    }
}

/* 上传区域动画效果 */
.upload-area::before {
    display: none;
}

.upload-area:hover::before {
    display: none;
}

/* 置顶文件在网格中的特殊效果 */
.file-item.pinned:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(255, 193, 7, 0.3);
}

/* 置顶文件的标签样式 */
.file-item.pinned .file-tag {
    background: #ffc107;
    color: #212529;
    border: 1px solid #e0a800;
}

/* 统一按钮样式，避免hover抖动 */
button {
    transition: background-color 0.2s ease, color 0.2s ease;
}

button:hover {
    transform: none;
}

.file-actions button:hover {
    transform: none;
}

.pin-btn:hover {
    background: #5a6268;
}

.pin-btn.pinned:hover {
    background: #e0a800;
}

.sort-options {
    display: flex;
    align-items: center;
    gap: 15px;
}

.sort-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    background: white;
    color: #6c757d;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.sort-btn:hover {
    border-color: #007bff;
    color: #007bff;
}

.sort-btn.active {
    border-color: #007bff;
    background: #007bff;
    color: white;
}

.sort-btn.active.asc {
    background: #28a745;
    border-color: #28a745;
}

.sort-btn.active.desc {
    background: #dc3545;
    border-color: #dc3545;
}

.sort-icon {
    font-weight: bold;
    font-size: 16px;
    min-width: 12px;
    text-align: center;
}

.sort-btn .sort-icon {
    color: #ccc;
}

.sort-btn.active .sort-icon {
    color: white;
}

.cache-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.cache-btn:hover {
    background: #c82333;
}

/* 缓存状态指示器 */
.cache-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(40, 167, 69, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1000;
    display: none;
    animation: slideUp 0.3s ease;
}

.cache-indicator.show {
    display: block;
}

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

/* 已缓存文件的视觉提示 */
.file-item.cached::after {
    content: '💾';
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 12px;
    opacity: 0.7;
}
