@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600&display=swap');

:root {
    --bg-color: #020617;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Background Gradients */
body::before {
    content: '';
    position: absolute;
    top: -10%;
    right: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

body::after {
    content: '';
    position: absolute;
    bottom: -10%;
    left: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

/* Layout */
header {
    padding: 2rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.logo {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
}

.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    vertical-align: middle;
    margin-left: 0.5rem;
    letter-spacing: normal;
    display: inline-block;
    -webkit-text-fill-color: #60a5fa; /* Override gradient text clip */
}

.badge.badge-editor {
    background: rgba(139, 92, 246, 0.15);
    color: #c084fc;
    border: 1px solid rgba(139, 92, 246, 0.3);
    -webkit-text-fill-color: #c084fc;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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


.main-container {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
    padding: 0 5% 2rem 5%;
    height: calc(100vh - 120px);
}

/* Model Viewer Container */
.viewer-wrapper {
    position: relative;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    backdrop-filter: blur(12px);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

model-viewer {
    width: 100%;
    height: 100%;
    --poster-color: transparent;
}

/* Sidebar Info */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
    overflow-y: auto;
    padding-right: 6px;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

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

.card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    flex-shrink: 0;
}

.model-info h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.model-info p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.gallery-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.gallery-container::-webkit-scrollbar {
    width: 4px;
}

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

.gallery-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: block;
}

.model-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.model-item {
    padding: 1rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.model-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--glass-border);
    transform: translateY(-2px);
}

.model-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-blue);
}

.model-thumb {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    background: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
}

.model-name {
    font-weight: 400;
    font-size: 0.9rem;
}

/* Hotspot styles */
.hotspot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background-color: var(--accent-purple);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.8), 0 0 20px rgba(139, 92, 246, 0.4);
    cursor: pointer;
    position: relative;
    transform: translate(-50%, -50%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    z-index: 100;
}

.hotspot:not(.active):hover {
    transform: translate(-50%, -50%) scale(1.3);
    background-color: #a78bfa;
}

.hotspot.active {
    z-index: 2000 !important;
}

/* Occluded hotspots (behind 3D geometry): transparent and non-clickable on all pages */
.hotspot:not([data-visible]) {
    opacity: 0.1 !important;
    pointer-events: none !important;
    transform: translate(-50%, -50%) scale(0.7) !important;
    transition: opacity 0.4s ease, transform 0.4s ease !important;
}

/* Ensure signboards for occluded hotspots remain hidden */
.hotspot:not([data-visible]) .signboard {
    display: none !important;
}

/* Hide hotspots smoothly when camera is outside their designated normal cone */
.hotspot.outside-cone {
    opacity: 0 !important;
    transform: translate(-50%, -50%) scale(0) !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

/* Fade out other hotspots when one is active to keep the active signboard prominent and clutter-free */
model-viewer:has(.hotspot.active) .hotspot:not(.active) {
    opacity: 0.15 !important;
    pointer-events: none;
}


.hotspot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--accent-purple);
    transform: translate(-50%, -50%);
    animation: pulse 2s infinite;
    z-index: -1;
}

@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

/* Signboard styles */
.signboard {
    position: absolute;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 15px;
    width: 320px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    color: white;
    bottom: calc(100% + 15px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.23, 1, 0.32, 1), transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
}

.signboard .lightbox-content {
    padding: 0;
}

.signboard.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* Render signboard below the hotspot if it is near the top of the viewport */
.signboard.render-below {
    bottom: auto;
    top: calc(100% + 15px);
    transform: translateX(-50%) translateY(-10px);
}

.signboard.render-below.active {
    transform: translateX(-50%) translateY(0);
}

.signboard.active:hover {
    transform: translateX(-50%) translateY(0) scale(1.05);
}

.signboard img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.signboard-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--accent-blue);
}

.signboard-text {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.close-btn:hover {
    opacity: 1;
}

/* Annotation Slot */
.annotation {
    pointer-events: none;
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 101;
}

/* Controls */
.controls-overlay {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    z-index: 5;
}

.btn-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

/* Coordinate Helper */
.coord-helper {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.helper-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.coord-output-wrapper {
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#coord-output {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    color: #60a5fa; /* Sleek blue */
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
    line-height: 1.4;
}

.btn-copy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.btn-copy:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.btn-copy:active {
    transform: scale(0.95);
}

.btn-copy.copied {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
    color: #34d399;
}

/* Temporary Hotspot Preview */
.hotspot.temp-hotspot {
    background-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.8), 0 0 20px rgba(59, 130, 246, 0.4);
}

.hotspot.temp-hotspot::after {
    background: var(--accent-blue);
}

/* Editor layout overrides are defined inline in editor.html
   to ensure correct cascade over these shared base styles. */


/* Responsive */
@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
        overflow-y: auto;
        height: auto;
    }
    
    .sidebar {
        height: auto;
    }
    
    body {
        overflow-y: auto;
    }
}

/* Lightbox Modal Styles */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(2, 6, 23, 0.75);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

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

.lightbox-card {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh; /* Prevent modal card from exceeding screen height */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
}

.lightbox-card-body {
    overflow-y: auto; /* Allow scrolling inside the card if contents exceed 90vh */
    flex: 1;
    display: flex;
    flex-direction: column;
}

.lightbox-overlay.active .lightbox-card {
    transform: scale(1) translateY(0);
}

.lightbox-card img {
    width: 100%;
    max-height: 50vh;
    object-fit: contain;
    background-color: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.lightbox-content {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.lightbox-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-blue);
    margin: 0;
}

.lightbox-content p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    color: white;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.05);
}

/* Multi-Image Lightbox Slider Navigation and Thumbnails */
.lightbox-thumbnails {
    position: absolute;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 3100;
    pointer-events: auto;
}

.lightbox-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.5;
}

.lightbox-thumb:hover {
    opacity: 0.8;
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.6);
}

.lightbox-thumb.active {
    opacity: 1;
    border-color: var(--accent-blue);
    box-shadow: 0 0 14px rgba(59, 130, 246, 0.6);
    transform: scale(1.1);
}

.lightbox-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 3100;
    pointer-events: auto;
}

.lightbox-nav-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-50%) scale(1.08);
    border-color: rgba(255, 255, 255, 0.35);
    color: #ffffff;
}

.lightbox-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.lightbox-nav-btn.prev-btn {
    left: 30px;
}

.lightbox-nav-btn.next-btn {
    right: 30px;
}

/* Responsive styles for lightbox slider elements */
@media (max-width: 768px) {
    .lightbox-nav-btn {
        width: 42px;
        height: 42px;
    }
    .lightbox-nav-btn.prev-btn {
        left: 15px;
    }
    .lightbox-nav-btn.next-btn {
        right: 15px;
    }
    .lightbox-thumbnails {
        top: 15px;
        gap: 8px;
    }
    .lightbox-thumb {
        width: 48px;
        height: 48px;
        border-radius: 8px;
    }
}

/* Push the card down when thumbnails are present to prevent overlap with even spacing */
.lightbox-overlay.has-thumbnails {
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 25px 0;
    overflow-y: auto;
}

.lightbox-overlay.has-thumbnails .lightbox-thumbnails {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    margin-bottom: 25px; /* Even spacing below thumbnails (25px) matching top padding */
}

.lightbox-overlay.has-thumbnails .lightbox-card {
    margin-top: 0;
    max-height: calc(100vh - 150px);
}

@media (max-width: 768px) {
    .lightbox-overlay.has-thumbnails {
        padding: 15px 0;
    }
    .lightbox-overlay.has-thumbnails .lightbox-thumbnails {
        margin-bottom: 15px; /* Even spacing below thumbnails (15px) matching top padding */
    }
    .lightbox-overlay.has-thumbnails .lightbox-card {
        max-height: calc(100vh - 100px);
    }
}

/* Premium Loader Styles */
.loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    pointer-events: auto;
}

.loader-overlay.hide {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.03);
}

.loader-container {
    width: 90%;
    max-width: 550px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    backdrop-filter: blur(12px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.loader-header {
    text-align: center;
}

.loader-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.loader-wait-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    margin-bottom: 0;
    animation: blink-slow 2s infinite ease-in-out;
}

@keyframes blink-slow {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.loader-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.loader-col {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.loader-col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.loader-col-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.loader-col-progress {
    font-size: 0.9rem;
    font-weight: 600;
}

#model-loader-progress {
    color: #3b82f6;
}

#space-loader-progress {
    color: #8b5cf6;
}

.loader-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.loader-bar-fill {
    width: 0%;
    height: 100%;
    border-radius: 10px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#model-loader-bar-fill {
    background: linear-gradient(90deg, #3b82f6 0%, #06b6d4 100%);
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}

#space-loader-bar-fill {
    background: linear-gradient(90deg, #8b5cf6 0%, #ec4899 100%);
    box-shadow: 0 0 12px rgba(236, 72, 153, 0.4);
}

.loader-col-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    margin-top: 0.1rem;
}

@media (max-width: 600px) {
    .loader-columns {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .loader-container {
        padding: 1.5rem;
    }
}
