/* --- 1. IMPORTS & FONTS --- */
/* Loading these first ensures no font-popping */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700&family=Rajdhani:wght@400;500;600;700&display=swap');

/* --- 2. GLOBAL RESET & LAYOUT --- */
html {
    height: 100%;
    width: 100%;
    background-color: #000000;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; 
    background-color: #000000;
    font-family: Helvetica, arial, sans-serif;
    
    /* Lock body on mobile to prevent "bounce" */
    position: fixed; 
    top: 0;
    left: 0;
    
    -webkit-tap-highlight-color: transparent;
}

/* --- 3. CANVAS LAYOUT --- */
canvas {
    outline: none;
    display: block;
}

#application-canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 0; /* Sits at the bottom */
}

/* --- 4. UI CONTAINER LAYOUT --- */
/* This replaces the manual positioning we were doing in JS */
#ui-container {
    position: fixed; /* Stronger than absolute */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10; /* Sits on top of canvas */
    
    pointer-events: none; /* Allows clicking through to the 3D model */
    overflow: hidden; 
    user-select: none;
    
    font-family: 'Rajdhani', sans-serif;
    color: #e0e0ff; 
}

/* PlayCanvas Helper Classes (Preserved for safety) */
#application-canvas.fill-mode-NONE { margin: auto; }
#application-canvas.fill-mode-KEEP_ASPECT { width: 100%; height: auto; margin: 0; }
#application-canvas.fill-mode-FILL_WINDOW { width: 100%; height: 100%; margin: 0; }


/* --- 5. UI COMPONENT STYLES --- */

.sci-fi-grid {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-image: linear-gradient(rgba(0, 234, 255, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 234, 255, 0.05) 1px, transparent 1px);
    background-size: 3.125rem 3.125rem; background-position: center center; opacity: 0.2; z-index: -1;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 40%, rgba(0,0,0,0) 100%); pointer-events: none;
}

/* Header */
.app-header {
    position: absolute; top: 0; left: 0; width: 100%; height: 100px;
    display: flex; justify-content: center; align-items: center;
    background: linear-gradient(to bottom, rgba(10, 15, 30, 0.8) 0%, rgba(10, 15, 30, 0) 100%);
    z-index: 50; pointer-events: none; transition: all 0.5s ease;
}
.header-content { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; transform: translateY(-10px); }
.header-title { font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 2rem; color: #00eaff; letter-spacing: 0.15em; margin: 0; text-shadow: 0 0 15px rgba(0, 234, 255, 0.4); text-transform: uppercase; }
.tech-line-top { width: 200px; height: 1px; background: linear-gradient(90deg, transparent, rgba(0, 234, 255, 0.5), transparent); }
.tech-decoration { display: flex; align-items: center; gap: 0.5rem; opacity: 0.7; }
.dec-line { width: 40px; height: 1px; background: #00eaff; }
.dec-dot { width: 4px; height: 4px; background: #00eaff; transform: rotate(45deg); }

/* Control Deck */
.control-deck {
    position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 50rem;
    background: rgba(10, 15, 30, 0.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 234, 255, 0.2); border-left: 1px solid rgba(0, 234, 255, 0.1); border-right: 1px solid rgba(0, 234, 255, 0.1);
    border-radius: 1rem 1rem 0 0; box-shadow: 0 -0.5rem 2rem rgba(0,0,0,0.5);
    display: flex; flex-direction: column; pointer-events: auto; transition: all 0.4s ease;
}
.deck-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255, 255, 255, 0.1); background: rgba(0,0,0,0.2); height: 3.5rem; }
.tabs-container { display: flex; flex: 1; height: 100%; }
.tab-btn { flex: 1; background: transparent; border: none; padding: 0 1rem; font-family: 'Orbitron', sans-serif; font-size: 0.9rem; letter-spacing: 0.1rem; font-weight: 700; color: #8a9ba8; cursor: pointer; position: relative; transition: all 0.2s; height: 100%; }
.tab-btn.active { color: #00eaff; background: rgba(0, 234, 255, 0.05); }
.tab-btn.active::after { content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 2px; background: #00eaff; box-shadow: 0 -2px 10px #00eaff; }
.deck-toggle-btn { width: 3.5rem; height: 100%; background: transparent; border: none; border-left: 1px solid rgba(255,255,255,0.1); color: #8a9ba8; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; }
.deck-toggle-btn:hover { color: #00eaff; background: rgba(0,234,255,0.1); }
.control-deck.collapsed .deck-toggle-btn { transform: rotate(180deg); }
.deck-body { padding: 1rem 1.5rem; overflow-y: auto; overflow-x: hidden; max-height: 40vh; opacity: 1; transition: all 0.4s ease; scrollbar-width: thin; scrollbar-color: rgba(0, 234, 255, 0.3) transparent; }
.control-deck.collapsed .deck-body { max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; }
.view-section { display: none; animation: fadeIn 0.3s ease; } .view-section.active { display: block; }
.section-label { font-size: 0.75rem; color: #8a9ba8; font-family: 'Orbitron', sans-serif; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 0; }

/* Grids */
.parts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 2rem; }
.part-row { display: flex; flex-direction: column; gap: 0.25rem; }
.scroll-list { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.25rem; cursor: grab; scrollbar-width: none; }
.scroll-list::-webkit-scrollbar { display: none; }
.option-btn { flex: 0 0 auto; width: 4rem; height: 4rem; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 0.25rem; padding: 0.25rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.option-btn img { width: 100%; height: 100%; object-fit: contain; opacity: 0.6; pointer-events: none; }
.option-btn.active { border-color: #00eaff; background: rgba(0, 234, 255, 0.15); box-shadow: 0 0 10px rgba(0, 234, 255, 0.2); } .option-btn.active img { opacity: 1; }
.materials-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem 2rem; }
.mat-group { display: flex; flex-direction: column; gap: 0.25rem; }
.swatch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }

/* Gradients */
.swatch-btn { width: 100%; aspect-ratio: 1; border-radius: 0.25rem; border: 1px solid rgba(255,255,255,0.2); cursor: pointer; position: relative; transition: transform 0.2s; }
.swatch-btn.active { border: 2px solid white; box-shadow: 0 0 10px currentColor; z-index: 2; transform: scale(1.1); }
.finish-silver { background: linear-gradient(135deg, #f5f5f5, #a9a9a9); }
.finish-steel { background: linear-gradient(135deg, #a0a0a0, #303030); }
.finish-bronze { background: linear-gradient(135deg, #cd7f32, #5c3317); }
.finish-copper { background: linear-gradient(135deg, #ffb790, #804020); }
.finish-gold { background: linear-gradient(135deg, #fffacd, #b8860b); }
.finish-black { background: linear-gradient(135deg, #444444, #000000); }

/* Footer */
.deck-footer { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1.5rem; background: rgba(0, 0, 0, 0.2); border-top: 1px solid rgba(255,255,255,0.05); }
.price-tag { font-family: 'Orbitron', sans-serif; font-size: 1.1rem; color: #8a9ba8; }
.price-val { color: white; font-weight: 700; margin-left: 0.5rem; font-size: 1.3rem; }
.buy-btn { background: linear-gradient(90deg, #0066ff, #00c3ff); border: none; border-radius: 0.25rem; padding: 0 1.5rem; height: 2.5rem; color: white; font-family: 'Orbitron', sans-serif; font-weight: 600; font-size: 0.9rem; letter-spacing: 0.1rem; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; box-shadow: 0 0 1rem rgba(0, 153, 255, 0.4); transition: all 0.2s; }

/* Mobile */
@media (max-width: 600px) { .parts-grid { grid-template-columns: 1fr; gap: 0.75rem; } .materials-grid { grid-template-columns: 1fr; gap: 0.75rem; } .swatch-grid { grid-template-columns: repeat(6, 1fr); gap: 0.5rem; } .deck-body { max-height: 50vh; padding: 1rem; } .option-btn { width: 3.8rem; height: 3.8rem; } .app-header { height: 60px; opacity: 0; transform: translateY(-20px); } .header-title { font-size: 1.2rem; } .app-header.mobile-visible { opacity: 1; transform: translateY(0); } }

/* Modal */
.modal-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; z-index: 100; visibility: hidden; opacity: 0; pointer-events: none; transition: opacity 0.3s ease, visibility 0s 0.3s; font-family: 'Rajdhani', sans-serif; color: #e0e0ff; }
.modal-overlay.open { visibility: visible; opacity: 1; pointer-events: auto; transition: opacity 0.3s ease, visibility 0s 0s; }
.modal-card { width: 90%; max-width: 400px; background: rgba(10, 15, 30, 0.95); border: 1px solid rgba(0, 234, 255, 0.3); border-radius: 0.5rem; box-shadow: 0 0 2rem rgba(0, 234, 255, 0.15); display: flex; flex-direction: column; transform: translateY(20px); transition: transform 0.3s ease; }
.modal-overlay.open .modal-card { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.1); background: rgba(0,234,255,0.05); }
.modal-header h2 { margin: 0; font-family: 'Orbitron', sans-serif; font-size: 1rem; color: #00eaff; letter-spacing: 0.1em; }
.close-modal-btn { background: none; border: none; color: #8a9ba8; font-size: 1.5rem; cursor: pointer; }
.modal-body { padding: 1.5rem; }
.saber-preview-box { width: 100%; aspect-ratio: 4 / 1; background: #000; border-radius: 4px; border: 1px solid rgba(255,255,255,0.1); margin-bottom: 1.5rem; overflow: hidden; position: relative; }
.saber-preview-box img { width: 100%; height: 100%; object-fit: cover; }
.download-overlay-btn { position: absolute; bottom: 8px; right: 8px; width: 32px; height: 32px; background: rgba(0, 0, 0, 0.7); border: 1px solid rgba(255,255,255,0.3); border-radius: 4px; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; }
.download-overlay-btn:hover { background: #00eaff; color: black; border-color: #00eaff; }
.spec-list { display: flex; flex-direction: column; gap: 0.5rem; }
.spec-row { display: flex; justify-content: space-between; font-size: 0.9rem; }
.spec-label { color: #8a9ba8; font-weight: 600; font-size: 0.8rem; letter-spacing: 0.05em;}
.spec-val { color: white; text-align: right; }
.spec-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 0.5rem 0; }
.modal-footer { padding: 1.5rem; background: rgba(0,0,0,0.3); }
.total-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; font-family: 'Orbitron', sans-serif; font-size: 1.1rem; }
.final-price { color: #00eaff; font-weight: 700; font-size: 1.4rem; }
.modal-actions { display: flex; gap: 1rem; }
.modal-btn { flex: 1; padding: 0.8rem; border: none; border-radius: 4px; font-family: 'Rajdhani', sans-serif; font-weight: 700; cursor: pointer; font-size: 1rem; transition: all 0.2s; }
.secondary { background: transparent; border: 1px solid rgba(255,255,255,0.2); color: #8a9ba8; }
.secondary:hover { border-color: white; color: white; }
.primary { background: #00eaff; color: #000; }
.primary:hover { background: white; box-shadow: 0 0 15px rgba(0, 234, 255, 0.5); }