/* Premium Design System */
:root {
    --bg-deep: #0a0b10;
    --bg-panel: rgba(20, 22, 30, 0.7);
    --accent-primary: #6366f1;
    --accent-secondary: #a855f7;
    --accent-vibrant: #ec4899;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg-deep);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.15) 0%, transparent 40%);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Toolbar */
.toolbar {
    height: 60px;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Main Layout */
.main-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 320px;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 50;
}

.right-sidebar {
    border-right: none;
    border-left: 1px solid var(--glass-border);
}

.panel-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
}

.panel-header h2 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

/* Transform Groups */
.transform-group {
    margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.transform-group h3 {
    font-size: 0.9rem;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.input-row label {
    width: 25px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

input[type="range"] {
    flex: 1;
    accent-color: var(--accent-primary);
}

.num-input {
    width: 60px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 4px;
    border-radius: 4px;
    font-size: 0.8rem;
    text-align: center;
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 30px 30px;
}

.viewport-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 10;
}

.canvas-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
    cursor: grab;
}

.canvas-wrapper:active {
    cursor: grabbing;
}

/* 3D Target */
.scene {
    width: 200px;
    height: 200px;
    transform-style: preserve-3d;
    transition: var(--transition-smooth);
}

.target-element {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
}

.face {
    position: absolute;
    width: 200px;
    height: 200px;
    background: rgba(99, 102, 241, 0.2);
    border: 2px solid var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    backdrop-filter: blur(4px);
    box-shadow: inset 0 0 40px rgba(99, 102, 241, 0.3);
}

.front  { transform: translateZ(100px); }
.back   { transform: rotateY(180deg) translateZ(100px); }
.right  { transform: rotateY(90deg) translateZ(100px); }
.left   { transform: rotateY(-90deg) translateZ(100px); }
.top    { transform: rotateX(90deg) translateZ(100px); }
.bottom { transform: rotateX(-90deg) translateZ(100px); }

/* Other Shapes */
.shape-square .face { border-radius: 0; }
.shape-circle .face { border-radius: 50%; }
.shape-square .face:not(.front),
.shape-circle .face:not(.front) { display: none; }

/* Timeline */
.timeline-controls {
    height: 120px;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--glass-border);
    padding: 15px 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.playback-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.timeline-bar {
    height: 40px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    position: relative;
    border: 1px solid var(--glass-border);
}

.timeline-track {
    position: absolute;
    top: 50%;
    left: 20px;
    right: 20px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-50%);
    border-radius: 2px;
}

.keyframe-marker {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    background: var(--accent-primary);
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.keyframe-marker.active {
    background: var(--accent-vibrant);
    box-shadow: 0 0 15px var(--accent-vibrant);
    transform: translate(-50%, -50%) scale(1.3);
}

/* AI Magic Section */
.ai-magic {
    margin-top: 20px;
    padding: 15px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.1));
    border-radius: 12px;
    border: 1px solid var(--accent-primary);
}

.ai-magic h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    resize: none;
    margin-bottom: 10px;
}

.btn-magic {
    width: 100%;
    padding: 10px;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-magic:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
}

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

/* Buttons */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-primary:hover {
    background: var(--accent-secondary);
}

/* Utilities */
.hidden { display: none !important; }
.mt-10 { margin-top: 10px; }
.w-100 { width: 100%; }

/* Code Editor */
.code-editor {
    position: relative;
    background: #1e1e2e;
    border-radius: 12px;
    padding: 15px;
    margin-top: 15px;
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    border: 1px solid var(--glass-border);
}

.code-editor pre {
    overflow-x: auto;
}

.btn-copy {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 5px;
    border-radius: 4px;
    cursor: pointer;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-deep);
    border: 1px solid var(--glass-border);
    padding: 30px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: var(--shadow-premium);
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 900px) {
    body {
        height: auto;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .app-container {
        height: auto;
    }
    
    .toolbar {
        height: auto;
        flex-direction: column;
        padding: 15px;
        gap: 15px;
        align-items: center;
        text-align: center;
    }
    
    .toolbar-section.tools {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .toolbar-section.tools .divider {
        display: none;
    }
    
    .main-workspace {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-left: none;
        border-bottom: 1px solid var(--glass-border);
    }
    
    .canvas-area {
        min-height: 450px;
        order: -1; /* Keep canvas on top so they see the result of changes first */
        border-bottom: 1px solid var(--glass-border);
    }
    
    .timeline-controls {
        padding: 15px 15px;
        height: auto;
        gap: 10px;
    }
    
    .playback-buttons {
        flex-wrap: wrap;
        gap: 8px;
    }
}
