/* ==========================================================================
   STL 3D Online Viewer - Modern Glassmorphism Stylesheet
   ========================================================================== */

:root {
    --bg-dark: #090d16;
    --bg-canvas: #0f172a;
    --panel-bg: rgba(15, 23, 42, 0.78);
    --panel-border: rgba(255, 255, 255, 0.1);
    --panel-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);

    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.35);

    --accent-cyan: #06b6d4;
    --accent-purple: #8b5cf6;
    --accent-amber: #f59e0b;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', Consolas, monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: var(--font-sans);
    color: var(--text-main);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   App Layout
   ========================================================================== */

#app-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* Top Navbar Header */
header {
    height: 58px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 50;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.logo-title {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, #fff, #93c5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    line-height: 1.2;
}

.logo-subtext {
    font-size: 10px;
    color: var(--text-dim);
    display: block;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Main Workspace */
#workspace {
    flex: 1;
    position: relative;
    display: flex;
    overflow: hidden;
}

#canvas-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* ==========================================================================
   Buttons & Controls UI
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
    border: none;
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), #0284c7);
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.5);
}

.btn-outline {
    border-color: rgba(59, 130, 246, 0.4);
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.08);
}

.btn-outline:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--primary);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-md);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* ==========================================================================
   Floating Panels (Glassmorphism)
   ========================================================================== */

.floating-panel {
    position: absolute;
    z-index: 10;
    background: var(--panel-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--panel-shadow);
    padding: 16px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Left Toolbar Panel */
#left-panel {
    top: 20px;
    left: 20px;
    width: 280px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Right Control & Analysis Panel */
#right-panel {
    top: 20px;
    right: 20px;
    width: 320px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Top View Control Toolbar */
#view-toolbar {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: 30px;
}

/* Section Header */
.panel-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Custom Scrollbar for Panels */
.floating-panel::-webkit-scrollbar, .modal-card::-webkit-scrollbar {
    width: 4px;
}
.floating-panel::-webkit-scrollbar-track, .modal-card::-webkit-scrollbar-track {
    background: transparent;
}
.floating-panel::-webkit-scrollbar-thumb, .modal-card::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Form Controls */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.control-label {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

select.control-input, input[type="text"].control-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

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

input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    background: transparent;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 2px solid var(--panel-border);
    border-radius: 50%;
}

/* Range Sliders */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 8px var(--primary-glow);
}

/* Checkbox Toggle Switch */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-muted);
}

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .3s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(18px);
}

/* Stat Key-Value Table */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 2px;
}

.stat-val {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-cyan);
}

/* Dimension Cards */
.dim-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.dim-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    padding: 6px 4px;
    text-align: center;
}

.dim-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 2px;
}

.tag-x { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.tag-y { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.tag-z { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }

/* Preset Model Cards */
.sample-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.sample-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    padding: 10px 4px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-main);
}

.sample-item:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.sample-item i {
    font-size: 18px;
    color: var(--accent-cyan);
    margin-bottom: 6px;
}

.sample-item span {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
}

/* Drag and Drop Overlay Overlay */
#drop-zone {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px dashed var(--primary);
    margin: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#drop-zone.drag-active {
    opacity: 1;
    pointer-events: auto;
}

.drop-icon {
    font-size: 64px;
    color: var(--accent-cyan);
    margin-bottom: 16px;
    animation: bounce 1.5s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

/* Loading Spinner */
#loading-spinner {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(9, 13, 22, 0.7);
    backdrop-filter: blur(6px);
    z-index: 90;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Measurement Floating Box */
#measure-info-box {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--accent-amber);
    padding: 10px 20px;
    border-radius: 30px;
    z-index: 20;
    display: none;
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.2);
}

.measure-text {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 15px;
    color: var(--accent-amber);
}

/* Color Presets Pill */
.color-picker-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.color-dot:hover {
    transform: scale(1.2);
}

.color-dot.active {
    border-color: #fff;
}

/* ==========================================================================
   SEO Modal Drawer & FAQ Article Styles
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(9, 13, 22, 0.75);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 680px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 30px;
    position: relative;
    box-shadow: 0 25px 50px rgba(0,0,0,0.6);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-main);
}

.seo-article {
    color: var(--text-main);
    line-height: 1.6;
}

.seo-article h2 {
    font-size: 20px;
    font-weight: 700;
    color: #93c5fd;
    margin-bottom: 12px;
}

.seo-lead {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.seo-article h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-cyan);
    margin: 20px 0 10px 0;
}

.seo-article ul {
    list-style: none;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.seo-article ul li {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.seo-article ul li strong {
    color: var(--text-main);
}

.faq-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.faq-item {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    padding: 12px;
}

.faq-item summary {
    cursor: pointer;
    outline: none;
}

.faq-item h4 {
    display: inline;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.faq-item p {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
    padding-left: 8px;
    border-left: 2px solid var(--primary);
}
