/* map-designer.css – kortdesignerens layout (kortet, rammen, previewet og panelets særlige dele).
   Farver, knapper (.button), valg (.option), paneler (.panel__head/.panel__section), felter (.input, .range) og
   header/footer kommer fra designsystemet /css/latl.css. Panelets bredde og kortområdet er uændrede, fordi
   laser-generatoren måler kortrammen (#map-frame-wrapper, #modeIndicator). */

/* ===== RESET & BASE ===== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    overflow: hidden;
    background: var(--paper);
}

/* Med shoppens header og footer (/kort/, app/views/kort.php sætter data-site): som på /julepynt/ ruller siden,
   kortet bliver stående (sticky, vinduets højde), og konfiguratoren har ingen egen scrollbar.
   Uden data-site (laser-generatoren) er siden som før: alt i ét vindue. */
html[data-site], html[data-site] body { height: auto; overflow: visible; }
html[data-site] #container { height: auto; align-items: flex-start; }
html[data-site] #unified-map-container { position: sticky; top: 0; align-self: flex-start; height: 100vh; height: 100dvh; }
html[data-site] #controls-panel { max-height: none; overflow: visible; }
/* Pladsen til kortet reserveres, før JS har regnet størrelsen ud (ellers hopper rammen fra en tom boks til fuld
   størrelse): samme formel som updateMapSize() i js/ui/map-designer-ui.js – 85 % af kortområdets clientWidth/
   clientHeight (indhold + 2 × 20 px padding) i papirets forhold, og en ramme på 2 cm. kort.php sætter
   --map-ratio (bredde/højde efter retning) og --paper-h-cm på <html> ud fra ?c=. JS's inline-mål overtager bagefter. */
html[data-site][style*="--map-ratio"] #unified-map-container { container-type: size; }
html[data-site][style*="--map-ratio"] #map-frame-wrapper {
    --map-w: min(0.85 * (100cqw + 40px), 0.85 * (100cqh + 40px) * var(--map-ratio));
    padding: calc(var(--map-w) / var(--map-ratio) * 2 / var(--paper-h-cm));
}
html[data-site][style*="--map-ratio"] #map-container { width: var(--map-w); height: calc(var(--map-w) / var(--map-ratio)); }

/* ===== MAIN CONTAINER ===== */

#container {
    display: flex;
    height: 100%;
    width: 100%;
}

/* ===== MAP SECTION ===== */

#unified-map-container {
    display: flex;
    flex: 1;
    height: 100%;
    padding: 20px;
    align-items: center;
    justify-content: center;
    background: transparent;   /* sidens baggrund (--paper) */
    /* overflow visible so box-shadow on child is not clipped */
    overflow: visible;
}

/* ===== FRAME WRAPPER — Realistic Wood Frame ===== */

#map-frame-wrapper {
    position: relative;
    display: inline-block;
    padding: 42px; /* overskrives af JS */
    background-color: #c8a96e; /* fallback oak farve */
    background-size: 100% 100%;
    background-repeat: no-repeat;
    /* ✅ Shadow here — works on inline-block regardless of flex parent */
    box-shadow:
        0 14px 40px rgba(0,0,0,0.40),
        0 4px 12px rgba(0,0,0,0.22),
        0 1px 4px rgba(0,0,0,0.15);
}

#map-frame-wrapper.oak {
    background-color: #c8a96e;
}

#map-frame-wrapper.black {
    background-image: none !important;
    background-color: #1a1a1a;
    box-shadow:
        0 14px 40px rgba(0,0,0,0.55),
        0 4px 12px rgba(0,0,0,0.35),
        0 1px 4px rgba(0,0,0,0.20);
}

/* Map Container */
#map-container {
    position: relative;
    background: white;
    overflow: hidden;
    z-index: 2;
}

/* Inset shadow overlay — sits on top of map, not clipped by overflow:hidden */
#map-container::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    box-shadow:
        inset 0 0 0 1px rgba(0,0,0,0.22),
        inset 3px 3px 10px rgba(0,0,0,0.28),
        inset -2px -2px 6px rgba(0,0,0,0.12);
}

/* ===== SEARCH CONTAINER ===== */

/* Søgefeltet ligger oven på kortet (felt og knap fra .input-row/.input/.button i latl.css) */
#search-container {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    width: 90%;
    max-width: 400px;
    transition: opacity 0.3s ease;
}
#search-container .input { box-shadow: 0 2px 10px rgba(4, 41, 64, .18); }

#search-container.hidden {
    opacity: 0;
    pointer-events: none;
}

#search-button { flex: none; }

#search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    display: none;
    margin-top: 2px;
}

.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #e9ecef;
    font-size: 13px;
}

.search-result-item:hover {
    background: #f8f9fa;
}

/* ===== MAP AND PREVIEW ===== */

#map, #svgPreview {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.3s ease;
}

#map {
    opacity: 1;
    z-index: 10;
}

#map.hidden {
    opacity: 0;
    pointer-events: none;
}

#svgPreview {
    opacity: 0;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    z-index: 20;
    pointer-events: none;
    cursor: grab;
}

#svgPreview.active {
    opacity: 1;
    pointer-events: all;
}

#svgPreview.active:active {
    cursor: grabbing;
}

#preview-iframe {
    background: transparent !important;
}

/* ===== FLOATING GENERATE BUTTON (udseende fra .button) ===== */

#generatePreviewFloat {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    padding: 16px 32px;
    font-size: 1.1rem;
    box-shadow: 0 6px 18px rgba(4, 41, 64, .3);
    opacity: 1;
    transition: opacity .3s ease, transform .3s ease, filter .15s;
}

#generatePreviewFloat:hover:not(:disabled) { transform: translate(-50%, -50%) scale(1.04); }

#generatePreviewFloat.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.9);
}

/* ===== MODE INDICATOR ===== */

.mode-indicator {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    z-index: 450;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mode-indicator.visible {
    opacity: 1;
}

/* ===== CONTROLS PANEL (hoved og sektioner fra .panel__head/.panel__section) ===== */

/* Konfiguratoren er det fælles .designer-card (latl.css): fritstående med luft omkring; den ruller selv,
   når indholdet er højere end vinduet */
#controls-panel {
    flex: 0 0 280px;
    align-self: flex-start;
    max-height: calc(100% - 32px);
    margin: 16px 16px 16px 0;
    overflow-y: auto;
    font: 400 .9375rem/1.45 var(--sans);
}
#controls-panel .hint { margin: 8px 0 0; }
#controls-panel .input + .input { margin-top: 8px; }
.paper-size-display { text-align: center; font-weight: 600; }
#rotateBtn svg { transition: transform .3s; }
#rotateBtn.landscape svg { transform: rotate(90deg); }
.poi-count { margin: 8px 0 0; }

/* ===== COLOR SELECTORS ===== */

.color-selector {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.color-option:hover { transform: scale(1.1); }

.color-option.is-selected {
    border-color: var(--ink);
    box-shadow: 0 0 0 2px var(--selected-bg);
}

.color-option.wood   { background: #E8D7C3; }
.color-option.brown  { background: linear-gradient(135deg, #8B6F47 0%, #6D5D39 100%); }
.color-option.black  { background: #000000; }
.color-option.blue   { background: #2B4C8C; }
.color-option.grey   { background: #D9D9D6; }
.color-option.white  { background: #FFFFFF; box-shadow: inset 0 0 0 1px var(--line); }
.color-option.red    { background: #CC0000; }

/* ===== FRAME SELECTOR (valg fra .option) ===== */

.frame-selector { margin-top: 8px; }

.frame-preview {
    width: 40px;
    height: 40px;
    margin: 0 auto 4px;
    border: 4px solid;
    border-radius: 4px;
}

.frame-preview.oak {
    border-color: #8B6F47;
    background: linear-gradient(135deg, #8B6F47 0%, #6D5D39 50%, #8B6F47 100%);
}

.frame-preview.black {
    border-color: #1a1a1a;
    background: #1a1a1a;
}

/* ===== TITLE DESIGN OPTIONS (valg fra .option.option--row) ===== */

.title-design-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 4px 0 12px;
}

.title-design-option { gap: 10px; }
.title-design-option input[type="radio"] { margin: 0; accent-color: var(--ink); }

.title-design-label { flex: 1; }

.title-design-preview {
    width: 60px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 3px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 2px;
    background: white;
    position: relative;
}

.title-preview-line { width: 100%; height: 2px; background: #E8D7C3; position: relative; }
.title-preview-line::before { content: 'ABC'; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); font-family: 'LATL Sans', sans-serif; font-size: 10px; color: #8B6F47; }
.title-preview-solid { width: 100%; height: 10px; background: #E8D7C3; display: flex; align-items: center; justify-content: center; position: relative; }
.title-preview-solid::after { content: 'ABC'; position: absolute; font-family: 'LATL Sans Stencil', sans-serif; font-size: 10px; color: #8B6F47; }
.title-preview-double { width: 100%; height: 100%; position: relative; }
.title-preview-double::before { content: ''; position: absolute; bottom: 2px; left: 0; right: 0; height: 1px; background: #E8D7C3; }
.title-preview-double::after { content: ''; position: absolute; top: 8px; left: 0; right: 0; height: 1px; background: #E8D7C3; }
.title-preview-double span { position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); font-family: 'LATL Sans', sans-serif; font-size: 10px; color: #8B6F47; }
.title-preview-rect { width: 100%; height: 100%; background: #f5f5f5; position: relative; }
.title-preview-rect::before { content: ''; position: absolute; top: 3px; left: 3px; right: 3px; bottom: 8px; background: white; border: 1px solid #ddd; }
.title-preview-rect::after { content: 'ABC'; position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%); font-family: 'LATL Sans Stencil', sans-serif; font-size: 6px; color: #999; }
.title-preview-circle { width: 100%; height: 100%; background: #f5f5f5; position: relative; }
.title-preview-circle::before { content: ''; position: absolute; width: 16px; height: 16px; top: 3px; left: 50%; transform: translateX(-50%); background: white; border-radius: 50%; border: 1px solid #ddd; }
.title-preview-circle::after { content: 'ABC'; position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%); font-family: 'LATL Sans Stencil', sans-serif; font-size: 6px; color: #999; }

/* ===== UTILITY CLASSES ===== */

.color-label { margin: 12px 0 6px; font-size: .8125rem; color: var(--muted); }
.color-label:first-of-type { margin-top: 0; }
.frame-label { font-size: .8125rem; }
.char-counter { text-align: right; font-size: .75rem; color: var(--muted); margin: 4px 0 8px; }

/* ===== PROGRESS BAR ===== */

#progress { height: 8px; background-color: var(--cream); margin: 12px 0; border-radius: 4px; overflow: hidden; }
#progress-bar { height: 100%; background: linear-gradient(90deg, var(--lime), var(--bright)); width: 0%; transition: width 0.3s; border-radius: 4px; }

/* ===== STATUS ===== */

#status { text-align: center; }

/* ===== LOADING SPINNER ===== */

.spinner { border: 3px solid var(--cream); border-top: 3px solid var(--ink); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 20px auto; }
.button .spinner { width: 20px; height: 20px; margin: 0; border: 0; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ===== LEAFLET CONTROLS ===== */

.leaflet-container { height: 100%; width: 100%; }
.leaflet-control-zoom { border: none !important; box-shadow: 0 2px 6px rgba(0,0,0,0.15) !important; }
.leaflet-control-zoom a { background: var(--surface) !important; color: var(--ink) !important; border: none !important; }
.leaflet-control-zoom a:hover { background: var(--selected-bg) !important; }

/* ===== ASPECT RATIO FRAME ===== */

.aspect-ratio-frame { display: none !important; }

/* ===== PROGRESS CIRCLE ===== */

.progress-circle-container { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2000; pointer-events: none; }
.progress-circle { width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,0.5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.progress-circle svg { width: 100px; height: 100px; transform: rotate(-90deg); }
.progress-circle-bg { fill: none; stroke: rgba(255,255,255,0.3); stroke-width: 8; }
.progress-circle-fill { fill: none; stroke: var(--ink); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.3s ease; }
.progress-text { position: absolute; font-size: 24px; font-weight: 600; color: var(--ink); }
.progress-label { position: absolute; bottom: -30px; width: 100%; text-align: center; font-size: 14px; color: var(--ink); background: rgba(255,255,255,0.9); padding: 4px 8px; border-radius: 4px; white-space: nowrap; }

/* ===== TOAST NOTIFICATIONS ===== */

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: white; padding: 16px 24px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); display: none; z-index: 10000; animation: slideInRight 0.3s ease; }
.toast.show { display: block; }
.toast.success { background: var(--secondary); }
.toast.error { background: var(--error); }
.toast.warning { background: var(--bright); color: var(--ink); }
.toast.info { background: var(--ink); }
@keyframes slideInRight { from { transform: translateX(400px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== RESPONSIVE ===== */

@media (max-width: 1024px) { #controls-panel { flex: 0 0 240px; } }
@media (max-width: 768px) { #container { flex-direction: column; } #unified-map-container { flex: 1; } #controls-panel { flex: 0 0 auto; align-self: stretch; max-height: none; margin: 0 16px 16px; } }
/* Mobil med shoppens ramme: kortet øverst i en fast højde, konfiguratoren under, og siden ruller (ikke panelet) */
@media (max-width: 768px) {
    html[data-site] #container { height: auto; }
    html[data-site] #unified-map-container { position: static; align-self: stretch; flex: none; height: 75vh; height: 75svh; }
}

/* ===== TITEL SLIDERS (sliderne er .range fra latl.css) ===== */

.title-sliders-container { background: var(--paper); border: 1px solid var(--cream); border-radius: var(--radius); padding: 14px; margin-top: 12px; }
.sliders-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--cream); }
.sliders-title { font-weight: 600; font-size: .875rem; }
.title-slider-row { margin-bottom: 18px; }
.title-slider-row:last-of-type { margin-bottom: 0; }
.title-slider-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: .8125rem; }
.title-slider-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.slider-scale { display: flex; justify-content: space-between; font-size: .6875rem; color: var(--muted); }

/* ===== BESTIL ===== */

.total-section { background: var(--paper); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.total-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.total-row--sum { margin: 8px 0 0; padding-top: 10px; border-top: 2px solid var(--cream); font-size: 1.125rem; font-weight: 700; }
.total-label { color: var(--muted); }
.total-value { font-weight: 600; }
