:root {
    --primary: #7c5ced;
    --primary-glow: rgba(124, 92, 237, 0.4);
    --secondary: #d4af37;
    --success: #10b981;
    --bg-main: #f8fafc;
    --bg-white: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-glass: rgba(124, 92, 237, 0.08);
    --radius-xl: 32px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --sidebar-width: 320px;
    --trans: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@font-face { font-family: 'RTA'; src: url('assets/rta.ttf'); font-weight: 400; }

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'RTA', sans-serif; }
body { background: var(--bg-main); color: var(--text-main); height: 100vh; overflow: hidden; }

.hidden { display: none !important; }

/* Backdrop */
.luxury-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.15; animation: orbit 20s infinite alternate; }
.orb-1 { width: 600px; height: 600px; background: var(--primary); top: -10%; right: -10%; }
.orb-2 { width: 500px; height: 500px; background: var(--secondary); bottom: -10%; left: -10%; animation-delay: -5s; }
@keyframes orbit { from { transform: translate(0,0); } to { transform: translate(100px, 100px); } }

/* App Core */
.app-shell { display: flex; height: 100vh; width: 100vw; }

/* Sidebar */
.app-sidebar { 
    width: var(--sidebar-width); background: var(--bg-white); border-left: 1px solid var(--border-glass); 
    display: flex; flex-direction: column; padding: 2.5rem 1.5rem; box-shadow: -10px 0 60px rgba(0,0,0,0.02); z-index: 100;
}
.sidebar-header { margin-bottom: 3rem; }
.brand-centered { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 1rem; }
.brand-logo-clean { width: 64px; height: auto; }
.brand-title { font-size: 1.2rem; color: var(--text-main); font-weight: 700; line-height: 1.4; }
.sidebar-main { flex: 1; }
.sidebar-footer { margin-top: auto; }

/* Sidebar Sections */
.sidebar-section {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.section-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 1rem;
    font-weight: 700;
}

.scenario-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.scenario-btn {
    aspect-ratio: 1;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.scenario-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.scenario-btn.active {
    background: linear-gradient(135deg, #7c4dff, #448aff);
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(124, 77, 255, 0.4);
}

.app-select {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 15px;
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
}

/* Result Viewer */
.result-viewer {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    gap: 2rem;
}

.main-canvas {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.final-photo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.final-photo.loaded {
    opacity: 1;
}

.image-skeleton {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    display: none;
}

.image-skeleton.active {
    display: block;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.result-actions {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 1.5rem;
    text-align: center;
}

.result-actions h3 {
    margin-bottom: 0.5rem;
    color: #448aff;
}

.result-actions p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

/* Buttons */
.action-btn { 
    width: 100%; padding: 1.2rem; border-radius: var(--radius-md); border: none; cursor: pointer; 
    display: flex; align-items: center; gap: 12px; font-size: 1rem; transition: var(--trans); font-weight: 500;
}
.action-btn.primary { background: linear-gradient(135deg, var(--primary), #977afe); color: white; box-shadow: 0 10px 25px rgba(124,92,237,0.2); }
.action-btn.success { background: var(--success); color: white; box-shadow: 0 10px 25px rgba(16,185,129,0.15); }
.action-btn.outline { background: transparent; border: 1.5px solid #e2e8f0; color: var(--text-main); }
.action-btn:hover { transform: translateY(-3px); box-shadow: 0 15px 35px rgba(0,0,0,0.08); }
.action-large { padding: 1.5rem !important; font-size: 1.1rem !important; }

/* Main Content */
.app-content { flex: 1; position: relative; background: rgba(248, 250, 252, 0.5); backdrop-filter: blur(10px); }
/* Main Content Management */
.content-view { display: none; padding: 2.5rem; height: 100%; flex-direction: column; overflow-y: auto; }
.content-view.active { display: flex; animation: viewIn 0.4s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.action-compact { height: 44px; padding: 0 18px; font-size: 0.95rem; border-radius: var(--radius-md); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.text-danger { background: rgba(239, 68, 68, 0.05); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.2); }
.text-danger:hover { background: #ef4444; color: white; transform: translateY(-2px); }

/* Unified Workflow (Ready Stage) */
.ready-workflow { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 1200px; margin: 0 auto; }
.ready-header { margin-bottom: 2rem; text-align: center; }
.ready-header h2 { font-size: 1.6rem; color: var(--text-main); font-weight: 700; }
.ready-header p { font-size: 0.95rem; color: var(--text-muted); }

.preview-grid { 
    display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1.2rem; 
    width: 100%; transition: all 0.3s ease;
}

/* Zero State Styling */
.zero-state-container { 
    grid-column: 1 / -1; min-height: 420px; background: #ffffff; border-radius: var(--radius-xl); 
    border: 3px dashed #e2e8f0; display: flex; flex-direction: column; align-items: center; 
    justify-content: center; text-align: center; padding: 2.5rem; transition: var(--trans);
    box-shadow: 0 10px 40px rgba(0,0,0,0.02);
}
.zero-state-container:hover { border-color: var(--primary); background: rgba(255,255,255,0.8); }
.zero-card-placeholder { 
    width: 100px; height: 100px; border-radius: var(--radius-lg); border: 2px dashed var(--primary);
    display: flex; align-items: center; justify-content: center; font-size: 2.5rem; color: var(--primary);
    margin-bottom: 2rem; background: var(--primary-glow); animation: float 3s infinite ease-in-out;
}
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } }
.zero-title { font-size: 1.6rem; color: var(--text-main); margin-bottom: 1rem; font-weight: 700; }
.zero-desc { color: var(--text-muted); max-width: 320px; line-height: 1.6; margin-bottom: 2rem; font-size: 1rem; }
.zero-btn { padding: 12px 30px; background: var(--primary); color: white; border-radius: 50px; border: none; cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 10px; box-shadow: 0 10px 20px var(--primary-glow); transition: var(--trans); }
.zero-btn:hover { transform: translateY(-3px); box-shadow: 0 15px 30px var(--primary-glow); }

.ready-thumb { aspect-ratio: 1; border-radius: var(--radius-md); overflow: hidden; position: relative; transition: var(--trans); border: 1px solid #f1f5f9; box-shadow: 0 4px 10px rgba(0,0,0,0.02); }
.ready-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ready-thumb:hover { transform: scale(1.05); border-color: var(--primary); box-shadow: 0 15px 30px rgba(0,0,0,0.08); }
.ready-remove { 
    position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; background: #ef4444; 
    color: white; border: none; border-radius: 50%; opacity: 0; transition: var(--trans); cursor: pointer; z-index: 10;
}
.ready-thumb:hover .ready-remove { opacity: 1; }
.add-more-card { 
    border: 3px dashed #e2e8f0; display: flex; flex-direction: column; align-items: center; 
    justify-content: center; font-size: 2rem; color: var(--text-muted); cursor: pointer; transition: var(--trans); 
}
.add-more-card:hover { border-color: var(--primary); color: var(--primary); background: var(--bg-main); }

/* Processing Center */
.processing-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.orb-loader { width: 120px; height: 120px; position: relative; display: flex; align-items: center; justify-content: center; }
.orb-spinner { position: absolute; inset: 0; border: 4px solid var(--border-glass); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s infinite linear; }
.orb-loader i { font-size: 3rem; color: var(--primary); }
.processing-progress { width: 100%; max-width: 350px; margin-top: 2.5rem; }
.progress-bar { height: 6px; background: #eaedf1; border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: var(--primary); transition: width 0.3s ease; }

/* Results Dashboard */
.dashboard-results { display: flex; flex-direction: column; height: 100%; gap: 1.5rem; }
.main-viewer { flex: 1; background: #000; border-radius: var(--radius-lg); position: relative; overflow: hidden; }
.split-view { width: 100%; height: 100%; position: relative; user-select: none; }
.view-item { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; pointer-events: none; }
.view-mask { position: absolute; inset: 0; z-index: 10; clip-path: inset(0 50% 0 0); }
.slider-handle { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: white; z-index: 20; transform: translateX(-50%); cursor: ew-resize; }
.handle-icon { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 44px; height: 44px; border-radius: 50%; background: var(--primary); border: 4px solid white; display: flex; align-items: center; justify-content: center; gap: 4px; color: white; box-shadow: 0 10px 20px rgba(0,0,0,0.2); }

.selection-gallery { background: white; padding: 1.5rem; border-radius: var(--radius-lg); width: 100%; max-width: 100%; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.gallery-label { font-size: 0.9rem; margin-bottom: 1rem; font-weight: 500; opacity: 0.8; }
.gallery-track { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 15px; scrollbar-width: thin; scrollbar-color: var(--primary) #f1f5f9; }
.gallery-track::-webkit-scrollbar { height: 6px; }
.gallery-track::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }
.gallery-track::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 10px; }
.res-item { min-width: 140px; height: 100px; border-radius: var(--radius-md); overflow: hidden; cursor: pointer; border: 3px solid transparent; transition: var(--trans); position: relative; }
.res-item.active { border-color: var(--primary); transform: translateY(-4px); }
.res-item img { width: 100%; height: 100%; object-fit: cover; transition: var(--trans); }
.res-item::after { 
    content: ''; position: absolute; inset: 0; 
    background: rgba(0,0,0,0.15); transition: var(--trans); z-index: 5; 
}
.res-item:hover img { transform: scale(1.1); }
.res-item:hover::after { background: rgba(0,0,0,0.3); }

.res-download-btn { 
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); 
    width: 42px; height: 42px; background: rgba(16, 185, 129, 0.95); color: white; 
    border: 2px solid white; border-radius: 50%; display: flex; align-items: center; 
    justify-content: center; z-index: 10; cursor: pointer; transition: var(--trans);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3); font-size: 1.2rem;
}
.res-download-btn:hover { transform: translate(-50%, -50%) scale(1.15) rotate(-10deg); background: var(--success); }

@media (max-width: 1000px) {
    .app-shell { flex-direction: column-reverse; }
    .app-sidebar { 
        width: 100%; height: auto; padding: 1rem; position: fixed; bottom: 0; left: 0; right: 0;
        border-top: 1px solid var(--border-glass); z-index: 1000;
        background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(20px);
    }
    .brand, .sidebar-main { display: none !important; }
    .sidebar-footer { 
        display: flex !important; gap: 10px; width: 100%; 
        padding: 0 !important; margin: 0 !important;
    }
    .nav-group { flex: 1; margin: 0 !important; }
    .nav-group.hidden { display: none !important; }
    .action-large { padding: 12px; font-size: 0.9rem; border-radius: var(--radius-md); }
    
    .app-content { padding-bottom: 90px; }
    .content-view { padding: 1.5rem; }
}

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
