/* ============================================
   Floor Designer v2 — Styles
   Bootstrap 5.3 customizations
   ============================================ */

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Toolbar */
#fd2-toolbar {
    height: 72px;
    z-index: 100;
}
#fd2-toolbar .logo-svg {
    height: 30px;
    width: auto;
}
/* Step navigation — prev / current / next */
#fd2-step-nav {
    flex-shrink: 1;
    min-width: 0;
}
#fd2-current-step {
    background-color: #231f20;
    border-color: #231f20;
    color: #fff;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    cursor: default;
    white-space: nowrap;
}
#fd2-prev-step, #fd2-next-step {
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.5rem 0.9rem;
    background-color: #231f20;
    border-color: #231f20;
    color: #fff;
    white-space: nowrap;
}
#fd2-prev-step:hover:not(:disabled), #fd2-next-step:hover:not(:disabled) {
    background-color: #000;
    border-color: #000;
    color: #fff;
}
#fd2-prev-step:disabled, #fd2-next-step:disabled {
    background-color: #e9ecef;
    border-color: #adb5bd;
    color: #6c757d;
    opacity: 1;
}
/* Action buttons (right side of toolbar) */
#fd2-toolbar .btn-primary {
    font-weight: 700;
    padding: 0.5rem 0.9rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
#fd2-toolbar .btn-outline-dark {
    font-weight: 600;
    border-width: 1.5px;
    border-color: #495057;
    color: #212529;
    background-color: #fff;
    padding: 0.45rem 0.8rem;
}
#fd2-toolbar .btn-outline-dark:hover:not(:disabled) {
    background-color: #231f20;
    border-color: #231f20;
    color: #fff;
}
#fd2-toolbar .btn-outline-dark:disabled {
    opacity: 0.45;
    background-color: #fff;
}

/* Sidebar */
#fd2-sidebar {
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 0.875rem;
}
#fd2-sidebar .fd2-panel {
    padding: 12px 16px !important;
}
#fd2-sidebar h6 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
}

/* Range slider — larger handle, more space */
#fd2-sidebar .form-range {
    margin: 8px 0;
}
#fd2-sidebar .form-range::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
}
#fd2-sidebar .form-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
}
#fd2-sidebar .form-range::-ms-thumb {
    width: 20px;
    height: 20px;
}

/* Right palette (product thumbnails) */
#fd2-palette {
    width: 380px;
    min-width: 380px;
    flex-shrink: 0;
}
.fd2-palette-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    height: calc(100% - 36px);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    align-content: start;
}
.fd2-palette-scroll .fd2-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    flex-shrink: 0;
    border-radius: 6px;
}

/* Palette thumbnail with SKU label */
.fd2-thumb-wrap {
    position: relative;
    display: inline-block;
    transition: transform 0.15s ease;
    cursor: pointer;
}
.fd2-thumb-wrap:hover {
    transform: scale(1.25);
    z-index: 10;
}
.fd2-thumb-wrap .fd2-sku-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    color: #fff;
    background: rgba(0,0,0,0.55);
    line-height: 1.2;
    padding: 2px 3px;
    pointer-events: none;
    word-wrap: break-word;
    white-space: normal;
    border-radius: 0 0 6px 6px;
}
.fd2-thumb-wrap:hover .fd2-sku-label {
    font-size: 12px;
}

/* Sidebar product preview */
.fd2-preview-img {
    width: 100%;
    height: 150px;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    background: #f8f9fa;
}

/* Sidebar shape gallery */
.fd2-thumb-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 180px;
    overflow-y: auto;
    padding: 2px;
}
.fd2-thumb {
    width: 56px;
    height: 56px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    object-fit: contain;
    background: #f8f9fa;
    transition: border-color 0.15s;
}
.fd2-thumb:hover {
    border-color: #999;
}
.fd2-thumb.active {
    border-color: #0d6efd;
    box-shadow: 0 0 0 2px rgba(13,110,253,0.25);
}

/* Measure tool cursor */
.fd2-measure-cursor { cursor: crosshair !important; }

/* Description More/Less links */
.fd2-more-link, .fd2-less-link {
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Shape gallery in palette — uses same grid as palette */
#fd2-shape-gallery {
    display: contents;
}
#fd2-shape-gallery .fd2-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 1.2;
    background: #fff;
}
#fd2-shape-gallery .fd2-thumb-wrap {
    position: relative;
}
#fd2-shape-gallery .fd2-sku-label {
    font-size: 10px;
}

/* Footer */
#fd2-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    background: #000;
    color: #fff;
    font-size: 14px;
    font-family: Helvetica, Arial, sans-serif;
    padding: 10px 16px;
    border-top: 1px solid #444;
}
#fd2-footer a {
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
#fd2-footer a:hover {
    color: #ccc;
}

/* Canvas area */
#fd2-app > main {
    min-width: 0;
    overflow: hidden;
}

/* Canvas container */
#fd2-canvas-container {
    cursor: grab;
    background: #ffffff;
}
#fd2-canvas-container:active {
    cursor: grabbing;
}

/* Zoom controls */
#btn-zoom-in, #btn-zoom-out, #btn-zoom-reset {
    min-width: 36px;
    font-size: 0.8rem;
}

/* Comment button — active state when placing a pin */
#fd2-toolbar #btn-comment.active,
#fd2-toolbar #btn-comment.active:hover {
    background-color: #d9534f !important;
    border-color: #d9534f !important;
    color: #fff !important;
}

/* Custom cursor for comment drop mode — map-pin with tip at hotspot */
.fd2-comment-drop,
.fd2-comment-drop * {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'><path d='M 16,31 L 5.9,15.5 A 12,12 0 1,1 26.1,15.5 Z' fill='%23d9534f' stroke='%23ffffff' stroke-width='1.8' stroke-linejoin='round'/><circle cx='16' cy='12' r='4' fill='%23ffffff'/></svg>") 16 31, crosshair !important;
}

/* Dimension inputs in sidebar */
#fd2-dim-inputs .form-control {
    font-size: 0.8rem;
}

/* Help modal */
#fd2-help-body {
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Estimate modal table */
#fd2-estimate-body table {
    font-size: 0.85rem;
}

/* ============================================
   Help Tour — spotlight overlay + tooltip
   ============================================ */
#fd2-tour-spotlight {
    position: fixed;
    border-radius: 6px;
    z-index: 1000;
    box-shadow: 0 0 0 4px #e67e22, 0 0 0 9999px rgba(0,0,0,0.55);
    pointer-events: none;
    transition: top 0.3s ease, left 0.3s ease, width 0.3s ease, height 0.3s ease;
    display: none;
}
#fd2-tour-tooltip {
    position: fixed;
    z-index: 1001;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.22);
    padding: 20px 24px;
    max-width: 340px;
    min-width: 260px;
    display: none;
    transition: opacity 0.2s ease;
}
.fd2-tour-dots {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}
.fd2-tour-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
}
.fd2-tour-dot.active {
    background: #e67e22;
}
.fd2-tour-step-label {
    font-size: 11px;
    font-weight: 700;
    color: #e67e22;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}
.fd2-tour-title {
    font-size: 17px;
    font-weight: 700;
    color: #212529;
    margin: 4px 0 6px 0;
}
.fd2-tour-desc {
    font-size: 13px;
    color: #555;
    line-height: 1.5;
    margin: 0 0 14px 0;
}
.fd2-tour-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.fd2-tour-skip {
    font-size: 13px;
    color: #888;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.fd2-tour-skip:hover {
    color: #333;
}
.fd2-tour-btn {
    background: #e67e22;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.fd2-tour-btn:hover {
    background: #cf6d17;
}

/* Quote form collapse (not display:none — allows Chrome autofill) */
.fd2-collapsed {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}
.fd2-expanded {
    max-height: 600px;
    overflow: visible;
    opacity: 1;
    transition: max-height 0.4s ease, opacity 0.3s ease;
}

/* Download dropdown z-index */
#btn-save-group .dropdown-menu {
    z-index: 110;
}

/* ============================================
   Material toggle in toolbar
   ============================================ */
#fd2-material-toggle-bar {
    flex-shrink: 0;
}
#fd2-material-toggle-bar .btn {
    font-weight: 600;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}
#fd2-material-toggle-bar .btn-check:checked + .btn {
    background-color: #231f20;
    border-color: #231f20;
    color: #fff;
}
#fd2-material-toggle-bar .btn-check:not(:checked) + .btn {
    background-color: #fff;
    border-color: #495057;
    color: #212529;
}

/* ============================================
   Bottom panel structure (hidden on desktop)
   ============================================ */
#fd2-bottom-panel { display: none; }

.fd2-bp-tabs {
    display: flex;
    gap: 6px;
    padding: 8px 12px 0;
    background: #f0f0f0;
    border-top: 1px solid #dee2e6;
    flex-shrink: 0;
}
.fd2-bp-tab {
    flex: 0 0 auto;
    border: 1px solid #ccc;
    border-bottom: none;
    background: #e9ecef;
    padding: 8px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: background 0.15s, color 0.15s;
    position: relative;
    bottom: -1px;
}
.fd2-bp-tab.active {
    color: #212529;
    background: #fff;
    border-color: #dee2e6;
    z-index: 1;
}
.fd2-bp-body {
    position: relative;
    flex-grow: 1;
    overflow: hidden;
    background: #fff;
    border-top: 1px solid #dee2e6;
}
.fd2-bp-pane {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overflow-x: hidden;
    visibility: hidden;
    pointer-events: none;
}
.fd2-bp-pane.active {
    visibility: visible;
    pointer-events: auto;
}

/* Selection pane: thumbnail grid */
.fd2-bp-pane[data-bp-pane="selection"] .fd2-palette-scroll {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 8px;
    height: auto;
}

/* ============================================
   Hamburger menu
   ============================================ */
.fd2-hamburger-menu {
    position: absolute;
    top: 50px;
    right: 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 200;
    min-width: 200px;
    display: none;
    flex-direction: column;
    padding: 6px 0;
}
.fd2-hamburger-menu.open { display: flex; }
.fd2-hamburger-menu button {
    border: none;
    background: transparent;
    text-align: left;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #212529;
    width: 100%;
    border-radius: 0;
    cursor: pointer;
}
.fd2-hamburger-menu button:hover:not(:disabled) { background: #f0f0f0; }
.fd2-hamburger-menu button:disabled { opacity: 0.4; cursor: default; }

/* ============================================
   Landscape small screens: desktop layout, narrower panels
   ============================================ */
@media (max-width: 1366px) and (orientation: landscape) {
    #fd2-toolbar {
        height: 56px;
        padding: 0 10px !important;
    }
    #fd2-toolbar .logo-svg { height: 24px; }
    #fd2-toolbar .navbar-brand .fs-6 { font-size: 0.8rem !important; }
    .fd2-step-btn-label { font-size: 0.8rem; }
    #fd2-current-step { font-size: 0.85rem; padding: 0.4rem 0.7rem; }
    #fd2-prev-step, #fd2-next-step { font-size: 0.8rem; padding: 0.4rem 0.6rem; }

    /* Hamburger menu, hide desktop actions */
    #fd2-toolbar-actions { display: none !important; }
    #fd2-hamburger {
        display: inline-flex !important;
        font-size: 1.3rem;
        padding: 0.3rem 0.6rem;
    }
    .fd2-hamburger-menu {
        top: 56px;
        min-width: 220px;
    }
    .fd2-hamburger-menu button {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    #fd2-app {
        height: calc(100vh - 56px - 38px) !important;
        margin-top: 0 !important;
    }

    /* Narrower sidebar */
    #fd2-sidebar {
        width: 220px !important;
        min-width: 220px !important;
        font-size: 0.8rem;
    }
    #fd2-sidebar .fd2-preview-img { height: 100px; }

    /* Narrower palette, 2 columns */
    #fd2-palette {
        width: 240px !important;
        min-width: 240px !important;
    }
    .fd2-palette-scroll {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 4px;
        padding: 6px;
    }

    /* Compact footer */
    #fd2-footer { font-size: 11px; padding: 6px 10px; gap: 10px; }

    /* Compact material toggle */
    #fd2-material-toggle-bar .btn { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
}

/* Very small landscape (phones) — even narrower */
@media (max-height: 500px) and (orientation: landscape) {
    #fd2-toolbar { height: 44px; }
    #fd2-toolbar .logo-svg { height: 20px; }
    #fd2-toolbar .navbar-brand .fs-6 { display: none !important; }
    #fd2-current-step { font-size: 0.75rem; padding: 0.3rem 0.5rem; }
    #fd2-prev-step, #fd2-next-step { font-size: 0.75rem; padding: 0.3rem 0.4rem; }
    #fd2-material-toggle-bar .btn { padding: 0.25rem 0.5rem; font-size: 0.7rem; }
    .fd2-hamburger-menu { top: 44px; }

    #fd2-app {
        height: calc(100vh - 44px) !important;
    }
    #fd2-footer { display: none !important; }

    #fd2-sidebar {
        width: 180px !important;
        min-width: 180px !important;
        font-size: 0.75rem;
    }
    #fd2-sidebar .fd2-preview-img { height: 70px; }

    #fd2-palette {
        width: 180px !important;
        min-width: 180px !important;
    }
    .fd2-palette-scroll {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 3px;
        padding: 4px;
    }
    .fd2-sku-label { font-size: 8px; }
}

/* ============================================
   Portrait mobile: max-width 1366px
   Bottom panel layout
   ============================================ */
@media (max-width: 1366px) and (orientation: portrait) {
    /* Toolbar */
    #fd2-toolbar {
        height: 60px;
        padding: 0 12px !important;
        flex-wrap: nowrap !important;
    }
    #fd2-toolbar .logo-svg { height: 30px; }
    #fd2-toolbar .navbar-brand .fs-6 { font-size: 0.9rem !important; }

    /* Step nav */
    #fd2-current-step { font-size: 1rem; padding: 0.5rem 1rem; }
    #fd2-prev-step, #fd2-next-step {
        font-size: 0.85rem;
        padding: 0.45rem 0.7rem;
    }
    .fd2-step-btn-label { font-size: 0.85rem; }

    /* Hide desktop action buttons, show hamburger */
    #fd2-toolbar-actions { display: none !important; }
    #fd2-hamburger {
        display: inline-flex !important;
        font-size: 1.5rem;
        padding: 0.4rem 0.7rem;
    }

    /* Hide desktop sidebar + palette (content relocated by JS) */
    #fd2-sidebar { display: none !important; }
    #fd2-palette { display: none !important; }

    /* Show bottom panel */
    #fd2-bottom-panel {
        display: flex !important;
        flex-direction: column;
        height: 240px;
        flex-shrink: 0;
        background: #f0f0f0;
    }

    /* Main app: column layout, leave room for footer */
    #fd2-app {
        flex-direction: column !important;
        height: calc(100vh - 60px - 42px) !important;
        margin-top: 0 !important;
    }

    /* Footer */
    #fd2-footer {
        font-size: 12px;
        padding: 8px 12px;
        gap: 14px;
    }

    /* Canvas */
    #fd2-canvas-container { min-height: 200px; }

    /* Zoom controls */
    #fd2-app > main > .position-absolute {
        top: 10px !important;
        right: 10px !important;
    }
    #btn-zoom-in, #btn-zoom-out, #btn-zoom-reset {
        min-width: 40px;
        min-height: 40px;
        font-size: 1rem;
        padding: 6px 10px;
    }

    /* Hamburger menu */
    .fd2-hamburger-menu {
        top: 60px;
        min-width: 240px;
    }
    .fd2-hamburger-menu button {
        padding: 14px 20px;
        font-size: 1rem;
    }

    /* Bottom panel tabs */
    .fd2-bp-tab {
        padding: 10px 24px;
        font-size: 0.95rem;
    }

    /* Thumbnails in bottom panel */
    .fd2-bp-pane .fd2-thumb-wrap:hover { transform: none; }
    .fd2-bp-pane .fd2-sku-label { font-size: 10px; }
    .fd2-bp-pane .fd2-thumb { width: 100%; height: auto; }

    /* Controls tab: hide preview images, horizontal layout */
    .fd2-bp-pane[data-bp-pane="controls"] .fd2-preview-img { display: none; }
    .fd2-bp-pane[data-bp-pane="controls"] .fd2-panel {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 16px;
        align-items: flex-start;
        padding: 10px 12px !important;
    }
    .fd2-bp-pane[data-bp-pane="controls"] .fd2-panel > * {
        flex: 0 0 auto;
    }
    .fd2-bp-pane[data-bp-pane="controls"] .fd2-panel h6 {
        width: 100%;
        margin-bottom: 0 !important;
    }
    .fd2-bp-pane[data-bp-pane="controls"] .fd2-panel .mb-2 {
        margin-bottom: 0 !important;
        min-width: 120px;
    }
    .fd2-bp-pane[data-bp-pane="controls"] .fd2-panel .row {
        min-width: 200px;
    }

    /* Measurements table: compact width */
    .fd2-bp-pane #fd2-summary table {
        max-width: 280px;
    }
}

/* ============================================
   Narrow portrait (small tablets / iPhone-Chrome simulation): 601-820px
   Hide brand text + shrink step buttons so the toolbar stays on one row.
   Wood/Stone toggle stays inline (only goes overlay at ≤600px).
   ============================================ */
@media (max-width: 820px) and (min-width: 601px) and (orientation: portrait) {
    #fd2-toolbar .navbar-brand .fs-6 { display: none !important; }
    .fd2-step-btn-label { font-size: 0.78rem; }
    #fd2-current-step { font-size: 0.9rem; padding: 0.4rem 0.7rem; }
    #fd2-prev-step, #fd2-next-step { padding: 0.4rem 0.55rem; }
    #fd2-material-toggle-bar .btn { padding: 0.35rem 0.65rem; font-size: 0.85rem; }
}

/* ============================================
   Phone portrait: max-width 600px
   ============================================ */
@media (max-width: 600px) and (orientation: portrait) {
    #fd2-toolbar { height: 50px; }
    #fd2-toolbar .logo-svg { height: 24px; }
    #fd2-toolbar .navbar-brand .fs-6 { display: none !important; }

    /* Move material toggle to canvas overlay on phone */
    #fd2-material-toggle-bar {
        position: fixed;
        top: 58px;
        left: 8px;
        z-index: 10;
        background: #fff;
        border-radius: 6px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }
    #fd2-material-toggle-bar .btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    #fd2-current-step { font-size: 0.85rem; padding: 0.4rem 0.7rem; }
    #fd2-prev-step, #fd2-next-step { font-size: 0.85rem; padding: 0.4rem 0.5rem; }
    .fd2-step-btn-label { display: none; }

    .fd2-bp-pane[data-bp-pane="selection"] .fd2-palette-scroll {
        grid-template-columns: repeat(4, 1fr);
    }

    #fd2-app { height: calc(100vh - 50px - 38px) !important; }
    #fd2-footer { font-size: 11px; padding: 6px 10px; gap: 10px; }

    .fd2-hamburger-menu { top: 50px; }

    /* Compact controls */
    .fd2-bp-pane .fd2-panel h6 { font-size: 0.75rem; }
    .fd2-bp-pane #fd2-summary { padding: 6px 8px !important; }
    .fd2-bp-pane #fd2-summary table { font-size: 0.75rem; max-width: 240px; }
}

/* ============================================
   Hamburger menu — material toggle
   ============================================ */
.fd2-hamburger-material {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
}
.fd2-hamburger-material .fd2-hm-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    margin-right: 4px;
}
.fd2-hamburger-material button {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    padding: 5px 14px !important;
    font-size: 0.85rem !important;
    font-weight: 600;
    border: 1.5px solid #495057 !important;
    border-radius: 4px !important;
    background: #fff !important;
    color: #212529 !important;
    cursor: pointer;
}
.fd2-hamburger-material button.active {
    background: #231f20 !important;
    border-color: #231f20 !important;
    color: #fff !important;
}
