/* Generate Page Specific Styles */

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.nav-tab {
    padding: 0.625rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-tab:hover {
    color: var(--text-primary);
    border-color: var(--primary);
    background: var(--bg-secondary);
}

.nav-tab.active {
    color: white;
    background: var(--primary);
    border-color: var(--primary);
}

/* Generate Section */
.generate-section {
    max-width: 800px;
    margin: 0 auto;
    animation: fadeInUp 0.6s ease-out;
}

/* Init Image Card (img2img) */
.init-image-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.init-image-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.optional-tag {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
}

.init-image-dropzone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition);
    cursor: pointer;
    overflow: hidden;
}

.init-image-dropzone:hover,
.init-image-dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    text-align: center;
}

.dropzone-content svg {
    width: 48px;
    height: 48px;
    color: var(--text-tertiary);
}

.dropzone-content span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.dropzone-hint {
    font-size: 0.75rem !important;
    color: var(--text-tertiary) !important;
}

.init-image-preview {
    position: relative;
    width: 100%;
}

.init-image-preview img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.remove-init-image {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--error);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0.9;
}

.remove-init-image:hover {
    opacity: 1;
    transform: scale(1.1);
}

.remove-init-image svg {
    width: 18px;
    height: 18px;
}

/* Strength Slider */
.strength-slider {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.strength-slider label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.strength-value {
    font-weight: 600;
    color: var(--primary);
}

.strength-slider input[type="range"] {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 4px;
    outline: none;
}

.strength-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.strength-slider input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.strength-hints {
    display: flex;
    justify-content: space-between;
    margin-top: 0.25rem;
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

/* Prompt Card */
.prompt-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.prompt-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.char-count {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-tertiary);
}

.prompt-input {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    resize: vertical;
    transition: var(--transition);
}

.prompt-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.prompt-input::placeholder {
    color: var(--text-tertiary);
}

/* Negative Prompt */
.negative-prompt-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    overflow: hidden;
}

.collapse-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.collapse-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.collapse-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.collapse-toggle.expanded svg {
    transform: rotate(180deg);
}

.collapse-content {
    display: none;
    padding: 0 1.5rem 1.5rem;
}

.collapse-content.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

.negative-prompt-input {
    width: 100%;
    min-height: 60px;
    padding: 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    resize: vertical;
    transition: var(--transition);
}

.negative-prompt-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.option-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.option-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

/* Aspect Ratio Buttons */
.aspect-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.aspect-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    min-width: 50px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.aspect-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.aspect-btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.aspect-icon {
    background: currentColor;
    opacity: 0.8;
}

.aspect-icon.square {
    width: 20px;
    height: 20px;
}

.aspect-icon.wide {
    width: 24px;
    height: 14px;
}

.aspect-icon.tall {
    width: 14px;
    height: 24px;
}

.aspect-icon.landscape {
    width: 22px;
    height: 16px;
}

.aspect-icon.portrait {
    width: 16px;
    height: 22px;
}

.aspect-btn span {
    font-size: 0.625rem;
    font-weight: 600;
}

/* Style Select */
.style-select {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b6b84' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.style-select:focus {
    outline: none;
    border-color: var(--primary);
}

.style-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Number Buttons */
.num-buttons {
    display: flex;
    gap: 0.5rem;
}

.num-btn {
    flex: 1;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.num-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.num-btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* Advanced Options */
.advanced-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    overflow: hidden;
}

.advanced-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.advanced-option {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.advanced-option label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.model-select {
    padding: 0.625rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.model-select:focus {
    outline: none;
    border-color: var(--primary);
}

.seed-input-group {
    display: flex;
    gap: 0.5rem;
}

.seed-input {
    flex: 1;
    padding: 0.625rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.seed-input:focus {
    outline: none;
    border-color: var(--primary);
}

.seed-input::-webkit-outer-spin-button,
.seed-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.random-seed-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.random-seed-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.random-seed-btn svg {
    width: 20px;
    height: 20px;
}

/* Generate Button */
.generate-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 1.25rem 2rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.generate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.generate-btn:hover::before {
    left: 100%;
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.generate-btn.processing {
    pointer-events: none;
}

.generate-btn.processing .btn-text,
.generate-btn.processing .btn-icon {
    opacity: 0;
}

.generate-btn.processing .spinner {
    display: block;
}

.generate-btn .btn-icon {
    width: 24px;
    height: 24px;
}

/* Results Section */
.results-section {
    display: none;
    margin-top: 3rem;
    animation: fadeInUp 0.6s ease-out;
}

.results-section.visible {
    display: block;
}

.results-section h2 {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.results-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Result Card */
.result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
}

.result-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary);
}

.result-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    cursor: pointer;
    transition: var(--transition);
}

.result-card:hover img {
    opacity: 0.9;
}

.result-card-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
}

.result-download-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    background: var(--success);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.result-download-btn:hover {
    background: #059669;
}

.result-download-btn svg {
    width: 18px;
    height: 18px;
}

/* Lightbox for full-size viewing */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 2rem;
}

.lightbox.visible {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.lightbox-close:hover {
    background: var(--error);
    border-color: var(--error);
}

.lightbox-close svg {
    width: 24px;
    height: 24px;
}

/* Loading placeholder */
.result-loading {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    animation: pulse 2s infinite;
}

.result-loading .spinner {
    display: block;
    position: static;
    transform: none;
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.result-loading span {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .nav-tabs {
        gap: 0.25rem;
    }

    .nav-tab {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    .generate-section {
        padding: 0;
    }

    .prompt-card,
    .negative-prompt-card,
    .option-card,
    .advanced-card {
        border-radius: var(--radius-md);
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .aspect-buttons {
        justify-content: center;
    }

    .generate-btn {
        font-size: 1.125rem;
        padding: 1rem 1.5rem;
    }

    .results-gallery {
        grid-template-columns: 1fr;
    }
}
