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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

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

/* 头部样式 */
.header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    animation: fadeIn 0.8s ease-in;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 主要内容区域 */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
    animation: fadeInUp 0.8s ease-in;
}

/* 通用section样式 */
.upload-section,
.preview-section,
.result-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.upload-section:hover,
.preview-section:hover,
.result-section:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
}

.upload-section h3,
.preview-section h3,
.result-section h3 {
    text-align: center;
    margin-bottom: 15px;
    color: #667eea;
    font-size: 1.2rem;
}

/* 上传区域样式 */
.upload-area {
    border: 2px dashed #667eea;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9ff;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #764ba2;
    background: #f0f4ff;
    transform: scale(1.02);
}

.upload-content {
    max-width: 300px;
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    animation: bounce 2s infinite;
}

.upload-content h3 {
    margin-bottom: 10px;
    color: #333;
}

.upload-content p {
    margin-bottom: 8px;
    color: #666;
    font-size: 0.9rem;
}

.size-hint {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 20px;
}

.file-input {
    display: none;
}

.upload-btn {
    display: inline-block;
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.upload-btn:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* 预览区域样式 */
.preview-container,
.grid-container {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #fafafa;
}

.original-image {
    max-width: 100%;
    max-height: 250px;
    object-fit: contain;
    display: none;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.original-image.show {
    display: block;
    animation: fadeIn 0.5s ease-in;
}

/* 九宫格结果样式 */
.grid-result {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    width: 100%;
    height: 250px;
    background: #e0e0e0;
    display: none;
}

.grid-result.show {
    display: grid;
    animation: fadeIn 0.5s ease-in;
}

.grid-item {
    background: white;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

.grid-item:hover {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.grid-item.selected {
    border: 3px solid #667eea;
    box-shadow: 0 0 0 2px white inset;
}

.grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.grid-item .item-number {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
}

.grid-item .item-checkbox {
    position: absolute;
    top: 5px;
    left: 5px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 空状态样式 */
.empty-state {
    text-align: center;
    color: #888;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.9rem;
}

/* 操作区域样式 */
.action-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    animation: fadeInUp 0.8s ease-in 0.2s both;
}

.action-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.cut-options {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cut-label,
.export-label {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.cut-mode-select,
.export-type-select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: white;
}

.cut-mode-select:focus,
.export-type-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.action-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 120px;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.cut-btn {
    background: #4caf50;
    color: white;
}

.cut-btn:hover:not(:disabled) {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.reset-btn {
    background: #f44336;
    color: white;
}

.reset-btn:hover {
    background: #da190b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.export-section {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.export-options {
    display: flex;
    align-items: center;
    gap: 10px;
}

.export-options label {
    font-weight: 600;
    color: #333;
}

.format-select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.format-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.export-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.export-all-btn {
    background: #2196f3;
    color: white;
}

.export-all-btn:hover:not(:disabled) {
    background: #0b7dda;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.export-selected-btn {
    background: #ff9800;
    color: white;
}

.export-selected-btn:hover:not(:disabled) {
    background: #e68a00;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

/* 状态消息样式 */
.status-message {
    background: white;
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: none;
    animation: slideIn 0.3s ease-in;
    text-align: center;
    font-weight: 600;
}

.status-message.show {
    display: block;
}

.status-message.success {
    border-left: 4px solid #4caf50;
    color: #4caf50;
}

.status-message.error {
    border-left: 4px solid #f44336;
    color: #f44336;
}

.status-message.info {
    border-left: 4px solid #2196f3;
    color: #2196f3;
}

/* 加载动画样式 */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.loading.show {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading p {
    font-size: 1.1rem;
    color: #667eea;
    font-weight: 600;
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

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

/* 响应式设计 */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
    }
    
    .result-section {
        grid-column: 1 / -1;
    }
    
    .grid-result {
        height: 300px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .upload-section,
    .preview-section,
    .result-section {
        padding: 15px;
    }
    
    .upload-area {
        min-height: 200px;
        padding: 20px;
    }
    
    .upload-icon {
        font-size: 3rem;
    }
    
    .preview-container,
    .grid-container {
        min-height: 200px;
    }
    
    .grid-result {
        height: 250px;
    }
    
    .action-controls,
    .export-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .action-btn {
        width: 100%;
    }
    
    .export-options {
        justify-content: center;
    }
    
    .export-buttons {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .upload-content h3 {
        font-size: 1.1rem;
    }
    
    .grid-result {
        height: 200px;
    }
}