/**
 * Photo to Coloring Page - Stylesheet
 * 图片转换页面样式
 */

/* ==================== Page Container ==================== */
.page-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 30px;
}

/* ==================== Converter Layout (4:6) ==================== */
.converter-layout {
    display: grid;
    grid-template-columns: 4fr 6fr;
    gap: 30px;
    align-items: stretch;
}

/* ==================== Left Panel - Control Cards ==================== */
.control-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
}

/* 第一个卡片（上传）自动扩展填充剩余空间 */
.control-card:first-child {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.control-card:first-child .upload-area {
    flex: 1;
}

/* 独立卡片通用样式 - 毛玻璃效果 */
.control-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* 每个卡片独立飘动动画 */
.control-card:nth-child(1) { animation: floatCard1 5s ease-in-out infinite; }
.control-card:nth-child(2) { animation: floatCard2 5.5s ease-in-out infinite; }
.control-card:nth-child(3) { animation: floatCard3 6s ease-in-out infinite; }
.control-card:nth-child(4) { animation: floatCard4 4.5s ease-in-out infinite; }

@keyframes floatCard1 {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
@keyframes floatCard2 {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
@keyframes floatCard3 {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}
@keyframes floatCard4 {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-7px); }
}

/* ==================== Right Panel - Preview ==================== */
.preview-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 预览卡片 - 毛玻璃效果 */
.preview-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    animation: floatPreview 6s ease-in-out infinite;
}

.preview-card:nth-child(2) {
    animation: floatHistory 5.5s ease-in-out infinite;
    flex: 1;
}

@keyframes floatPreview {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
@keyframes floatHistory {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* ==================== Section Titles ==================== */
.section-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: #e5e7eb;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==================== Generate Button ==================== */
.generate-btn {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(to right, #FD9169, #0B95E3);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 8px 30px rgba(253, 145, 105, 0.4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(253, 145, 105, 0.5);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.points-cost {
    font-size: 0.875rem;
    opacity: 0.8;
}

/* ==================== Demo Comparison (16:9) ==================== */
.preview-demo {
    width: 100%;
}

.demo-comparison {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 12px;
    overflow: hidden;
    background: #1e1b4b;
    user-select: none;
}

/* 生成进度 - 与demo-comparison保持相同高度 */
.generation-progress {
    width: 100%;
    aspect-ratio: 16/9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(30, 27, 75, 0.5);
    border-radius: 12px;
    padding: 0 !important; /* 覆盖Tailwind的py-12 */
}

.demo-after, .demo-before {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.demo-before { 
    clip-path: inset(0 50% 0 0); 
}

.comparison-slider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background: linear-gradient(to bottom, #FD9169, #0B95E3);
    cursor: ew-resize;
    transform: translateX(-50%);
    z-index: 10;
}

.slider-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #FD9169, #0B95E3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* ==================== Upload Area ==================== */
.upload-area {
    border: 2px dashed rgba(253, 145, 105, 0.3);
    border-radius: 12px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: rgba(253, 145, 105, 0.6);
    background: rgba(253, 145, 105, 0.1);
}

.upload-input { display: none; }

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 1.5rem;
}

.upload-preview {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 10px;
    overflow: hidden;
}

.upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}

.delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.8);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 5;
}

.delete-btn:hover { 
    background: rgba(239, 68, 68, 1); 
    transform: scale(1.1); 
}

/* ==================== Style Option ==================== */
.style-option {
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.style-option:hover {
    background: rgba(253, 145, 105, 0.15);
    border-color: rgba(253, 145, 105, 0.3);
}

.style-option.active {
    background: rgba(253, 145, 105, 0.2);
    border-color: #FD9169;
    box-shadow: 0 0 0 2px rgba(253, 145, 105, 0.3);
}

/* ==================== Toggle Switch ==================== */
.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.toggle-input { display: none; }

.toggle-slider {
    width: 44px;
    height: 24px;
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
    position: relative;
    transition: all 0.3s;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: all 0.3s;
}

.toggle-input:checked + .toggle-slider {
    background: linear-gradient(to right, #FD9169, #0B95E3);
}

.toggle-input:checked + .toggle-slider::after {
    left: 23px;
}

/* ==================== Result Comparison ==================== */
/* 默认隐藏，由JS控制显示 */
#resultPreviewSection:not(.visible) {
    display: none !important;
}

.result-preview-section {
    margin-top: 40px;
    width: 100%;
    text-align: center;
}

.result-preview-section .preview-card {
    display: inline-block;
    width: fit-content;
    max-width: 100%;
    text-align: left;
    animation: floatResult 5.5s ease-in-out infinite;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

@keyframes floatResult {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* 结果下载按钮组飘动效果 */
.result-download-wrapper {
    animation: floatButtons 6s ease-in-out infinite;
}

@keyframes floatButtons {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.result-comparison {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: #1e1b4b;
    user-select: none;
}

.result-comparison img.result-after {
    display: block;
    max-width: 100%;
    height: auto;
}

.result-comparison .result-before {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    clip-path: inset(0 50% 0 0);
}

/* ==================== Progress ==================== */
.progress-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #FD9169;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 16px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, #FD9169, #0B95E3);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

/* ==================== History Grid ==================== */
.history-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.history-placeholder {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #6b7280;
    gap: 8px;
}

.history-item {
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.history-item:hover {
    border-color: #FD9169;
    transform: scale(1.02);
}

.history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==================== Modal ==================== */
.result-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background: rgba(15, 15, 30, 0.95);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 30px;
    max-width: 650px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.modal-content::-webkit-scrollbar {
    display: none;
}

.modal-close {
    position: absolute;
    top: -45px;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #333;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.modal-close:hover {
    background: #fff;
    transform: scale(1.1);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 16px;
}

.modal-image-container {
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.modal-image {
    width: 100%;
    border-radius: 12px;
}

.modal-info {
    display: flex;
    justify-content: space-between;
    color: #9ca3af;
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.modal-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    font-size: 0.875rem;
}

.modal-btn.primary {
    background: linear-gradient(to right, #FD9169, #0B95E3);
    color: #fff;
}

.modal-btn.primary:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 8px 20px rgba(147,51,234,0.3); 
}

.modal-btn.secondary {
    background: rgba(255,255,255,0.1);
    color: #d1d5db;
    border: 1px solid rgba(255,255,255,0.1);
}

.modal-btn.secondary:hover { background: rgba(255,255,255,0.15); }

.modal-footer {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.modal-link {
    color: #FD9169;
    font-size: 0.875rem;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    transition: color 0.2s;
}

.modal-link:hover { color: #c4b5fd; }

.modal-message {
    color: #d1d5db;
    text-align: center;
    margin-bottom: 16px;
}

/* ==================== Inspiration Section (More Pages) ==================== */
.inspiration-section {
    margin-top: 60px;
    padding: 40px 0;
}

.inspiration-title {
    font-family: 'Inter', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 30px;
}

.inspiration-wrapper {
    overflow: hidden;
    position: relative;
}

.inspiration-marquee {
    display: flex;
    gap: 16px;
    animation: scrollMarquee 60s linear infinite;
    width: max-content;
}

.inspiration-marquee:hover {
    animation-play-state: paused;
}

@keyframes scrollMarquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.inspiration-item {
    flex-shrink: 0;
    height: 280px;
    width: fit-content;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
    position: relative;
    text-decoration: none;
}

.inspiration-item:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 40px rgba(253, 145, 105, 0.3);
}

.inspiration-item img {
    height: 100%;
    width: auto;
    display: block;
}

.inspiration-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.inspiration-item:hover .inspiration-caption {
    opacity: 1;
}

.inspiration-caption span {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: #fff;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== Responsive ==================== */
@media screen and (max-width: 1050px) {
    .converter-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .control-card:first-child {
        flex: none;
    }
    
    .control-card:first-child .upload-area {
        flex: none;
    }
}

@media screen and (max-width: 767px) {
    .page-container {
        padding: 0 16px;
    }
    
    .control-card,
    .preview-card {
        padding: 16px;
    }
    
    .upload-area {
        min-height: 200px;
    }
    
    .upload-preview img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
    
    .history-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .inspiration-item {
        height: 200px;
    }
}
