/* 23DFactory Global Design System */
:root {
    --bg-main: #060608;
    --bg-panel: rgba(13, 13, 18, 0.7);
    --bg-panel-hover: rgba(20, 20, 30, 0.85);
    --bg-card: rgba(22, 22, 33, 0.4);
    
    --primary: #9d4edd;
    --primary-glow: rgba(157, 78, 221, 0.5);
    --primary-light: #c77dff;
    
    --accent: #00f5ff;
    --accent-glow: rgba(0, 245, 255, 0.35);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #4b5563;
    
    --border: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(157, 78, 221, 0.2);
    
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --transition-smooth: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-fast: all 0.15s ease;
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(157, 78, 221, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(0, 245, 255, 0.1) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(6, 6, 8, 1) 0px, rgba(13, 13, 18, 0.9) 100%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* App Layout */
.app-container {
    display: grid;
    grid-template-rows: 70px 1fr;
    height: 100vh;
    width: 100vw;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    background: rgba(6, 6, 8, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    box-shadow: 0 0 15px var(--primary-glow);
}

.logo-text {
    font-size: 1.4rem;
    background: linear-gradient(to right, #ffffff, #c77dff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text span {
    font-weight: 300;
    color: var(--accent);
    -webkit-text-fill-color: var(--accent);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Main Area */
.main-workspace {
    display: grid;
    grid-template-columns: 420px 1fr;
    height: calc(100vh - 70px);
    overflow: hidden;
}

.sidebar {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-actions {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 5;
}

/* Content Area - Viewer */
.viewer-container {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, rgba(20, 20, 30, 0.4) 0%, rgba(6, 6, 8, 1) 100%);
    overflow: hidden;
}

/* Sidebar Sections & Tabs */
.tab-nav {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 0.25rem;
    border: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.6rem;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tab-btn.active {
    background: var(--primary);
    color: var(--text-main);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.tab-content {
    display: none;
    flex-direction: column;
    gap: 1.25rem;
}

.tab-content.active {
    display: flex;
    animation: fadeIn 0.4s ease;
}

/* Card layout */
.control-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: var(--transition-smooth);
}

.control-card:hover {
    border-color: var(--border-glow);
    box-shadow: 0 4px 20px rgba(157, 78, 221, 0.05);
}

.card-title {
    font-size: 1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

/* Inputs & Buttons */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.text-input {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: var(--transition-fast);
    outline: none;
    resize: none;
}

.text-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

/* Drag and Drop Zone */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    overflow: hidden;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: rgba(157, 78, 221, 0.05);
    box-shadow: 0 0 15px rgba(157, 78, 221, 0.1);
}

.dropzone-icon {
    font-size: 2rem;
    color: var(--primary-light);
    transition: var(--transition-smooth);
}

.dropzone:hover .dropzone-icon {
    transform: translateY(-4px);
    color: var(--accent);
}

.dropzone p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.dropzone input[type="file"] {
    display: none;
}

/* Image Preview in Drag and Drop */
.preview-container {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
    background: #0f0f14;
    display: none;
}

.preview-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.remove-preview {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
    transition: var(--transition-fast);
}

.remove-preview:hover {
    background: #ef4444;
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, var(--primary), #7b2cbf);
    color: var(--text-main);
    border: none;
    border-radius: 8px;
    padding: 0.8rem 1.5rem;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    box-shadow: 0 4px 15px rgba(157, 78, 221, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(157, 78, 221, 0.45);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background: var(--text-dark);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    box-shadow: none;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-muted);
    box-shadow: none;
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), #00b4d8);
    color: #060608;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(0, 245, 255, 0.25);
}

.btn-accent:hover {
    box-shadow: 0 6px 20px rgba(0, 245, 255, 0.4);
}

/* Sliders */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.range-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-light);
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: 0 0 8px var(--primary-glow);
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--accent);
}

/* Select element styling */
.custom-select {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-main);
    outline: none;
    font-family: var(--font-body);
}

.custom-select option {
    background: #121217;
    color: var(--text-main);
}

/* 3D Visualizer Area */
.viewer-display {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

model-viewer {
    width: 100%;
    height: 100%;
    background-color: transparent;
    --poster-color: transparent;
}

/* Visualizer overlay controls */
.viewer-overlay {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(13, 13, 18, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 0.5rem 1rem;
    display: flex;
    gap: 0.75rem;
    z-index: 10;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translate(-50%, 20px);
    transition: var(--transition-smooth);
    pointer-events: none;
}

.viewer-overlay.active {
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
}

.overlay-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.overlay-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.overlay-btn.active {
    color: var(--accent);
    background: rgba(0, 245, 255, 0.1);
}

/* Empty State / Prompt info */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    text-align: center;
    max-width: 400px;
    z-index: 2;
    animation: float 4s ease-in-out infinite;
}

.empty-state-icon {
    font-size: 4rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0.8;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: var(--text-main);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Generation Status overlay */
.status-overlay {
    position: absolute;
    inset: 0;
    background: rgba(6, 6, 8, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.status-overlay.active {
    display: flex;
    opacity: 1;
}

/* Cybernetic Loading Spinner */
.cyber-loader {
    position: relative;
    width: 120px;
    height: 120px;
}

.loader-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--primary);
    animation: spin 2s linear infinite;
}

.loader-ring:nth-child(2) {
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
    border-top-color: transparent;
    border-bottom-color: var(--accent);
    animation: spin-reverse 1.5s linear infinite;
}

.loader-ring:nth-child(3) {
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
    border-top-color: var(--primary-light);
    border-bottom-color: transparent;
    animation: spin 1s linear infinite;
}

.loader-text-pct {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.status-info {
    text-align: center;
    max-width: 350px;
}

.status-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.status-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Modal styling */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
}

/* Footer info */
.sidebar-footer {
    margin-top: auto;
    font-size: 0.75rem;
    color: var(--text-dark);
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.sidebar-footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition-fast);
}

.sidebar-footer a:hover {
    color: var(--accent);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes spin-reverse {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Gallery / Library Styling */
.gallery-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 450px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.gallery-list::-webkit-scrollbar {
    width: 4px;
}

.gallery-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.gallery-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: var(--transition-fast);
    animation: itemFadeIn 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) both;
}

@keyframes itemFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-glow);
    transform: translateX(2px);
}

.gallery-thumbnail {
    width: 46px;
    height: 46px;
    border-radius: 6px;
    background: #0f0f14;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.gallery-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-thumbnail i {
    color: var(--primary-light);
}

.gallery-info {
    flex: 1;
    min-width: 0; /* allows text truncation */
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.gallery-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-meta {
    font-size: 0.65rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.gallery-actions {
    display: flex;
    gap: 0.35rem;
}

.gallery-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.gallery-btn:hover {
    color: var(--bg-main);
    background: var(--accent);
    border-color: var(--accent);
}

.gallery-btn.delete-btn:hover {
    color: #ffffff;
    background: #ef4444;
    border-color: #ef4444;
}

.gallery-empty-state {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* Source Selector and Thumbnail Grid Styles */
.toggle-group {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.25rem;
    gap: 0.25rem;
}

.toggle-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.toggle-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.toggle-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.library-thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.library-thumb-item {
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.library-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.library-thumb-item:hover {
    border-color: var(--primary-light);
}

.library-thumb-item.active {
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

.library-thumb-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 1.5rem 0.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}
