/**
 * Text 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;
}

.converter-layout > .control-panel,
.converter-layout > .preview-panel {
    min-height: 0;
}

/* ==================== Left Panel - Control Cards ==================== */
.control-panel {
    display: flex;
    flex-direction: column;
}

.control-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
}

/* 独立卡片通用样式 - 毛玻璃效果 */
.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:first-child {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.control-card:first-child .textarea-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.control-card:first-child .text-input {
    flex: 1;
    min-height: 200px;
}

/* 每个卡片独立飘动动画 */
.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 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(-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;
}

/* ==================== Textarea - 自动扩展填充剩余空间 ==================== */
.textarea-wrapper { 
    position: relative; 
}

.text-input {
    width: 100%;
    height: 100%;
    min-height: 200px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 16px;
    padding-bottom: 40px;
    color: #e5e7eb;
    font-size: 1.1rem;
    line-height: 1.7;
    resize: none;
    transition: border-color 0.3s;
    font-family: 'Inter', system-ui, sans-serif;
}

.text-input:focus {
    outline: none;
    border-color: rgba(253, 145, 105, 0.5);
    box-shadow: 0 0 0 3px rgba(253, 145, 105, 0.1);
}

.text-input::placeholder { 
    color: #6b7280;
    font-size: 1.05rem;
}

.randomize-btn {
    position: absolute;
    bottom: 10px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(253, 145, 105, 0.2);
    border: 1px solid rgba(253, 145, 105, 0.3);
    color: #FD9169;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.randomize-btn:hover {
    background: rgba(253, 145, 105, 0.3);
    color: #c4b5fd;
}

.infinity-icon { font-size: 1rem; }

.char-count {
    position: absolute;
    bottom: 12px;
    left: 16px;
    font-size: 0.75rem;
    color: #6b7280;
}

/* ==================== 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;
}

/* ==================== Toggle ==================== */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle-input { display: none; }

.toggle-slider {
    width: 36px;
    height: 20px;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    position: relative;
    transition: all 0.3s;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    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: 18px;
}

/* ==================== Style Option ==================== */
.style-option {
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 10px 8px;
    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);
}

/* ==================== Preview Image (16:9) ==================== */
.preview-image-wrapper {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    position: relative;
}

.preview-placeholder {
    width: 100%;
    height: 100%;
}

.placeholder-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.placeholder-image.full {
    object-fit: contain;
}

.generation-progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 15, 30, 0.8);
    border-radius: 12px;
    padding: 0 !important; /* 覆盖Tailwind的py-16 */
}

/* ==================== 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%;
}

/* ==================== Result Image ==================== */
/* 默认隐藏，由JS控制显示 */
#resultPreviewSection:not(.visible) {
    display: none !important;
}

.result-preview-section {
    margin-top: 40px;
    width: 100%;
    text-align: center;
}

.result-preview-section .preview-card,
.result-preview-section .preview-container {
    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-image-container {
    border-radius: 16px;
    overflow: hidden;
}

.result-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 16px;
}

/* ==================== 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-prompt {
    color: #9ca3af;
    font-size: 0.8rem;
    font-style: italic;
    margin-bottom: 12px;
    line-height: 1.5;
}

.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 .text-input {
        flex: none;
        min-height: 180px;
    }
}

@media screen and (max-width: 767px) {
    .page-container {
        padding: 0 16px;
    }
    
    .control-card,
    .preview-card {
        padding: 16px;
    }
    
    .control-card:first-child .text-input {
        min-height: 210px;
    }
    
    .history-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .inspiration-item {
        height: 200px;
    }
    
    /* Result Modal - mobile fix */
    .result-modal {
        padding: 12px;
    }
    
    .modal-content {
        width: 100%;
        max-width: none;
        padding: 20px;
        border-radius: 16px;
        max-height: 90vh;
    }
    
    .modal-close {
        top: -38px;
        right: 4px;
    }
    
    .modal-title {
        font-size: 1.25rem;
    }
    
    .modal-actions {
        flex-direction: column;
        gap: 8px;
    }
}
