/* Dedicated map editor page + read-only floor plan preview. */

body.map-editor-page {
    --map-editor-offset: 68px;
    padding-left: 0 !important;
    overflow: hidden;
    background: #0f172a;
}

body.map-editor-page .company-left-menu,
body.map-editor-page .company-left-menu-backdrop,
body.map-editor-page .company-left-menu-toggle {
    display: none !important;
}

body.map-editor-page .setup-shell,
body.map-editor-page .spaces-shell,
body.map-editor-page .templates-shell {
    display: none !important;
}

body.map-editor-page .toast-wrap {
    left: 16px;
}

body.map-editor-page #mapModal.modal,
body.map-editor-page #layoutTemplateMapModal.modal {
    position: fixed;
    top: var(--map-editor-offset);
    left: 0;
    right: 0;
    bottom: 0;
    display: flex !important;
    align-items: stretch;
    z-index: 20;
    padding: 0;
    margin: 0;
    background: #e8eef6;
    overflow: hidden;
}

body.map-editor-page #mapModal .modal-dialog,
body.map-editor-page #layoutTemplateMapModal .modal-dialog {
    width: 100%;
    max-width: none;
    height: 100%;
    margin: 0;
}

body.map-editor-page #mapModal .modal-content,
body.map-editor-page #layoutTemplateMapModal .modal-content {
    border-radius: 0;
    border: 0;
    height: 100%;
}

body.map-editor-page #mapModal .btn-close,
body.map-editor-page #layoutTemplateMapModal .btn-close {
    display: none;
}

body.map-editor-page #mapModal .modal-header,
body.map-editor-page #layoutTemplateMapModal .modal-header {
    padding: 6px 16px;
}

body.map-editor-page #mapModal .modal-title,
body.map-editor-page #layoutTemplateMapModal .modal-title {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.3;
    color: #475569;
}

body.map-editor-page #mapModal .modal-title i,
body.map-editor-page #layoutTemplateMapModal .modal-title i {
    font-size: 0.78rem;
}

.map-editor-back-btn {
    display: none;
}

body.map-editor-page .map-editor-back-btn {
    display: inline-flex;
    align-items: center;
}

.layout-map-preview,
.template-thumb.is-map-preview {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: #e8eef4;
    cursor: pointer;
    text-align: left;
}

.template-thumb.is-map-preview {
    height: 140px;
    overflow: hidden;
}

.layout-map-preview:focus-visible,
.template-thumb.is-map-preview:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.map-preview-modal-dialog {
    max-width: min(96vw, 1600px);
    width: 96vw;
    margin: 1.25rem auto;
}

.map-preview-modal-dialog .modal-content {
    height: calc(100vh - 2.5rem);
    max-height: calc(100vh - 2.5rem);
}

.map-preview-modal-dialog .modal-body {
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.map-preview-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    flex-shrink: 0;
    margin-bottom: 8px;
}

.map-preview-nav-hint {
    color: #64748b;
    font-size: 0.78rem;
}

.map-preview-tools .btn.active {
    color: #fff;
    background: #2563eb;
    border-color: #2563eb;
}

.map-preview-mini,
.map-preview-stage {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #f8fafc;
}

.map-preview-stage {
    flex: 1;
    min-height: min(72vh, 820px);
    max-height: none;
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    touch-action: none;
    overscroll-behavior: none;
}

.map-preview-stage.is-interactive {
    cursor: default;
    user-select: none;
}

.map-preview-stage.is-hand {
    cursor: grab;
}

.map-preview-stage.is-panning {
    cursor: grabbing;
}

.map-preview-stage.is-interactive .map-preview-board {
    left: 0;
    top: 0;
    transform-origin: 0 0;
}

.map-preview-board {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
    overflow: hidden;
}

.map-preview-board img.map-preview-bg {
    position: absolute;
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: left top;
    pointer-events: none;
}

.map-preview-unit,
.map-preview-deco,
.map-preview-group {
    position: absolute;
    box-sizing: border-box;
    pointer-events: none;
    overflow: visible;
    transform-origin: top left;
}

.map-preview-unit svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.map-preview-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.1;
    text-align: center;
    pointer-events: none;
    transform-origin: center center;
}

.map-preview-group {
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-preview-group-label {
    font-weight: 700;
    font-size: 12px;
    color: #0f172a;
    text-align: center;
    line-height: 1.1;
    padding: 0 4px;
    pointer-events: none;
    transform-origin: center center;
}

.map-preview-stage.is-interactive {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.map-preview-stage.is-selectable .map-preview-unit.is-selectable {
    pointer-events: auto;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.map-preview-stage.is-hand .map-preview-unit,
.map-preview-stage.is-panning .map-preview-unit {
    pointer-events: none;
}

.map-preview-unit.is-busy {
    opacity: 0.55;
    cursor: not-allowed;
}

.map-preview-unit.is-pending {
    cursor: not-allowed;
}

.map-preview-unit.is-selected {
    z-index: 8;
    box-shadow: 0 0 0 3px #c1ff72, 0 0 18px rgba(193, 255, 114, 0.4);
    border-radius: 6px;
}

.map-preview-deco {
    z-index: 3;
}

.map-preview-deco.is-text {
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    font-weight: 700;
}

.map-preview-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #94a3b8;
    font-size: 0.82rem;
}

.map-preview-empty i {
    font-size: 1.6rem;
}

#mapPreviewModal {
    z-index: 1092;
}

body.map-editor-page #mapUnitModal,
body.map-editor-page #mapGroupModal {
    z-index: 1088;
}

.map-busy-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.map-busy-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
    color: #0f172a;
    font-size: 0.95rem;
}

.map-busy-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #cbd5e1;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: map-busy-spin 0.7s linear infinite;
}

@keyframes map-busy-spin {
    to { transform: rotate(360deg); }
}
