/**
 * iColorFill - Pages Stylesheet
 * 子页面通用样式
 */

/* ============================================
   Page Layout
   ============================================ */
.page-main {
    min-height: calc(100vh - 75px);
    padding: 40px 0 80px;
    background-color: #002b36;
    background-image: url("https://www.yudiz.com/codepen/photography-banner/frame.png");
    background-size: cover;
    background-repeat: no-repeat;
}

.page-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 30px;
}

.page-header {
    text-align: center;
    margin-bottom: 50px;
}

.page-title {
    font-family: "Lexend", sans-serif;
    font-size: clamp(32px, 5vw, 56px);
    font-weight: 700;
    color: #fff;
    margin: 0 0 20px;
    text-transform: uppercase;
}

.page-title .highlight {
    color: #d33682;
}

.page-subtitle {
    font-family: "Lexend", sans-serif;
    font-size: 18px;
    color: #aaa;
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ============================================
   Converter Layout (Two Column)
   ============================================ */
.converter-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 40px;
    align-items: stretch;
}

/* Control Panel (Left) */
.control-panel {
    background: rgba(7, 54, 66, 0.8);
    border: 1px solid rgba(211, 54, 130, 0.2);
    border-radius: 20px;
    padding: 30px;
    position: sticky;
    top: 100px;
    min-height: 580px;
    display: flex;
    flex-direction: column;
}

/* Preview Panel (Right) */
.preview-panel {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* ============================================
   Upload Section
   ============================================ */
.upload-section {
    margin-bottom: 30px;
}

.upload-area {
    border: 2px dashed rgba(211, 54, 130, 0.5);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(0, 43, 54, 0.5);
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #d33682;
    background: rgba(211, 54, 130, 0.1);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.upload-icon {
    color: #d33682;
    opacity: 0.8;
}

.upload-text {
    font-family: "Lexend", sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.upload-hint {
    font-size: 14px;
    color: #aaa;
    line-height: 1.5;
}

.upload-input {
    display: none;
}

.upload-preview {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 14px;
    overflow: hidden;
}

.upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}

.delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(211, 54, 130, 0.9);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.delete-btn:hover {
    background: #d33682;
    transform: scale(1.1);
}

/* ============================================
   Text Input Section
   ============================================ */
.text-input-section {
    margin-bottom: 30px;
}

.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.textarea-wrapper {
    position: relative;
}

.text-input {
    width: 100%;
    min-height: 140px;
    padding: 15px;
    padding-bottom: 50px;
    border: 2px dashed rgba(211, 54, 130, 0.5);
    border-radius: 16px;
    background: rgba(0, 43, 54, 0.5);
    color: #fff;
    font-family: "Lexend", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.3s ease;
}

.text-input.tall {
    min-height: 270px;
}

.text-input:focus {
    outline: none;
    border-color: #d33682;
    background: rgba(211, 54, 130, 0.1);
}

.text-input::placeholder {
    color: #666;
}

.randomize-btn {
    position: absolute;
    right: 15px;
    bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: #aaa;
    font-family: "Lexend", sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.randomize-btn:hover {
    background: rgba(211, 54, 130, 0.2);
    color: #fff;
}

.infinity-icon {
    font-size: 18px;
    background: linear-gradient(135deg, #d33682, #87CEEB);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.char-count {
    position: absolute;
    left: 15px;
    bottom: 15px;
    font-size: 12px;
    color: #666;
}

/* ============================================
   Style Selection
   ============================================ */
.style-section {
    margin-bottom: 30px;
}

.section-title {
    font-family: "Lexend", sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin: 0 0 12px;
    background: linear-gradient(135deg, #d33682, #87CEEB);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Enhance Toggle below title */
.enhance-toggle {
    margin-bottom: 15px;
    display: flex;
    justify-content: flex-start;
    gap: 12px;
}

.style-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.style-grid.text-styles {
    grid-template-columns: repeat(4, 1fr);
}

.style-grid.three-cols {
    grid-template-columns: repeat(3, 1fr);
}

.style-option {
    padding: 15px 10px;
    background: rgba(0, 43, 54, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.style-option:hover {
    border-color: rgba(211, 54, 130, 0.5);
}

.style-option.active {
    border-color: #d33682;
    background: rgba(211, 54, 130, 0.15);
}

.style-option.with-image {
    padding: 8px;
}

.style-preview {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
}

.style-name {
    font-family: "Lexend", sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.style-desc {
    font-size: 12px;
    color: #aaa;
    margin-top: 4px;
}

/* ============================================
   Options & Toggles
   ============================================ */
.options-section {
    margin-bottom: 30px;
}

.toggle-option {
    margin-bottom: 15px;
}

.toggle-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(0, 43, 54, 0.5);
    border-radius: 10px;
    cursor: pointer;
    font-family: "Lexend", sans-serif;
    font-size: 14px;
    color: #fff;
}

.toggle-label.compact {
    padding: 0;
    background: none;
    font-size: 13px;
    color: #aaa;
}

.toggle-input {
    display: none;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    position: relative;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: all 0.3s ease;
}

.toggle-input:checked + .toggle-slider {
    background: linear-gradient(135deg, #d33682, #FF91B3);
}

.toggle-input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ============================================
   Generate Button
   ============================================ */
.generate-btn {
    width: 100%;
    padding: 18px 30px;
    background: linear-gradient(135deg, #d33682, #FF91B3);
    border: none;
    border-radius: 50px;
    color: #fff;
    font-family: "Lexend", sans-serif;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: auto;
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(211, 54, 130, 0.4);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.points-cost {
    font-size: 13px;
    font-weight: 400;
    opacity: 0.8;
}

/* ============================================
   Preview Container
   ============================================ */
.preview-container {
    background: rgba(7, 54, 66, 0.8);
    border: 1px solid rgba(211, 54, 130, 0.2);
    border-radius: 20px;
    padding: 20px;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.preview-container.text-preview {
    flex: 1;
    padding: 20px;
}

/* Demo Comparison */
.preview-demo {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.demo-comparison {
    position: relative;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16/9;
    border-radius: 16px;
    overflow: hidden;
    background: #002b36;
    user-select: none;
    -webkit-user-select: none;
}

.demo-comparison img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
    -webkit-user-select: none;
}

.demo-before {
    clip-path: inset(0 50% 0 0);
}

.comparison-slider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background: #d33682;
    cursor: ew-resize;
    z-index: 10;
}

.slider-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: #d33682;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 15px rgba(211, 54, 130, 0.5);
}

/* Placeholder */
.preview-placeholder {
    text-align: center;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-image {
    max-width: 280px;
    max-height: 280px;
    object-fit: contain;
    opacity: 0.8;
    margin-bottom: 20px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.placeholder-image.full {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
    margin-bottom: 0;
    border-radius: 12px;
    opacity: 1;
}

.placeholder-text {
    font-family: "Lexend", sans-serif;
    font-size: 16px;
    color: #666;
}

/* Generation Progress */
.generation-progress {
    text-align: center;
}

.progress-spinner {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(211, 54, 130, 0.2);
    border-top-color: #d33682;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.progress-percentage {
    font-family: "Lexend", sans-serif;
    font-size: 48px;
    font-weight: 700;
    color: #d33682;
    margin-bottom: 10px;
}

.progress-text {
    font-family: "Lexend", sans-serif;
    font-size: 16px;
    color: #aaa;
    margin-bottom: 20px;
}

.progress-bar-container {
    width: 80%;
    max-width: 300px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin: 0 auto;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #d33682, #FF91B3);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Result Image */
.result-image {
    max-width: 100%;
    max-height: 460px;
    object-fit: contain;
    border-radius: 12px;
}

/* ============================================
   Download Actions
   ============================================ */
.download-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.download-btn {
    flex: 1;
    min-width: 140px;
    padding: 14px 20px;
    border-radius: 12px;
    font-family: "Lexend", sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.download-btn.primary {
    background: linear-gradient(135deg, #d33682, #FF91B3);
    border: none;
    color: #fff;
}

.download-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(211, 54, 130, 0.4);
}

.download-btn.secondary {
    background: rgba(7, 54, 66, 0.8);
    border: 1px solid rgba(211, 54, 130, 0.3);
    color: #fff;
}

.download-btn.secondary:hover {
    border-color: #d33682;
    background: rgba(211, 54, 130, 0.1);
}

/* ============================================
   History Section
   ============================================ */
.history-section {
    background: rgba(7, 54, 66, 0.8);
    border: 1px solid rgba(211, 54, 130, 0.2);
    border-radius: 20px;
    padding: 25px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.history-header h3 {
    font-family: "Lexend", sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.view-all {
    font-family: "Lexend", sans-serif;
    font-size: 14px;
    color: #d33682;
    text-decoration: none;
    transition: color 0.3s ease;
}

.view-all:hover {
    color: #FF91B3;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.history-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.history-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 10px;
}

.history-text {
    font-family: "Lexend", sans-serif;
    font-size: 14px;
}

.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: #d33682;
    transform: scale(1.02);
}

.history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   Responsive
   ============================================ */
@media screen and (max-width: 1199px) {
    .converter-layout {
        grid-template-columns: 350px 1fr;
        gap: 30px;
    }
    
    .style-grid.text-styles {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media screen and (max-width: 991px) {
    .converter-layout {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        position: static;
        min-height: auto;
    }
    
    .style-grid.text-styles,
    .style-grid.three-cols {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .history-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .preview-container.text-preview {
        min-height: 400px;
    }
}

@media screen and (max-width: 767px) {
    .page-main {
        padding: 30px 0 60px;
    }
    
    .page-container {
        padding: 0 16px;
    }
    
    .page-subtitle {
        font-size: 16px;
    }
    
    .control-panel {
        padding: 20px;
    }
    
    .style-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .style-grid.text-styles,
    .style-grid.three-cols {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Mobile preview containers - auto height for varying image dimensions */
    .preview-container {
        min-height: auto;
        height: auto;
        padding: 16px;
    }
    
    .preview-container.text-preview {
        min-height: auto;
        height: auto;
        padding: 16px;
    }
    
    /* Demo comparison - auto height to fit image content */
    .demo-comparison {
        max-width: 100%;
        aspect-ratio: unset;
        height: auto;
    }
    
    .demo-comparison img {
        position: relative;
        width: 100%;
        height: auto;
    }
    
    .demo-comparison .demo-before {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    /* Preview placeholder - auto height */
    .preview-placeholder {
        height: auto;
    }
    
    .placeholder-image.full {
        width: 100%;
        height: auto;
        max-height: none;
    }
    
    /* Result image - auto height */
    .result-image {
        max-height: none;
        width: 100%;
        height: auto;
    }
    
    .download-actions {
        flex-direction: column;
    }
    
    .download-btn {
        width: 100%;
    }
    
    .history-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   Result Preview Section (Below Converter Layout - Full Width)
   ============================================ */
.result-preview-section {
    margin-top: 40px;
    margin-left: auto;
    margin-right: auto;
    background: rgba(7, 54, 66, 0.8);
    border: 1px solid rgba(211, 54, 130, 0.2);
    border-radius: 20px;
    padding: 30px;
    width: fit-content;
    max-width: 100%;
}

.result-comparison {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: #002b36;
    user-select: none;
    -webkit-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);
}

.result-comparison .comparison-slider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background: #d33682;
    cursor: ew-resize;
    z-index: 10;
}

.result-comparison .slider-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: #d33682;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 15px rgba(211, 54, 130, 0.5);
}

/* Download buttons wrapper - outside the background container */
.result-download-wrapper {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin: 25px auto 0;
    max-width: 60%;
}

/* Result image container for text page */
.result-image-container {
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: #002b36;
}

.result-image-container .result-image {
    width: 100%;
    height: auto;
    display: block;
}

/* Text page: full width preview section */
.page-text .result-preview-section {
    width: 100%;
}

/* ============================================
   Result Modal
   ============================================ */
.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background: #073642;
    border: 1px solid rgba(211, 54, 130, 0.3);
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    /* Hide scrollbar but keep functionality */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* Hide scrollbar for Chrome/Safari */
.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-family: "Lexend", sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 20px;
    text-align: center;
}

.modal-image-container {
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    background: #002b36;
}

.modal-image {
    width: 100%;
    display: block;
}

.modal-prompt {
    font-family: "Lexend", sans-serif;
    font-size: 13px;
    color: #aaa;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.modal-info {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
    font-family: "Lexend", sans-serif;
    font-size: 14px;
    color: #aaa;
}

.modal-message {
    font-family: "Lexend", sans-serif;
    font-size: 16px;
    color: #aaa;
    text-align: center;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.modal-btn {
    flex: 1;
    padding: 14px 20px;
    border-radius: 12px;
    font-family: "Lexend", sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    transition: transform 0.2s;
}

.modal-btn.primary {
    background: linear-gradient(135deg, #d33682, #FF91B3);
    border: none;
    color: #fff;
}

.modal-btn.secondary {
    background: rgba(7, 54, 66, 0.8);
    border: 1px solid rgba(211, 54, 130, 0.3);
    color: #fff;
}

.modal-btn:hover {
    transform: translateY(-2px);
}

.modal-footer {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.modal-link {
    font-family: "Lexend", sans-serif;
    font-size: 14px;
    color: #d33682;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
}

.modal-link:hover {
    color: #FF91B3;
}

/* Modal Mobile Responsive */
@media (max-width: 480px) {
    .modal-content {
        padding: 20px;
        border-radius: 16px;
    }
    
    .modal-title {
        font-size: 20px;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-footer {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
}
