/* ===================================
   3D Designer - Main Styles
   Mobile-First Design System
   =================================== */

/* CSS Variables - Design Tokens */
:root {
    /* Colors */
    --color-primary: hsl(220, 90%, 56%);
    --color-primary-dark: hsl(220, 90%, 46%);
    --color-secondary: hsl(280, 70%, 60%);
    --color-success: hsl(140, 70%, 50%);
    --color-danger: hsl(0, 70%, 55%);
    --color-warning: hsl(40, 90%, 55%);

    /* Backgrounds */
    --bg-primary: hsl(220, 15%, 12%);
    --bg-secondary: hsl(220, 15%, 16%);
    --bg-tertiary: hsl(220, 15%, 20%);
    --bg-surface: hsla(220, 15%, 20%, 0.8);
    --bg-overlay: hsla(0, 0%, 0%, 0.7);

    /* Text */
    --text-primary: hsl(0, 0%, 95%);
    --text-secondary: hsl(0, 0%, 70%);
    --text-muted: hsl(0, 0%, 50%);

    /* Borders */
    --border-color: hsla(220, 15%, 30%, 0.5);
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 12px;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Shadows */
    --shadow-sm: 0 2px 4px hsla(0, 0%, 0%, 0.2);
    --shadow-md: 0 4px 12px hsla(0, 0%, 0%, 0.3);
    --shadow-lg: 0 8px 24px hsla(0, 0%, 0%, 0.4);
    --shadow-glow: 0 0 20px hsla(220, 90%, 56%, 0.3);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Z-index layers */
    --z-base: 1;
    --z-panel: 10;
    --z-toolbar: 20;
    --z-modal: 100;
    --z-toast: 200;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    max-width: 300px;
}

.loading-logo {
    margin-bottom: var(--spacing-lg);
}

.logo-cube {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border-radius: var(--border-radius-lg);
    animation: cube-spin 2s ease-in-out infinite;
    box-shadow: var(--shadow-glow);
}

@keyframes cube-spin {

    0%,
    100% {
        transform: rotate(0deg) scale(1);
    }

    50% {
        transform: rotate(180deg) scale(1.1);
    }
}

.loading-content h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loading-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: var(--spacing-sm);
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: 2px;
    transition: width var(--transition-normal);
    width: 0%;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Main App Container */
.app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: opacity var(--transition-normal);
}

.app.hidden {
    display: none;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: var(--z-toolbar);
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.toolbar-center {
    flex: 1;
    justify-content: center;
}

.app-title {
    font-size: 1.125rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Button Styles */
.btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--border-radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    min-height: 44px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    background: var(--bg-surface);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-icon {
    padding: var(--spacing-sm);
    min-width: 44px;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.75rem;
    min-height: 32px;
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: var(--spacing-xs);
    background: var(--bg-primary);
    padding: var(--spacing-xs);
    border-radius: var(--border-radius);
}

.btn-group .btn {
    min-width: 44px;
}

.btn-group .btn.active {
    background: var(--color-primary);
    color: white;
}

.icon {
    font-size: 1.25rem;
    line-height: 1;
}

/* Main Content Layout */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Side Panels */
.side-panel {
    width: 300px;
    background: linear-gradient(135deg, hsla(220, 15%, 12%, 0.98) 0%, hsla(220, 15%, 8%, 0.98) 100%);
    background-image:
        radial-gradient(at 0% 0%, hsla(220, 90%, 56%, 0.05) 0, transparent 50%),
        radial-gradient(at 100% 100%, hsla(280, 70%, 60%, 0.05) 0, transparent 50%);
    backdrop-filter: blur(25px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: var(--z-panel);
    transition: transform var(--transition-normal), width var(--transition-normal);
    box-shadow: var(--shadow-lg);
}

.left-panel.slim-panel {
    width: 180px;
}

.right-panel {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.panel-header {
    display: flex;
    flex-direction: column;
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    background: hsla(220, 15%, 20%, 0.4);
    backdrop-filter: blur(10px);
}

.header-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.header-actions {
    display: flex;
    gap: var(--spacing-xs);
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.panel-toggle {
    background: white;
    border: none;
    color: var(--bg-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.panel-toggle:hover {
    background: var(--color-primary);
    color: white;
    transform: scale(1.1);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--spacing-md);
}

/* Custom Scrollbar */
.panel-content::-webkit-scrollbar {
    width: 8px;
}

.panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.panel-content::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* Shape Grid & Buttons */
.shape-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
    padding: var(--spacing-sm);
    transition: all var(--transition-normal);
}

/* Strip View Mode */
.shape-grid.strip-view {
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
}

.shape-grid.strip-view .shape-btn {
    flex-direction: row;
    padding: var(--spacing-sm);
    min-height: 50px;
    justify-content: flex-start;
    gap: var(--spacing-md);
}

.shape-grid.strip-view .shape-btn .shape-label {
    font-size: 0.875rem;
    font-weight: 500;
}

.shape-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    min-height: 100px;
    position: relative;
    overflow: hidden;
}

.shape-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.shape-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--color-primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.shape-btn:hover::before {
    opacity: 1;
}

.shape-btn:active {
    transform: translateY(-1px);
}

/* Shape Icons - Colorful & Informative */
.shape-icon-container {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--spacing-sm);
    position: relative;
    transition: transform var(--transition-normal);
}

.shape-grid.strip-view .shape-icon-container {
    width: 32px;
    height: 32px;
    margin-bottom: 0;
}

.shape-btn:hover .shape-icon-container {
    transform: scale(1.1) rotate(5deg);
}

/* CSS Icons */
.icon-cube {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    transform: rotateX(45deg) rotateZ(45deg);
    border-radius: 2px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}

.icon-sphere {
    width: 26px;
    height: 26px;
    background: radial-gradient(circle at 30% 30%, #ec4899, #be185d);
    border-radius: 50%;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
}

.icon-cylinder {
    width: 20px;
    height: 28px;
    background: linear-gradient(90deg, #10b981, #059669, #10b981);
    border-radius: 4px / 8px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}

.icon-cone {
    width: 0;
    height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-bottom: 28px solid #f59e0b;
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.3));
}

.icon-torus {
    width: 26px;
    height: 26px;
    border: 6px solid #8b5cf6;
    border-radius: 50%;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2), 2px 2px 5px rgba(0, 0, 0, 0.3);
}

.icon-plane {
    width: 30px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid var(--text-secondary);
    transform: perspective(100px) rotateX(45deg);
}

.icon-pyramid {
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 25px solid #ef4444;
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.3));
}

.icon-octahedron {
    width: 24px;
    height: 24px;
    background: #06b6d4;
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}

.icon-dodecahedron {
    width: 26px;
    height: 26px;
    background: #f97316;
    clip-path: polygon(50% 0%, 95% 35%, 80% 90%, 20% 90%, 5% 35%);
}

.icon-icosahedron {
    width: 26px;
    height: 26px;
    background: #6366f1;
    clip-path: polygon(50% 0%, 100% 30%, 80% 100%, 20% 100%, 0% 30%);
}

.shape-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: var(--spacing-xs);
}

.shape-container {
    scroll-snap-type: y mandatory;
    overflow-y: auto;
    scrollbar-width: thin;
}

.shape-btn {
    scroll-snap-align: start;
}

/* Specific Icon Backgrounds */
.cube .icon-cube {
    background: linear-gradient(135deg, #60a5fa, #2563eb);
}

.sphere .icon-sphere {
    background: radial-gradient(circle at 30% 30%, #f472b6, #db2777);
}

.cylinder .icon-cylinder {
    background: linear-gradient(90deg, #34d399, #059669, #34d399);
}

.cone .icon-cone {
    border-bottom-color: #fbbf24;
}

.torus .icon-torus {
    border-color: #a78bfa;
}

.pyramid .icon-pyramid {
    border-bottom-color: #f87171;
}

.octahedron .icon-octahedron {
    background: #22d3ee;
}

.dodecahedron .icon-dodecahedron {
    background: #fb923c;
}

.icosahedron .icon-icosahedron {
    background: #818cf8;
}

.shape-btn:hover .icon-cube {
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.5);
}

.shape-btn:hover .icon-sphere {
    box-shadow: 0 0 15px rgba(219, 39, 119, 0.5);
}

.shape-btn:hover .icon-cylinder {
    box-shadow: 0 0 15px rgba(5, 150, 105, 0.5);
}

.shape-btn:hover .icon-cone {
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.5));
}

.shape-btn:hover .icon-torus {
    box-shadow: 0 0 15px rgba(167, 139, 250, 0.5);
}

.shape-btn:hover .icon-pyramid {
    filter: drop-shadow(0 0 8px rgba(248, 113, 113, 0.5));
}

/* Viewport */
.viewport-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
}

.viewport {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.viewport-controls {
    position: absolute;
    bottom: var(--spacing-md);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: var(--spacing-md);
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
}

.view-buttons {
    display: flex;
    gap: var(--spacing-xs);
}

.view-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 36px;
}

.view-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.view-btn.active {
    background: var(--color-primary);
    color: white;
}

.viewport-info {
    display: flex;
    gap: var(--spacing-xs);
}

/* Properties Panel Sections */
.section {
    margin-bottom: var(--spacing-md);
    background: hsla(220, 15%, 20%, 0.5);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
}

.section:hover {
    background: hsla(220, 15%, 25%, 0.5);
    border-color: var(--color-primary);
}

.section h3 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.section h3::before {
    content: '';
    width: 4px;
    height: 12px;
    background: var(--color-primary);
    border-radius: 2px;
}

.property-group {
    margin-bottom: var(--spacing-md);
}

.property-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.input-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-xs);
}

.input-sm {
    padding: var(--spacing-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 100%;
}

.input-sm:focus {
    outline: none;
    border-color: var(--color-primary);
}

.color-input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-tertiary);
    cursor: pointer;
}

.slider {
    width: calc(100% - 50px);
    margin-right: var(--spacing-sm);
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Object List */
.object-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.object-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm);
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.object-item:hover {
    background: var(--bg-secondary);
}

.object-item.selected {
    border-color: var(--color-primary);
    background: var(--bg-secondary);
}

.object-name {
    font-size: 0.875rem;
    flex: 1;
}

.object-visibility {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-xs);
    font-size: 1rem;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: var(--spacing-lg);
}

/* Mobile Panel Toggles (Arrows) */
.mobile-panel-btn {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: white;
    border: none;
    color: var(--bg-primary);
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 100;
    transition: all var(--transition-normal);
    border-radius: 50%;
    box-shadow: var(--shadow-lg);
}

.mobile-left-btn {
    left: 10px;
}

.mobile-right-btn {
    right: 10px;
}

.mobile-panel-btn:hover {
    background: var(--color-primary);
    color: white;
    transform: translateY(-50%) scale(1.1);
}

.mobile-panel-btn.open.mobile-left-btn {
    left: 310px;
    /* sidebar width + margin */
}

.mobile-panel-btn.open.mobile-right-btn {
    right: 310px;
}

.mobile-panel-btn.open .arrow {
    transform: rotate(180deg);
}

.arrow {
    transition: transform var(--transition-normal);
    display: inline-block;
}

@media (max-width: 768px) {
    .mobile-panel-btn {
        display: flex;
    }

    /* Update open positions for mobile viewports */
    @media (max-width: 480px) {
        .mobile-panel-btn.open.mobile-left-btn {
            left: 85%;
            /* Matches mobile side-panel width */
        }

        .mobile-panel-btn.open.mobile-right-btn {
            right: 85%;
        }
    }
}

/* Viewport Overlays */
.viewport-overlay-top-right {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    z-index: 50;
}

.overlay-circle-btn {
    width: 44px;
    height: 44px;
    background: white;
    border: none;
    border-radius: 50%;
    color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
}

.overlay-circle-btn:hover {
    background: var(--color-primary);
    color: white;
    transform: scale(1.1);
}

.overlay-circle-btn:active {
    transform: scale(0.95);
}

.overlay-circle-btn .icon {
    font-size: 1.25rem;
}

/* Adjust mobile positions */
@media (max-width: 768px) {
    .viewport-overlay-top-right {
        top: var(--spacing-sm);
        right: var(--spacing-sm);
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive adjustments in mobile.css */