:root {
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #8b5cf6;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    color: var(--text-main);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    padding: 2rem 5%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: #e2e8f0;
}

.container {
    display: flex;
    flex: 1;
    gap: 2rem;
    padding: 2rem 5%;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.5);
}

.control-panel, .editor-panel {
    flex: 0 0 350px;
}

.editor-panel {
    margin-top: 1.5rem;
}

.dimension-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.dimension-item span {
    color: var(--text-main);
    font-size: 0.95rem;
    flex: 1;
}

.dimension-item input {
    width: 100px;
    padding: 0.5rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: white;
    text-align: right;
    font-family: monospace;
}

.dimension-item input:focus {
    border-color: var(--primary);
    background: rgba(255,255,255,0.1);
}

.dimension-item input.changed {
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.1);
}

.visualizations {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.viz-panel {
    flex: 1;
    min-height: 350px;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.02);
    position: relative;
    overflow: hidden;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.upload-area input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-area p {
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.preview-thumb {
    width: 100%;
    border-radius: 8px;
    margin-top: 1rem;
    display: none;
}

.settings {
    margin: 1.5rem 0;
}

.settings label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

select, input[type="text"], input[type="number"] {
    padding: 0.8rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

select:focus, input[type="text"]:focus, input[type="number"]:focus {
    border-color: var(--primary);
}

button {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Loading State */
#loading {
    margin-top: 2rem;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Results section */
#results-info {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

pre {
    background: rgba(0,0,0,0.3);
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #a78bfa;
    max-height: 200px;
    overflow-y: auto;
    margin: 1rem 0;
}

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

.btn {
    display: inline-block;
    padding: 0.8rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: white;
    text-align: center;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--primary);
}

/* Visualization containers */
.viz-container {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255,255,255,0.05);
}

.viz-container p {
    color: var(--text-muted);
}

.viz-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Responsive */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }
    .control-panel, .editor-panel {
        flex: none;
    }
}

/* 3D Viewer Toolbar */
.viewer-toolbar {
    display: flex;
    gap: 0.5rem;
    background: rgba(15, 23, 42, 0.6);
    padding: 0.4rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.viewer-toolbar button {
    width: 32px;
    height: 32px;
    padding: 0;
    margin: 0;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid transparent;
    border-radius: 6px;
    color: white;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: pointer;
}

.viewer-toolbar button:hover {
    background: rgba(59, 130, 246, 0.4);
    border-color: rgba(59, 130, 246, 0.8);
    transform: translateY(-1px);
}

.viewer-toolbar button:active {
    transform: translateY(1px);
}

/* Fullscreen Styles for Viz Container */
.viz-container:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    background: #000;
    border: none;
    border-radius: 0;
}
.viz-container:fullscreen {
    width: 100vw;
    height: 100vh;
    background: #000;
    border: none;
    border-radius: 0;
}
