/* ===== CSS Variables ===== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --accent: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #0f172a;
    --light: #f8fafc;
    --gray: #64748b;
    --light-gray: #e2e8f0;
    --border: #cbd5e1;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
}

/* ===== Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--light);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Premium Header ===== */
.premium-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--light-gray);
}

.header-left {
    flex: 1;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
}

.header-center {
    flex: 2;
    display: flex;
    justify-content: center;
}

.model-header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.model-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-tag {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.header-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.purchase-header-btn {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.purchase-header-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.menu-btn {
    background: var(--light);
    color: var(--dark);
    width: 42px;
    height: 42px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
}

.menu-btn:hover {
    background: var(--primary);
    color: white;
}

.btn-text {
    display: inline;
}

/* ===== Viewer Layout ===== */
.viewer-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    margin-top: 70px;
    min-height: calc(100vh - 70px);
    background: white;
}

/* ===== Canvas Wrapper ===== */
.canvas-wrapper {
    position: relative;
    width: 100%;
    height: calc(100vh - 70px);
    background: var(--light);
    overflow: hidden;
}

#canvas-container {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 250, 252, 0.98);
    backdrop-filter: blur(20px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.3s ease;
}

.loading-content {
    text-align: center;
    padding: 2rem;
}

.premium-loader {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 2rem;
}

.loader-circle {
    position: absolute;
    border: 3px solid transparent;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

.loader-circle:nth-child(1) {
    width: 100%;
    height: 100%;
    animation-duration: 1.5s;
}

.loader-circle:nth-child(2) {
    width: 75%;
    height: 75%;
    top: 12.5%;
    left: 12.5%;
    border-top-color: var(--secondary);
    animation-duration: 1s;
    animation-direction: reverse;
}

.loader-circle:nth-child(3) {
    width: 50%;
    height: 50%;
    top: 25%;
    left: 25%;
    border-top-color: var(--accent);
    animation-duration: 0.75s;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-content h3 {
    font-size: 1.5rem;
    color: var(--dark);
    margin-bottom: 1.5rem;
    font-weight: 700;
}

.progress-container {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--light-gray);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
}

@keyframes indeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

.progress-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

/* ===== Floating Controls ===== */
.floating-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: var(--shadow-xl);
    z-index: 50;
    border: 1px solid var(--light-gray);
}

.control-group-left,
.control-group-right {
    display: flex;
    gap: 8px;
}

.control-group-center {
    display: flex;
    gap: 8px;
    padding: 0 1rem;
    border-left: 1px solid var(--light-gray);
    border-right: 1px solid var(--light-gray);
}

.float-btn {
    width: 42px;
    height: 42px;
    border: none;
    background: var(--light);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--dark);
    transition: all 0.3s;
}

.float-btn.large {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
}

.float-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

.float-btn.active {
    background: var(--primary);
    color: white;
}

/* ===== Model Info Badge ===== */
.model-info-badge {
    position: absolute;
    bottom: 30px;
    left: 30px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 0.75rem 1.25rem;
    border-radius: 50px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 50;
    border: 1px solid var(--light-gray);
}

.badge-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--dark);
    font-weight: 500;
}

.badge-item i {
    color: var(--primary);
}

.badge-divider {
    width: 1px;
    height: 20px;
    background: var(--light-gray);
}

/* ===== Side Panel ===== */
.side-panel {
    background: white;
    border-left: 1px solid var(--light-gray);
    height: calc(100vh - 70px);
    overflow-y: auto;
    position: sticky;
    top: 70px;
    z-index: 50;
}

.panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--light);
    position: sticky;
    top: 0;
    z-index: 10;
}

.panel-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--gray);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.close-btn:hover {
    background: var(--light-gray);
    color: var(--dark);
}

.panel-body {
    padding: 1.5rem;
}

/* ===== Preview Card ===== */
.preview-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    color: white;
}

.preview-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.preview-info h4 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.preview-info p {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* ===== Info Grid ===== */
.info-grid {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.info-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--light);
    border-radius: var(--radius-sm);
    transition: all 0.3s;
}

.info-card:hover {
    background: #f1f5f9;
    transform: translateX(5px);
}

.info-icon-box {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.info-icon-box.success {
    background: linear-gradient(135deg, var(--success), #059669);
}

.info-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 0.75rem;
    color: var(--gray);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.info-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--dark);
}

.info-value.success {
    color: var(--success);
}

/* ===== Purchase Section ===== */
.purchase-section {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 2px solid var(--success);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.purchase-section h4 {
    font-size: 1.05rem;
    color: var(--dark);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.purchase-desc {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 1rem;
}

.purchase-btn-large {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.purchase-btn-large:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* ===== Controls Section ===== */
.controls-section {
    margin-bottom: 1.5rem;
}

.controls-section h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.85rem 0.5rem;
    background: var(--light);
    border: 2px solid var(--light-gray);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--dark);
}

.control-btn i {
    font-size: 1.2rem;
    color: var(--primary);
}

.control-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.control-btn:hover i {
    color: white;
}

.control-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.control-btn.active i {
    color: white;
}

/* ===== Speed Control ===== */
.speed-control {
    background: var(--light);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
}

.speed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.speed-header label {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.speed-header #speedValue {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
}

.speed-control input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--light-gray);
    border-radius: 10px;
    outline: none;
    -webkit-appearance: none;
}

.speed-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

/* ===== Back Button ===== */
.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 700;
    transition: all 0.3s;
    box-shadow: var(--shadow);
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ===== Mobile Controls (Compact) ===== */
.mobile-controls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    padding: 0.75rem 1rem;
    z-index: 90;
    border-top: 1px solid var(--light-gray);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}

.mobile-controls-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 0.5rem;
    max-width: 500px;
    margin: 0 auto;
}

.mobile-btn {
    width: 48px;
    height: 48px;
    border: none;
    background: var(--light);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--dark);
    transition: all 0.3s;
    flex-shrink: 0;
}

.mobile-btn:hover,
.mobile-btn:active {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

.mobile-btn.active {
    background: var(--primary);
    color: white;
}

.purchase-btn-mobile {
    background: linear-gradient(135deg, var(--success), #059669) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* ===== Panel Overlay ===== */
.panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.panel-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===== No Select ===== */
.no-select {
    user-select: none;
    -webkit-user-select: none;
}

/* ===== Responsive: Tablet ===== */
@media (max-width: 1024px) {
    .viewer-layout {
        grid-template-columns: 1fr 320px;
    }
    
    .model-title {
        max-width: 200px;
    }
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 768px) {
    .premium-header {
        padding: 0 1rem;
        height: 60px;
    }
    
    .logo {
        font-size: 1.2rem;
    }
    
    .header-center {
        display: none;
    }
    
    .header-right {
        gap: 0.5rem;
    }
    
    .purchase-header-btn .btn-text {
        display: none;
    }
    
    .purchase-header-btn {
        padding: 0.6rem;
        width: 42px;
        height: 42px;
        justify-content: center;
    }
    
    .viewer-layout {
        grid-template-columns: 1fr;
        margin-top: 60px;
    }
    
    .canvas-wrapper {
        height: calc(100vh - 60px - 70px);
        width: 100%;
    }
    
    #canvas-container {
        width: 100vw;
        height: 100%;
    }
    
    .side-panel {
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        max-width: 350px;
        height: 100vh;
        z-index: 999;
        transition: right 0.3s ease;
        border-left: none;
        box-shadow: -5px 0 30px rgba(0,0,0,0.2);
        margin-top: 0;
    }
    
    .side-panel.open {
        right: 0;
    }
    
    .close-btn {
        display: flex;
    }
    
    .floating-controls {
        display: none;
    }
    
    .model-info-badge {
        display: none;
    }
    
    .mobile-controls {
        display: block;
    }
    
    .panel-overlay {
        z-index: 998;
    }
}

/* ===== Responsive: Small Mobile ===== */
@media (max-width: 480px) {
    .premium-header {
        padding: 0 0.75rem;
    }
    
    .logo span {
        display: none;
    }
    
    .canvas-wrapper {
        height: calc(100vh - 60px - 65px);
    }
    
    .mobile-controls {
        padding: 0.6rem 0.75rem;
    }
    
    .mobile-btn {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }
    
    .mobile-controls-inner {
        gap: 0.4rem;
    }
}

/* ===== Fullscreen Mode ===== */
.canvas-wrapper:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
}

/* ===== Scrollbar Styling ===== */
.side-panel::-webkit-scrollbar {
    width: 6px;
}

.side-panel::-webkit-scrollbar-track {
    background: var(--light);
}

.side-panel::-webkit-scrollbar-thumb {
    background: var(--light-gray);
    border-radius: 10px;
}

.side-panel::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.info-card, .control-btn {
    animation: fadeIn 0.4s ease;
}