/* Scene Configurator Styles */

/* Main Layout */
.configurator-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
    padding-top: 80px;
    /* Space for fixed navbar */
}

/* Scene Canvas Area (Left) */
.scene-canvas-container {
    flex-grow: 1;
    position: relative;
    background-color: #f0f0f0;
    overflow: hidden;
    /* Cursor indicates 3D interaction */
    cursor: grab;
}

.scene-canvas-container:active {
    cursor: grabbing;
}

/* Canvas element text */
canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Sidebar Area (Right) */
.product-sidebar {
    width: 350px;
    background: white;
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
    background: white;
}

.sidebar-header h2 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    margin-bottom: 15px;
}

/* Collection Tabs */
.collection-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.tab-btn {
    padding: 6px 12px;
    background: #f5f5f5;
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: #e0e0e0;
}

.tab-btn.active {
    background: var(--color-primary);
    color: white;
}

/* Product Grid */
.product-grid {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.product-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    /* Horizontal layout */
    align-items: center;
    min-height: 80px;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--color-primary);
}

.product-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    background: #f9f9f9;
    flex-shrink: 0;
}

.product-info {
    padding: 10px 15px;
    flex-grow: 1;
    overflow: hidden;
}

.product-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-meta {
    font-size: 0.75rem;
    color: #999;
}

/* Overlay UI Elements */
.scene-overlay-top {
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: none;
    /* Let clicks pass through to canvas */
    z-index: 5;
}

.scene-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-top: 10px;
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.8);
}

.back-link {
    pointer-events: auto;
    text-decoration: none;
    color: var(--color-text-main);
    font-weight: 500;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.8);
    padding: 5px 10px;
    border-radius: 4px;
}

.scene-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.5s;
    opacity: 0;
    pointer-events: none;
}

.scene-loader.active {
    opacity: 1;
    pointer-events: auto;
}

.interaction-hints {
    position: absolute;
    bottom: 20px;
    right: 20px;
    /* Bottom right of canvas */
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #666;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.hint-item {
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hint-item:last-child {
    margin-bottom: 0;
}

/* Floating Context Controls (Selected Item) */
.context-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    /* Top right of canvas */
    background: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 150px;
}

.selected-name {
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    text-align: center;
}

.control-actions {
    display: flex;
    justify-content: space-between;
    gap: 5px;
}

.control-actions button {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.control-actions button:hover {
    background: white;
    border-color: #ccc;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.btn-danger {
    color: #cc0000;
}

.btn-danger:hover {
    background: #cc0000 !important;
    color: white !important;
    border-color: #cc0000 !important;
}

/* Bottom Scene Controls */
.scene-controls-bottom {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 20;
}

.btn-outline-danger {
    background: white;
    border: 1px solid #cc0000;
    color: #cc0000;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-outline-danger:hover {
    background: #cc0000;
    color: white;
}

.btn-secondary {
    background: #666;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #444;
}

/* ============================================
   PREMIUM ICON BUTTON SYSTEM
   ============================================ */

/* Icon + Label button (e.g. "Undo", "View in AR") */
.btn-icon-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: rgba(255,255,255,0.95);
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 5px;
    color: #2a2a2a;
    font-size: 0.78rem;
    font-family: var(--font-heading, 'Cormorant Garamond', serif);
    font-weight: 500;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.12s;
    white-space: nowrap;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.btn-icon-label svg {
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity 0.15s;
}

.btn-icon-label:hover {
    background: rgba(255,255,255,1);
    border-color: rgba(0,0,0,0.22);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.btn-icon-label:hover svg {
    opacity: 1;
}

/* Icon-only button (e.g. fullscreen, floor arrows) */
.btn-icon-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    background: rgba(255,255,255,0.95);
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 5px;
    color: #2a2a2a;
    font-size: 0.7rem;
    font-family: var(--font-heading, 'Cormorant Garamond', serif);
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.12s;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    min-width: 32px;
}

.btn-icon-only:hover {
    background: rgba(255,255,255,1);
    border-color: rgba(0,0,0,0.22);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

/* Joined button group (floor up/down, T/F/S views) */
.btn-group-joined {
    display: inline-flex;
}

.btn-group-joined .btn-icon-only {
    border-radius: 0;
    border-right-width: 0;
}

.btn-group-joined .btn-icon-only:first-child {
    border-radius: 5px 0 0 5px;
}

.btn-group-joined .btn-icon-only:last-child {
    border-radius: 0 5px 5px 0;
    border-right-width: 1px;
}

/* Primary action button (View in AR) */
.btn-primary.btn-icon-label {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #f5f0e8;
}

.btn-primary.btn-icon-label svg {
    opacity: 0.85;
}

.btn-primary.btn-icon-label:hover {
    background: #333;
    border-color: #333;
    color: #fff;
}

/* Danger/clear button */
.btn-outline-danger.btn-icon-label {
    background: rgba(255,255,255,0.95);
    border-color: rgba(180,20,20,0.35);
    color: #b41414;
}

.btn-outline-danger.btn-icon-label:hover {
    background: #b41414;
    border-color: #b41414;
    color: white;
}

/* Import 3D special accent */
.btn-import {
    background: rgba(240,246,255,0.95);
    border-color: rgba(30,80,180,0.2);
    color: #1e50b4;
}

.btn-import:hover {
    background: rgba(220,235,255,1);
    border-color: rgba(30,80,180,0.4);
}

/* Lock active state — amber tint signals camera is locked */
.btn-lock-active {
    background: rgba(180, 120, 0, 0.1) !important;
    border-color: rgba(180, 120, 0, 0.4) !important;
    color: #8a5c00 !important;
}

/* FOV control inline wrapper */
.fov-control.btn-icon-label {
    gap: 8px;
    cursor: default;
}

.fov-control.btn-icon-label:hover {
    transform: none;
}

.fov-control input[type=range] {
    accent-color: #2a2a2a;
    cursor: pointer;
}

/* Context controls — premium dark card */
.context-controls {
    background: rgba(24,24,24,0.92) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35) !important;
}

.selected-name {
    color: #d4c5a9 !important;
    border-bottom-color: rgba(255,255,255,0.1) !important;
    font-family: var(--font-heading, 'Cormorant Garamond', serif) !important;
    letter-spacing: 0.05em !important;
    font-size: 0.8rem !important;
}

.control-actions button {
    background: rgba(255,255,255,0.06) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    color: rgba(255,255,255,0.85) !important;
    border-radius: 5px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 9px !important;
    transition: background 0.15s, border-color 0.15s, transform 0.1s !important;
}

.control-actions button:hover {
    background: rgba(255,255,255,0.14) !important;
    border-color: rgba(255,255,255,0.25) !important;
    transform: translateY(-1px) !important;
    box-shadow: none !important;
}

.control-actions .btn-danger {
    color: #e87070 !important;
}

.control-actions .btn-danger:hover {
    background: rgba(180,30,30,0.5) !important;
    border-color: rgba(220,60,60,0.5) !important;
    color: #ffb0b0 !important;
}

/* Interaction hints — refined glass card */
.interaction-hints {
    background: rgba(20,20,20,0.72) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    color: rgba(255,255,255,0.65) !important;
    border-radius: 8px !important;
    font-size: 0.72rem !important;
    letter-spacing: 0.03em !important;
}

.hint-icon {
    display: flex;
    align-items: center;
    opacity: 0.7;
}

/* View controls top bar — frosted */
.view-controls {
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
}

/* ============================================
   MOBILE / TABLET RESPONSIVE
   ============================================ */

/* Use dvh (dynamic viewport height) to fix Android Chrome address bar issue.
   Falls back to vh for older browsers. */

@media (max-width: 900px) {

    /* Main layout: stack vertically */
    .configurator-wrapper {
        flex-direction: column;
        padding-top: 60px;
        height: calc(100vh - 60px);
        height: calc(100dvh - 60px);
        overflow: hidden;
    }

    /* 3D Canvas: top portion */
    .scene-canvas-container {
        height: 50%;
        min-height: 200px;
        flex-shrink: 0;
    }

    /* Product sidebar: bottom portion */
    .product-sidebar {
        width: 100%;
        height: 50%;
        flex-shrink: 0;
        border-left: none;
        border-top: 2px solid var(--color-border);
        box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.1);
    }

    .product-grid {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 10px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ---- Hide ALL top view controls on mobile ---- */
    .view-controls {
        display: none !important;
    }

    /* ---- Compact bottom scene controls ---- */
    .scene-controls-bottom {
        bottom: 5px !important;
        left: 5px !important;
        right: 5px !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 4px !important;
        justify-content: center;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .scene-controls-bottom button {
        padding: 8px 10px !important;
        font-size: 0.7rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Hide non-essential buttons on mobile */
    #btn-undo,
    #btn-upload-bg,
    #btn-clear-bg,
    #btn-fullscreen,
    #btn-import-3d,
    #btn-toggle-grid {
        display: none !important;
    }

    .scene-controls-bottom .divider {
        display: none !important;
    }

    /* Hide interaction hints on mobile (touch is intuitive) */
    .interaction-hints {
        display: none !important;
    }

    /* ---- Context controls (selected item) ---- */
    .context-controls {
        position: absolute !important;
        top: 5px !important;
        right: 5px !important;
        bottom: auto !important;
        left: auto !important;
        min-width: 110px;
        padding: 6px;
        border-radius: 6px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    }

    .selected-name {
        font-size: 0.75rem;
        padding-bottom: 4px;
    }

    .control-actions {
        gap: 3px;
    }

    .control-actions button {
        padding: 6px !important;
        font-size: 0.85rem;
    }

    #object-coordinates {
        display: none !important;
    }

    /* ---- Scene title and back link ---- */
    .scene-overlay-top {
        top: 5px !important;
        left: 5px !important;
    }

    .scene-title {
        font-size: 0.9rem;
        margin-top: 3px;
    }

    .back-link {
        font-size: 0.7rem;
        padding: 3px 6px;
    }

    /* ---- Sidebar on mobile ---- */
    .sidebar-header {
        padding: 8px 10px;
    }

    .sidebar-header h2 {
        font-size: 0.95rem;
        margin-bottom: 6px;
    }

    .collection-tabs {
        gap: 4px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .tab-btn {
        padding: 4px 10px;
        font-size: 0.72rem;
        flex-shrink: 0;
    }

    .product-card {
        min-height: 55px;
    }

    .product-thumb {
        width: 55px;
        height: 55px;
    }

    .product-info {
        padding: 6px 10px;
    }

    .product-name {
        font-size: 0.78rem;
    }

    .product-meta {
        font-size: 0.65rem;
    }

    /* QR Modal: mobile friendly */
    .modal-content {
        margin: 20px !important;
        max-width: calc(100vw - 40px) !important;
    }
}

/* ---- Extra small (phones portrait) ---- */
@media (max-width: 480px) {
    .configurator-wrapper {
        padding-top: 50px;
        height: calc(100vh - 50px);
        height: calc(100dvh - 50px);
    }

    .scene-canvas-container {
        height: 45%;
    }

    .product-sidebar {
        height: 55%;
    }

    .scene-controls-bottom button {
        padding: 6px 8px !important;
        font-size: 0.65rem;
    }

    .scene-overlay-top {
        display: none !important;
    }
}