/* Core Viewport Container - Fix for iOS Safari 100vh Bar */
html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

#v3d-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic Viewport Height for mobile browsers */
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Ensure canvas doesn't steal touches from UI */
#v3d-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ==========================================
   DESKTOP HORIZONTAL MENU BAR
   ========================================== */
.configurator-bar {
    position: absolute;
    bottom: calc(20px + env(safe-area-inset-bottom)); /* iOS Safe Area Protection */
    left: 50%;
    transform: translateX(-50%);
    width: 94%;
    max-width: 1280px;
    background: #ffffff;
    border: 1px solid #e2e2e2;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 52px;
    z-index: 1000; /* Ensured above WebGL canvas */
    pointer-events: auto; /* Force tap reception */
    box-sizing: border-box;
}

.brand-title {
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: #111111;
    text-transform: uppercase;
    padding-right: 20px;
    border-right: 1px solid #e8e8e8;
    white-space: nowrap;
}

.nav-dropdowns {
    display: flex;
    flex: 1;
    justify-content: space-around;
    height: 100%;
}

/* Custom Dropdown Container */
.dropdown-item {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.dropdown-trigger {
    background: none;
    border: none;
    font-size: 0.82rem;
    font-weight: 500;
    color: #333333;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    height: 100%;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.dropdown-trigger:hover {
    color: #000000;
}

.dropdown-trigger .arrow {
    font-size: 0.6rem;
    transition: transform 0.2s;
    color: #888;
}

.dropdown-item.open .dropdown-trigger .arrow {
    transform: rotate(180deg);
}

/* Dropdown Flyout Panel */
.dropdown-menu {
    display: none;
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    min-width: 220px;
    padding: 8px 0;
    z-index: 1100;
}

.dropdown-item.open .dropdown-menu {
    display: block;
}

/* Color Swatch Circle */
.swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.option-btn {
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    background: none;
    border: none;
    font-size: 0.82rem;
    color: #444444;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.option-btn:hover {
    background: #f5f5f5;
    color: #000000;
}

.option-btn.selected {
    font-weight: 600;
    color: #000000;
    background: #f8f8f8;
}

/* ==========================================
   DESKTOP RIGHT-HAND PRICE SUMMARY
   ========================================== */
.price-summary-container {
    position: relative;
    padding-left: 20px;
    border-left: 1px solid #e8e8e8;
    height: 100%;
    display: flex;
    align-items: center;
}

.price-breakdown-toggle {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    cursor: pointer;
    user-select: none;
}

.price-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #777;
}

.price-total {
    font-size: 0.92rem;
    font-weight: 700;
    color: #111;
}

.price-popover {
    display: none;
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 280px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 16px;
    z-index: 1200;
}

.price-summary-container:hover .price-popover {
    display: block;
}

.popover-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.itemized-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #444;
    margin-bottom: 6px;
}

.itemized-row .item-name {
    max-width: 190px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popover-footer {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid #eee;
    padding-top: 10px;
    margin-top: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #111;
}

/* ==========================================
   MOBILE & TABLET PORTRAIT BAR & DRAWER
   ========================================== */
.mobile-header {
    display: none;
    position: absolute;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    height: 48px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 2000;
    pointer-events: auto;
    box-sizing: border-box;
}

/* Wrapper to group Price + Hamburger together on the right */
.mobile-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-header-price {
    font-size: 0.88rem;
    font-weight: 700;
    color: #111111 !important;
    white-space: nowrap;
    line-height: 1;
}

.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mobile-drawer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: #ffffff;
    z-index: 9999; /* Tops all WebGL canvas elements */
    padding: 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-drawer.open {
    display: block;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.drawer-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #333;
    padding: 4px 10px;
    touch-action: manipulation;
}

.mobile-section {
    margin-bottom: 20px;
}

.mobile-section label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    margin-bottom: 8px;
}

.mobile-select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mobile-price-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.mobile-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    margin-top: 12px;
    color: #111;
}

/* RESPONSIVE MEDIA QUERIES - Extended Breakpoint to 1025px to catch iPads in Portrait */
@media (max-width: 1025px) or (orientation: portrait) {
    .configurator-bar {
        display: none !important;
    }
    .mobile-header {
        display: flex !important;
    }
}