/* Modern Simulation CSS - Glassmorphism & Premium Feel */
@import url('https://fonts.googleapis.com/css2?family=Rationale&family=Inter:wght@400;600;700&display=swap');

body {
    margin: 0;
    overflow: hidden;
    background-color: #000;
    font-family: 'Inter', sans-serif;
    color: white;
}

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

/* --- Floating Personalization Panel (Right Side) --- */
#personalization-section {
    position: fixed;
    top: 100px;
    /* Below header */
    right: 20px;
    width: 320px;
    height: calc(100vh - 240px);
    /* Leave space for bottom palette */
    background: rgba(15, 15, 20, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.personalization-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Scrollbar Styling */
.personalization-content::-webkit-scrollbar {
    width: 6px;
}

.personalization-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.personalization-content::-webkit-scrollbar-thumb {
    background: rgba(255, 57, 63, 0.5);
    border-radius: 3px;
}

/* Category Headers */
.part-category-title {
    font-family: 'Rationale', sans-serif;
    font-size: 18px;
    color: #FF393F;
    text-transform: uppercase;
    margin: 25px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255, 57, 63, 0.3);
    letter-spacing: 1px;
}

.part-category-title:first-child {
    margin-top: 0;
}

/* Part Buttons Stack */
#all-parts-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Individual Part Buttons */
.part-button {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 15px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    color: #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.part-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateX(5px);
    color: white;
}

.part-button.selected {
    background: linear-gradient(90deg, rgba(255, 57, 63, 0.2), rgba(255, 57, 63, 0.1));
    border-color: #FF393F;
    color: white;
    box-shadow: 0 0 15px rgba(255, 57, 63, 0.2);
}

.part-button.selected::after {
    content: '\f058';
    /* FontAwesome Check Circle */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    color: #FF393F;
}

/* --- Color Palette (Bottom Fixed) --- */
#color-palette-bottom {
    display: none;
    /* JS controls visibility */
    width: 100%;
    position: absolute;
    bottom: 0;
    z-index: 200;

    /* User Glass Styles */
    background: rgba(15, 15, 20, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 19px;
}

#color-palette-title {
    font-family: 'Rationale', sans-serif;
    font-size: 18px;
    color: #FF393F;
    text-transform: uppercase;
    margin: 10px 0 0 0;
    padding-bottom: 5px;
    letter-spacing: 1px;
    width: 100%;
    text-align: center;
}

/* Toggle Category Button */
.category-toggle-btn {
    position: fixed;
    top: 85px;
    /* Aligned near top center UI */
    right: 20px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 57, 63, 0.3);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(5px);
}

.category-toggle-btn:hover {
    background: rgba(255, 57, 63, 0.8);
    transform: scale(1.1);
}

.category-toggle-btn.active {
    background: #FF393F;
    box-shadow: 0 0 15px rgba(255, 57, 63, 0.4);
}

.print-fab-btn {
    position: fixed;
    top: 135px;
    /* Below Category Toggle */
    right: 20px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(5px);
}

.print-fab-btn:hover {
    background: #28a745;
    /* Green for print/success */
    border-color: #28a745;
    transform: scale(1.1);
}

.custom-color-palette {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    width: 100%;
    align-items: flex-start;
    padding: 20px 30px;
    /* More padding */
    scrollbar-width: none;
    -ms-overflow-style: none;
    justify-content: center;
    /* Center items */
}

.custom-color-palette::-webkit-scrollbar {
    display: none;
}

/* Color Swatches */
.colorButtonDiv {
    flex: 0 0 30px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
}

.colorButtonDiv:hover {
    transform: scale(1.2);
    border-color: white;
    z-index: 10;
}

.colorButtonDiv.selected,
.colorButton.selected {
    transform: scale(1.3);
    border-color: #FF393F;
    box-shadow: 0 0 15px rgba(255, 57, 63, 0.5);
    z-index: 10;
}

/* Wrappers Visibility Helpers */
#colors-content,
.preview,
.parts,
.part-tabs {
    display: block !important;
    width: 100%;
}


svg.colorButton {
    width: 100%;
    height: 100%;
    display: block;
}

/* Close/Collapse Buttons (Optional) */
.colors-close-btn {
    display: none;
    /* Hide for this design, we keep it persistent */
}

/* --- Overlay/Modals (Reused from Index) --- */
#boat-info-overlay {
    backdrop-filter: blur(10px);
}

/* --- Sim Header Overrides --- */
/* Ensure header doesn't conflict */
.sim-header {
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent);
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px), (max-height: 500px) and (orientation: landscape) {
    #personalization-section {
        width: 100%;
        height: 40%;
        top: auto;
        bottom: 110px;
        /* Above color palette */
        right: 0;
        left: 0;
        border-radius: 20px 20px 0 0;
        border-bottom: none;
    }

    #color-palette-bottom {
        bottom: 0px;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        padding: 0 15px;
        padding-bottom: 19px;
    }

    /* Adjust floating buttons for taller header (110px) on mobile */
    .category-toggle-btn {
        top: 125px;
        /* 110px header + 15px gap */
    }

    .print-fab-btn {
        top: 175px;
        /* 125px + 40px btn + 10px gap */
    }
}


.fab-btn-main {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    /* Reduced from 80px */
    height: 60px;
    border-radius: 50%;
    background: #FF393F;
    color: white;
    border: none;
    /* Material Shadows (Elevation 6) */
    box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2),
        0 6px 10px 0 rgba(0, 0, 0, 0.14),
        0 1px 18px 0 rgba(0, 0, 0, 0.12);
    font-size: 24px;
    /* Standard Icon Size */
    z-index: 2147483647;
    cursor: pointer;
    display: flex !important;
    visibility: hidden;
    /* Start hidden, show via JS after load */
    opacity: 0;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
}

.fab-btn-main:hover {
    transform: scale(1.05);
    background: #ff5c61;
    /* Elevation 12 */
    box-shadow: 0 7px 8px -4px rgba(0, 0, 0, 0.2),
        0 12px 17px 2px rgba(0, 0, 0, 0.14),
        0 5px 22px 4px rgba(0, 0, 0, 0.12);
}

/* Menu Container - Translucid Aqua */
#personalization-menu-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 350px;
    height: 100vh;
    /* Aqua Glass */
    background: rgba(0, 40, 50, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 9999;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.4);
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(0, 255, 255, 0.1);
    /* Subtle aqua border */
}

#personalization-menu-container.open {
    transform: translateX(0);
}

/* Views Wrapper */
#personalization-views-wrapper {
    position: relative;
    flex: 1;
    overflow: hidden;
    width: 100%;
}

/* Views */
.menu-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease-in-out;
    padding: 20px;
    padding-top: 80px;
    /* Increased top padding for header space */
    padding-bottom: 100px;
    /* Ensure last item is visible above FAB/Bottom */
    overflow-y: auto;
    /* inherit transparency */
    background: transparent;
    box-sizing: border-box;
    /* Maintain width with padding */
}

.active-view {
    transform: translateX(0);
    z-index: 2;
}

.next-view {
    transform: translateX(100%);
    z-index: 1;
}

.prev-view {
    transform: translateX(-100%);
    z-index: 0;
}

/* Close Button */
.menu-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 24px;
    cursor: pointer;
    z-index: 100;
    transition: color 0.2s;
}

.menu-close-btn:hover {
    color: #FF393F;
}

/* Titles */
.menu-title {
    font-family: 'Rationale', sans-serif;
    font-size: 24px;
    color: #FF393F;
    text-transform: uppercase;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 57, 63, 0.3);
    text-shadow: 0 0 10px rgba(255, 57, 63, 0.3);
}

/* Back Button */
.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.back-btn {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

#color-selector-title {
    margin: 0;
    font-size: 14px;
    color: #ccc;
    text-transform: uppercase;
    text-align: right;
    flex: 1;
}

/* Part Button Styling Overrides */
.part-button {
    /* Compact Part Code */
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 6px;
    /* Spacing */
    padding: 10px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.part-button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
}

.part-button .part-name {
    flex: 1;
    margin: 0 10px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    /* Smaller Font */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #ddd;
}

.part-color-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background-color: transparent;
    /* Placeholder */
    flex-shrink: 0;
    overflow: hidden;
}

/* Color Palette Grid Layout Override */
/* Must be !important to override sim2.css or inline styles */
.custom-color-palette {
    display: flex !important;
    align-items: flex-start !important;
    flex-wrap: wrap !important;
    /* Wrap to new lines */
    justify-content: center !important;
    /* Center grid */
    gap: 20px !important;
    /* Bigger separation */
    padding: 10px !important;
    overflow-x: hidden !important;
    /* No horizontal scroll */
    width: 100% !important;
}

/* Palette Buttons */
.colorButtonDiv,
.colorButton {
    width: 40px !important;
    /* Slightly larger targets */
    height: 40px !important;
    margin: 0 !important;
    /* Reset margin, use gap */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);

    /* Fix for small GIF textures */
    background-repeat: repeat !important;
    background-size: auto !important;
    background-position: center !important;
}

@media (max-width: 768px) {
    #personalization-menu-container {
        width: 100%;
    }
}

/* Hide Old Category Toggle */
#btn-toggle-categories {
    display: none !important;
}