﻿/* ===== Model Studio Page ===== */
.page-model { animation: fadeIn 0.4s ease; }

.studio-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    min-height: calc(100vh - var(--topbar-height) - 80px);
}

/* Left Panel */
.studio-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: calc(100vh - var(--topbar-height) - 80px);
}

.panel-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Upload Area */
.upload-area {
    --upload-preview-height: 200px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    min-height: var(--upload-preview-height);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.upload-area:hover {
    border-color: var(--accent);
    background: rgba(233,30,99,0.04);
}

.upload-area.has-image {
    padding: 0;
    border-style: solid;
    display: block;
}

.upload-area.has-image img {
    width: 100%;
    height: var(--upload-preview-height);
    object-fit: contain;
    background: var(--bg-input);
    cursor: zoom-in;
}

.upload-replace-btn {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    height: 28px;
    min-width: 64px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.48);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
}

.upload-area.has-image .upload-replace-btn {
    display: inline-flex;
}

.upload-area.has-image .upload-input {
    inset: auto;
    top: 8px;
    right: 8px;
    width: 64px;
    height: 28px;
    z-index: 3;
}

.upload-icon {
    font-size: 32px;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.upload-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.upload-hint {
    font-size: 11px;
    color: var(--text-muted);
}

.upload-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Form Groups */
.form-section {
    margin-bottom: 20px;
}

.form-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 14px;
}

.api-tip {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    background: var(--bg-input);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* Radio/Checkbox Groups */
.option-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.option-btn {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12.5px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-secondary);
    transition: all var(--transition);
    cursor: pointer;
}

.option-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.option-btn.active {
    background: linear-gradient(135deg, rgba(233,30,99,0.15), rgba(124,77,255,0.1));
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 550;
}

/* Slider */
.slider-group {
    margin-bottom: 14px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.slider-value {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-input);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-glow);
}

/* Select */
.form-select {
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: all var(--transition);
}

.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Input */
.form-input {
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: all var(--transition);
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Textarea */
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    resize: vertical;
    min-height: 80px;
    transition: all var(--transition);
}

.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Generate Button */
.btn-generate {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    transition: all var(--transition);
    box-shadow: 0 4px 16px var(--accent-glow);
    margin-top: 8px;
}

.btn-generate:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-generate:disabled {
    opacity: 1;
    cursor: not-allowed;
    transform: none;
}

.studio-panel > .btn-generate {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin-top: auto;
    box-shadow: 0 -10px 20px rgba(0, 0, 0, 0.16), 0 4px 16px var(--accent-glow);
}

/* Right Preview Area */
.studio-preview {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.preview-title {
    font-size: 16px;
    font-weight: 600;
}

.preview-actions {
    display: flex;
    gap: 8px;
}

/* Result Grid */
.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
}

.result-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow);
}

.result-card.pending {
    border-style: dashed;
}

.result-image {
    height: 260px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
    position: relative;
}

.result-card.pending .result-image {
    background: linear-gradient(110deg, var(--bg-input) 20%, rgba(255,255,255,0.05) 40%, var(--bg-input) 60%);
    background-size: 200% 100%;
    animation: modelShimmer 1.2s linear infinite;
}

.result-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--bg-input);
    cursor: zoom-in;
}

.model-generating {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.model-gen-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.model-gen-text {
    font-size: 12px;
    color: var(--text-secondary);
}

.result-actions {
    padding: 10px;
    display: flex;
    gap: 6px;
    justify-content: center;
}

.result-actions .btn-sm {
    flex: 1;
    justify-content: center;
}

/* Model Library */
.model-library {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
}

.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.model-thumb {
    aspect-ratio: 3/4;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    padding: 8px;
    gap: 4px;
    position: relative;
    overflow: hidden;
}

.model-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    background: var(--bg-input);
    cursor: zoom-in;
    position: absolute;
    inset: 0;
    z-index: 0;
    display: block;
}

.model-thumb-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.5);
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
}

.model-thumb-delete:hover {
    background: rgba(198,40,40,0.9);
    border-color: rgba(255,255,255,0.8);
}

.model-thumb:hover {
    border-color: var(--accent);
}

.model-thumb-label {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 4px 6px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 11px;
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 1;
}

.model-lib-actions {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.model-lib-actions .btn {
    justify-content: center;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,10,15,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.loading-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.loading-progress {
    width: 200px;
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 2px;
    transition: width 0.3s ease;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes modelShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Collapsible Section */
.collapsible {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 550;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.collapsible-header:hover {
    color: var(--text-primary);
    background: var(--glass);
}

.collapsible-arrow {
    transition: transform var(--transition);
    font-size: 11px;
}

.collapsible.open .collapsible-arrow {
    transform: rotate(180deg);
}

.collapsible-body {
    padding: 0 14px;
    max-height: 0;
    overflow: hidden;
    transition: all var(--transition);
}

.collapsible.open .collapsible-body {
    padding: 0 14px 14px;
    max-height: 600px;
}

@media (max-width: 1080px) {
    .studio-layout {
        grid-template-columns: 1fr;
    }

    .studio-panel {
        max-height: none;
    }
}

@media (max-width: 640px) {
    .model-lib-actions {
        grid-template-columns: 1fr;
    }
}
