/* Visualizer 2D Overhaul Styles (Linecraft) */

:root {
    --viz-primary: #8B7355;
    --viz-text: #222;
    --viz-text-muted: #888;
    --viz-border: rgba(0, 0, 0, 0.1);
    --viz-bg-pill: rgba(34, 34, 34, 0.85);
    --viz-blue: #007AFF;
}

/* Layout Overhaul - Boxed Version */
.lc-visualizer-main-wrap {
    padding: 60px 0;
    background: #fff;
    overflow-x: clip;
}

.viz-container-wide {
    width: 100%;
    max-width: 1720px;
    margin: 0 auto;
    padding: 0 40px;
    box-sizing: border-box;
}

.viz-page-header {
    text-align: center;
    margin-bottom: 40px;
}

.viz-page-title {
    font-size: clamp(28px, 4vw, 42px);
    letter-spacing: -1px;
}

.viz-page-title__muted {
    color: #444;
    font-weight: 300;
    opacity: 0.7;
}

.viz-page-title__strong {
    color: #2D3E50;
    font-weight: 800;
}

.viz-container-boxed {
    position: relative;
    width: 100%;
    max-width: calc((100vh - 120px) * 16 / 9);
    margin: 0 auto;
    aspect-ratio: 16 / 9;
    border-radius: 40px;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.15);
    background: #000;
    overflow: hidden;
    color: var(--viz-text);
    font-family: 'Outfit', 'Inter', sans-serif;
}

@media (max-width: 768px) {
    .viz-container-boxed {
        border-radius: 20px;
        aspect-ratio: 4 / 3;
        max-height: 70vh;
    }
}

@media (max-width: 480px) {
    .viz-container-boxed {
        border-radius: 12px;
        aspect-ratio: 3 / 4;
        /* Hoặc 1/1 tùy bạn chọn */
        max-height: 60vh;
    }
}

/* Welcome Overlay */
.viz-welcome-overlay {
    position: absolute;
    inset: 0;
    z-index: 110;
    background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)),
        url('../../img/CabinetVisualizer-Background.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.viz-welcome-overlay.is-hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(1.1);
}

.viz-welcome-content {
    text-align: center;
    color: #fff;
    max-width: 920px;
    padding: 20px;
}

.viz-welcome-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    color: #fff;
    line-height: 1;
}

.viz-welcome-sub {
    font-size: clamp(20px, 3vw, 26px);
    font-weight: 300;
    margin-bottom: 5px;
    opacity: 0.9;
    letter-spacing: 1px;
    transform: translateX(-78px);
}

.viz-welcome-title--coming-soon {
    margin-bottom: 0;
}

.viz-welcome-sub--coming-soon {
    font-size: clamp(20px, 3vw, 26px);
    font-weight: 300;
    margin-bottom: 5px;
    opacity: 0.9;
    letter-spacing: 1px;
    text-transform: uppercase;
    transform: translateX(-78px);
}

.viz-welcome-actions--coming-soon {
    margin-top: 34px;
    display: flex;
    justify-content: center;
}

.viz-welcome-actions--coming-soon {
    margin-top: 34px;
    display: flex;
    justify-content: center;
}

.viz-welcome-actions--coming-soon {
    margin-top: 34px;
    display: flex;
    justify-content: center;
}

.viz-welcome-main {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: clamp(15px, 2.5vw, 30px);
    font-size: clamp(50px, 9vw, 96px);
    font-weight: 800;
    letter-spacing: -2px;
    text-transform: uppercase;
}

.viz-welcome-main img {
    height: clamp(50px, 8.5vw, 90px);
    width: auto;
    filter: brightness(0) invert(1);
    object-fit: contain;
}

.viz-welcome-main .viz-welcome-logo {
    height: clamp(52px, 9vw, 94px);
    width: auto;
    filter: none;
    display: block;
    margin: 0 auto;
}

.viz-welcome-main--logos {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    width: fit-content;
    max-width: min(92vw, 561px);
    align-items: center;
    column-gap: clamp(14px, 1.8vw, 24px);
    margin: 0 auto;
    transform: translateX(1%);
}

.viz-welcome-main .viz-welcome-logo--brand {
    width: clamp(84px, 9vw, 97px);
    height: auto !important;
    margin: 0;
}

.viz-welcome-right-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: clamp(6px, 1vw, 12px);
    padding-top: 0;
    justify-self: start;
    width: auto;
}

.viz-welcome-main .viz-welcome-logo--visualizer {
    width: clamp(150px, 21vw, 280px);
    max-width: 100%;
    height: auto !important;
    margin: 0;
}

.viz-welcome-main .viz-welcome-logo--brand-alt {
    width: min(100%, 640px);
    max-width: 100%;
    height: auto !important;
    margin: 0;
    transform: none;
}

.viz-welcome-desc {
    font-size: clamp(14px, 2vw, 18px);
    font-weight: 400;
    letter-spacing: 12px;
    margin-top: 15px;
    opacity: 0.8;
    text-indent: 12px;
}

@media (max-width: 600px) {
    .viz-welcome-main--logos {
        width: fit-content;
        max-width: min(96%, 520px);
        column-gap: 10px;
        transform: none;
    }

    .viz-welcome-main .viz-welcome-logo--brand {
        width: clamp(56px, 13vw, 80px);
    }

    .viz-welcome-right-stack {
        align-items: flex-start;
        gap: 6px;
        padding-top: 0;
    }

    .viz-welcome-main .viz-welcome-logo--visualizer {
        width: clamp(120px, 34vw, 180px);
    }

    .viz-welcome-main .viz-welcome-logo--brand-alt {
        width: min(100%, 320px);
    }
}

.viz-btn-primary {
    background: #2D3E50;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 20px 60px;
    border-radius: 100px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);

    /* 3D Depth Effect: Light at corners */
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.3),
        inset 4px 4px 10px rgba(255, 255, 255, 0.1),
        /* Top-left light */
        inset -4px -4px 10px rgba(0, 0, 0, 0.2);
    /* Bottom-right shadow */

    text-transform: capitalize;
    animation: viz-btn-glow 4s infinite alternate;
}

.viz-btn-primary--home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 42px;
    padding: 5px 20px;
    font-size: 14px;
    line-height: 1;
    text-decoration: none;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.26),
        inset 3px 3px 8px rgba(255, 255, 255, 0.08),
        inset -3px -3px 8px rgba(0, 0, 0, 0.18);
}

.viz-btn-primary--home .viz-btn-primary__muted {
    color: rgba(255, 255, 255, 0.68);
    font-weight: 400;
}

.viz-btn-primary--home .viz-btn-primary__strong {
    color: #fff;
    font-weight: 700;
}

@keyframes viz-btn-glow {
    0% {
        border-color: rgba(255, 255, 255, 0.15);
    }

    100% {
        border-color: rgba(255, 255, 255, 0.45);
    }
}

/* Shimmer Sheen Effect */
.viz-btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 60%;
    height: 100%;
    background: linear-gradient(to right,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.3) 50%,
            rgba(255, 255, 255, 0) 100%);
    transform: skewX(-25deg);
    transition: none;
    animation: viz-shimmer 3s infinite;
}

@keyframes viz-shimmer {
    0% {
        left: -150%;
    }

    30% {
        left: 150%;
    }

    100% {
        left: 150%;
    }
}

.viz-btn-primary:hover {
    background: #3d546d;
    /* Lighter, more premium blue than black */
    transform: translateY(-5px) scale(1.05);
    border-color: #fff;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(255, 255, 255, 0.2),
        inset 6px 6px 15px rgba(255, 255, 255, 0.15);
}

.viz-btn-primary:hover::before {
    animation-duration: 1.5s;
}

/* Modal: Initial Selection */
.viz-modal {
    position: absolute;
    inset: 0;
    z-index: 105;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(30px);
    /* Intensive blur as per Figma */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.viz-modal.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.viz-modal__content {
    background: rgba(40, 40, 40, 0.4);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 60px;
    border-radius: 40px;
    text-align: center;
    max-width: 800px;
    width: 90%;
    color: #fff;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5);
}

.viz-modal__title {
    font-size: 38px;
    margin-bottom: 50px;
    font-weight: 500;
}

.viz-layout-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.viz-layout-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 50px 20px;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.4s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.viz-layout-card:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(255, 255, 255, 0.1);
}

.viz-layout-card:hover .viz-layout-icon {
    color: #fff;
}

.viz-layout-card:hover .viz-layout-label {
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.viz-layout-icon {
    width: 140px;
    height: 140px;
    color: #55585C;
}

.viz-layout-label {
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Main Stage */
.viz-stage-overhaul {
    position: absolute;
    inset: 0;
    transition: opacity 0.5s ease;
}

.viz-stage-overhaul.is-hidden {
    opacity: 0;
}

.viz-2d-canvas-wrap {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);

    /* Ensure child stage stays 16:9 and COVERS the container */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* The Fixed-Aspect Stage */
#viz-panzoom-target {
    position: relative;
    aspect-ratio: 16 / 9;
    flex-shrink: 0;
}

/* Cover logic for the stage */
@media (min-aspect-ratio: 16/9) {
    #viz-panzoom-target {
        width: 100%;
        height: auto;
    }
}

@media (max-aspect-ratio: 16/9) {
    #viz-panzoom-target {
        height: 100%;
        width: auto;
    }
}

.viz-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    /* We handle ratio via parent stage */
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Hotspots */
#viz-hotspots-container {
    position: absolute;
    inset: 0;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
}

#viz-hotspots-container.is-visible {
    opacity: 1;
    visibility: visible;
}

.viz-hotspot {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 50;
    text-align: center;
    pointer-events: none;
}

.viz-hotspot__trigger-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.viz-hotspot__btn {
    width: 44px;
    height: 44px;
    background: rgba(34, 34, 34, 0.8);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    position: relative;
}

.viz-hotspot__btn::after {
    content: '';
    position: absolute;
    inset: -3px;
    border: 2px solid #fff;
    border-radius: 50%;
    animation: viz-pulse 2s infinite;
}

@keyframes viz-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

.viz-hotspot.is-active {
    z-index: 1000;
}

.viz-hotspot.is-active .viz-hotspot__btn {
    background: var(--viz-primary);
    transform: scale(0.9);
}

.viz-hotspot__label {
    background: rgba(34, 34, 34, 0.6);
    color: #fff;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

@media (max-width: 768px) {
    .viz-hotspot__label {
        display: none !important;
    }
}

.viz-hotspot.is-active .viz-hotspot__label {
    opacity: 0;
}

/* Rich Dropdown/Popover */
.viz-hotspot__menu {
    position: absolute;
    bottom: calc(100% + 15px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);

    /* REFINED: Use a narrower clamp to follow container size better */
    width: clamp(230px, 80%, 320px);
    max-width: 90vw;

    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 18px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    padding: clamp(10px, 2.5%, 18px);

    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 60;
    pointer-events: auto;
}

.viz-hotspot.is-active .viz-hotspot__menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/*
 * Portaled to document.body in JS (see visualizer-2d.js). Not a descendant of .viz-hotspot.is-active,
 * so visibility/opacity must be set here. position:fixed under #viz-panzoom-target would use the wrong
 * containing block (transform from Panzoom).
 */
.viz-hotspot__menu.viz-menu--fixed {
    position: fixed !important;
    z-index: 10001 !important;
    bottom: auto !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    width: min(320px, 90vw) !important;
    max-width: 90vw !important;
}

/* Flipped state (when menu collides with top) */
.viz-hotspot.is-flipped .viz-hotspot__menu {
    bottom: auto;
    top: calc(100% + 20px);
    transform: translateX(-50%) translateY(-15px);
}

.viz-hotspot.is-flipped.is-active .viz-hotspot__menu {
    transform: translateX(-50%) translateY(0);
}

.viz-menu__list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.viz-menu-item {
    display: flex;
    align-items: center;
    gap: clamp(8px, 2%, 14px);
    padding: clamp(6px, 1.5%, 10px) clamp(8px, 2%, 14px);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    overflow: hidden;
    /* Prevent text spill */
}

.viz-menu-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

.viz-menu-item.is-selected {
    background: rgba(0, 122, 255, 0.05);
    border-color: var(--viz-blue);
}

.viz-menu-item__swatch {
    width: clamp(30px, 12%, 44px);
    height: clamp(30px, 12%, 44px);
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.viz-menu-item__info {
    text-align: left;
    min-width: 0;
    /* Critical for shrinking flex items */
    flex: 1;
}

.viz-menu-item__title {
    font-weight: 600;
    font-size: clamp(13px, 3%, 15px);
    display: block;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viz-menu-item__desc {
    font-size: clamp(10px, 2.5%, 12px);
    color: var(--viz-text-muted);
    line-height: 1.3;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Floating Bottom Toolbar (Pill) */
.viz-bottom-toolbar {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    /* Lower than Hotspots (50) to allow menus to overlap */
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
    width: auto;
    max-width: 90vw;
}

@media (max-width: 600px) {
    .viz-bottom-toolbar {
        bottom: 15px;
    }
}

.viz-bottom-toolbar.is-visible {
    opacity: 1;
    visibility: visible;
}

.viz-toolbar-pill {
    background: var(--viz-bg-pill);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    height: 60px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    gap: 2px;
}

@media (max-width: 600px) {
    .viz-toolbar-pill {
        height: 50px;
        padding: 0 12px;
    }

    .viz-toolbar-btn span {
        display: none;
    }

    .viz-toolbar-btn {
        width: 36px;
        height: 36px;
        padding: 0;
    }

    .viz-toolbar__divider {
        margin: 0 4px !important;
    }
}

.viz-toolbar__section {
    display: flex;
    align-items: center;
    gap: 4px;
}

.viz-toolbar__divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 12px;
}

.viz-toolbar-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viz-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.viz-shape-btn.is-active {
    background: #fff;
    color: #000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.viz-tool-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 40px;
}

/* Loading Overlay */
.viz-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 80;
    backdrop-filter: blur(5px);
}

.viz-loading-overlay.is-hidden {
    opacity: 0;
    visibility: hidden;
}

.viz-spinner-box {
    text-align: center;
}

.viz-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--viz-primary);
    border-radius: 50%;
    animation: viz-spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes viz-spin {
    to {
        transform: rotate(360deg);
    }
}

.viz-loading__text {
    font-size: 14px;
    font-weight: 500;
    color: var(--viz-primary);
}


/* Responsive */
@media (max-width: 900px) {
    .viz-container-wide {
        padding: 0 20px;
    }

    .viz-layout-grid {
        gap: 20px;
    }

    .viz-modal__content {
        padding: 40px 20px;
    }

    .viz-layout-card {
        padding: 20px;
    }

    .viz-layout-icon {
        width: 80px;
        height: 80px;
    }

    /* Width is now handled by clamp() above */
}

@media (max-width: 600px) {
    .viz-container-wide {
        padding: 0 12px;
    }
}

/* Extra small mobile fix */
@media (max-width: 375px) {
    /* Handled by clamp() */
}

@media (max-width: 600px) {
    .viz-modal__content {
        width: 95%;
        padding: 30px 15px;
    }

    .viz-modal__title {
        font-size: 24px;
        margin-bottom: 30px;
    }

    .viz-layout-grid {
        gap: 15px;
    }

    .viz-layout-card {
        padding: 15px 10px;
    }

    .viz-layout-icon {
        width: 60px;
        height: 60px;
    }
}