/* Kartentool Editor (Wizard) – Sellica/URBANHELDEN Designsystem
   Elfenbein #F7F4F0 · Grün #2c5530 · Gold #c89e3c · Plus Jakarta Sans */

:root {
    --bg:        #F7F4F0;
    --panel:     #FFFFFF;
    --ink:       #2A2A28;
    --green:     #2c5530;
    --green-dk:  #224326;
    --gold:      #c89e3c;
    --line:      #E7E1D6;
    --muted:     #8A8578;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}

/* ---------- Topbar ---------- */

.topbar {
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-block {
    width: 22px; height: 22px;
    background: var(--green);
    border-radius: 5px;
    position: relative;
}
.brand-block::after {
    content: '';
    position: absolute; right: -4px; bottom: -4px;
    width: 10px; height: 10px;
    background: var(--gold);
    border-radius: 3px;
}

.brand-name { font-weight: 800; letter-spacing: 2px; font-size: 14px; }
.brand-sub  {
    font-size: 12px; color: var(--muted);
    border-left: 1px solid var(--line);
    padding-left: 10px;
}

.topbar-hint { font-size: 12px; color: var(--muted); }

/* ---------- Buehne ---------- */

.stage {
    display: grid;
    grid-template-columns: 1fr 380px;
    height: calc(100% - 58px);
}

.preview-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
}

/* WICHTIG: Das Seitenverhaeltnis sitzt auf dem WRAP (Hoehe gesetzt,
   Breite folgt aus aspect-ratio). Das Poster fuellt den Wrap zu 100 %.
   So gibt es keinen Zirkelbezug zwischen Wrap-Breite und Poster-
   Maximalbreite mehr (Ursache der kollabierten Mini-Vorschau). */
.preview-row {
    display: flex;
    align-items: center;
    gap: 26px;
    max-width: 100%;
}

/* Produktbilder-Leiste (Momenterie-Stil) */
.gallery-rail {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 84vh;
    overflow-y: auto;
    flex: 0 0 auto;
    padding: 4px;
}
.g-thumb {
    width: 62px; height: 62px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    overflow: hidden;
    padding: 0;
    position: relative;
    color: var(--muted);
    transition: border-color .15s, transform .12s;
}
.g-thumb:hover { border-color: var(--gold); transform: scale(1.05); }
.g-thumb.active { border-color: var(--green); box-shadow: 0 0 0 1.5px var(--green); }
.g-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-thumb svg { width: 26px; height: 26px; margin-top: 6px; }
.g-live .lbl {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: var(--green);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 2px 0;
}

/* Foto-Grossansicht (ersetzt die Live-Vorschau) */
.photo-viewer {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 0;
}
.photo-viewer img {
    max-height: 84vh;
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(42, 42, 40, .18);
}

/* Breitenbasiert: die Hoehe folgt IMMER dem A4-Verhaeltnis.
   59.4vh entspricht 84vh Hoehe (84 * 620/877); max-width laesst
   Platz fuer Galerie-Leiste links und Zoom-Buttons rechts. */
.poster-wrap {
    position: relative;
    aspect-ratio: 620 / 877;
    width: 59.4vh;
    max-width: calc(100% - 146px);
    height: auto;
}

.poster {
    position: relative;
    width: 100%;
    height: 100%;
    background: #FAF9F6;              /* wird per JS auf Theme-bg gesetzt */
    box-shadow: 0 18px 50px rgba(42, 42, 40, .18),
                0 2px 8px  rgba(42, 42, 40, .10);
    transition: border-color .18s;
}

/* Bilderrahmen-Vorschau: Rahmen liegt als Border um das Poster.
   box-sizing: border-box => Posterinhalt sitzt "im Rahmen", exakt
   wie beim echten gerahmten Druck. Falz/Glas als Innenschatten. */
.poster-wrap.f-white .poster,
.poster-wrap.f-black .poster,
.poster-wrap.f-oak   .poster {
    border-style: solid;
    border-width: clamp(10px, 2.2vh, 18px);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18),
                inset 0 2px 10px rgba(0, 0, 0, .12),
                0 22px 55px rgba(42, 42, 40, .26),
                0 2px 8px  rgba(42, 42, 40, .12);
}
.poster-wrap.f-white .poster { border-color: #F4F3F0; }
.poster-wrap.f-black .poster { border-color: #1C1C1C; }
.poster-wrap.f-oak .poster {
    border-color: #B98756;
    border-image: linear-gradient(135deg,
        #DCB07A 0%, #B07E4A 38%, #C99C66 62%, #A97843 100%) 1;
}

.map-window {
    position: absolute;
    overflow: hidden;                  /* Kreisform via border-radius */
}
#map { width: 100%; height: 100%; }

/* Lade-Overlay im Kartenbereich */
.map-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(247, 244, 240, .75);
    z-index: 5;
    transition: opacity .25s;
}
.map-loading.hidden { opacity: 0; pointer-events: none; }

.spinner {
    width: 30px; height: 30px;
    border: 3px solid var(--line);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 2s; }
}

.overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;              /* Karte bleibt bedienbar */
    z-index: 6;
}
.overlay svg { width: 100%; height: 100%; display: block; }

/* Zoom-Steuerung rechts neben dem Poster */
.zoom-controls {
    position: absolute;
    right: -50px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.zoom-controls button {
    width: 38px; height: 38px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    font-size: 20px;
    line-height: 1;
    color: var(--ink);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
    transition: border-color .15s, transform .1s;
}
.zoom-controls button:hover  { border-color: var(--gold); }
.zoom-controls button:active { transform: scale(.94); }

.preview-note {
    margin: 14px 0 0;
    font-size: 12px;
    color: var(--muted);
}

/* MapLibre-Logo/Attribution im Poster ausblenden (steht im Footer) */
.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right { display: none; }

/* ---------- Panel / Wizard ---------- */

.panel {
    background: var(--panel);
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Stepper */
.stepper {
    display: flex;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--line);
    gap: 4px;
}
.stepper button {
    flex: 1;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    text-align: center;
}
.stepper .dot {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 2px solid var(--line);
    background: #fff;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    transition: all .15s;
}
.stepper .lbl {
    display: block;
    font-size: 10px;
    color: var(--muted);
    letter-spacing: .5px;
}
.stepper button.done .dot {
    border-color: var(--green);
    color: var(--green);
}
.stepper button.active .dot {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}
.stepper button.active .lbl { color: var(--green); font-weight: 600; }

/* Steps */
.steps {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 0;
}

.step h2 {
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 800;
}

.step h3 {
    margin: 20px 0 10px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--green);
}
.step h3:first-of-type { margin-top: 0; }

.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* Ortssuche */
.search-wrap { position: relative; }

.search-wrap input,
.step label input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-size: 14px;
    background: var(--bg);
}
.search-wrap input:focus,
.step label input[type="text"]:focus {
    outline: 2px solid var(--gold);
    outline-offset: 0;
    border-color: transparent;
}

.suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    margin: 0; padding: 4px;
    list-style: none;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.10);
    z-index: 30;
    max-height: 240px;
    overflow-y: auto;
}
.suggestions li {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.suggestions li small { color: var(--muted); display: block; }
.suggestions li:hover { background: var(--bg); }

/* Chips (Stil, Layout, Format, Schrift, Groesse) */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--gold); }
.chip:focus-visible,
.swatch:focus-visible,
.zoom-controls button:focus-visible,
.stepper button:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}
.chip.active {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

/* Schriftwahl pro Textzeile */
.font-mini {
    display: flex;
    gap: 6px;
    margin: -4px 0 14px;
}
.font-mini .chip {
    padding: 3px 10px;
    font-size: 15px;
    line-height: 1.4;
}

/* Format-Kacheln + Rahmen + Preis (Schritt 4) */
.tile-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.tile {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 10px 12px;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s;
}
.tile:hover { border-color: var(--gold); }
.tile.active { border-color: var(--green); box-shadow: 0 0 0 1.5px var(--green); }
.tile .t-label { display: block; font-size: 14px; font-weight: 600; }
.tile .t-price { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.active .t-price { color: var(--green); font-weight: 600; }
.tile:disabled { opacity: .4; cursor: default; }
.tile:disabled:hover { border-color: var(--line); }

.frame-row { display: flex; gap: 12px; }
.frame-wrap { text-align: center; }
.frame-swatch {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 2px solid var(--line);
    cursor: pointer;
    padding: 0;
    position: relative;
    overflow: hidden;
    transition: transform .12s, border-color .15s;
}
.frame-swatch:hover { transform: scale(1.08); }
.frame-swatch.active { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.frame-swatch.f-none { background: #fff; }
.frame-swatch.f-none::after {
    content: '';
    position: absolute;
    left: -4px; top: 50%;
    width: 44px; height: 2px;
    background: #C4BFB4;
    transform: rotate(-45deg);
}
.frame-swatch.f-white { background: #FDFDFD; }
.frame-swatch.f-black { background: #1A1A1A; }
.frame-swatch.f-oak {
    background: linear-gradient(135deg, #D8AC77 0%, #B07E4A 55%, #C79A63 100%);
}
.frame-name {
    display: block;
    font-size: 10px;
    color: var(--muted);
    margin-top: 4px;
}

.price-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 14px;
}
.price-line strong { font-size: 20px; color: var(--green); }

/* Marker-Symbolwahl */
.chip.symbol {
    width: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 0;
}
.chip.symbol svg { width: 18px; height: 18px; display: block; }
.chip.symbol.active svg { fill: #fff; }

/* Marker-Farbwahl */
.marker-swatch-row { display: flex; gap: 10px; flex-wrap: wrap; }
.marker-swatch {
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 2px solid var(--line);
    cursor: pointer;
    padding: 0;
    transition: transform .12s, border-color .15s;
}
.marker-swatch:hover { transform: scale(1.1); }
.marker-swatch.active {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px var(--gold);
}
.marker-swatch.is-ink {
    background:
        linear-gradient(135deg, #141414 50%, #E9E6DF 50%) !important;
}

/* Farbswatches */
.swatch-row { display: flex; flex-wrap: wrap; gap: 10px; }

.swatch {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 2px solid var(--line);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    padding: 0;
    transition: transform .12s, border-color .15s;
}
.swatch:hover { transform: scale(1.07); }
.swatch.active { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }

.swatch .half-ink   { position: absolute; inset: 0 50% 0 0; }
.swatch .half-bg    { position: absolute; inset: 0 0 0 50%; }
.swatch .dot-water  {
    position: absolute;
    width: 12px; height: 12px;
    border-radius: 50%;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(0,0,0,.08);
}
.swatch-name {
    display: block;
    font-size: 10px;
    color: var(--muted);
    text-align: center;
    margin-top: 4px;
}
.swatch-wrap { text-align: center; }

/* Texte */
.step label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 10px;
}
.step label input[type="text"] { margin-top: 4px; }

label.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--ink);
    cursor: pointer;
    margin-bottom: 8px;
}
label.check input { accent-color: var(--green); }

/* Aktionen (Schritt 5) */
.panel-actions { margin-top: 22px; }

.btn-primary {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 10px;
    background: var(--green);
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.btn-primary:hover  { background: var(--green-dk); }
.btn-primary:disabled { opacity: .55; cursor: default; }

.btn-spinner[hidden] { display: none; }

.btn-spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    display: inline-block;
}

.status {
    margin-top: 10px;
    font-size: 13px;
    min-height: 18px;
    color: var(--muted);
}
.status.ok    { color: var(--green); font-weight: 600; }
.status.error { color: #A13B2A; }

.btn-link {
    margin-top: 6px;
    border: none;
    background: none;
    color: var(--green);
    font: inherit;
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}
.btn-link:hover { color: var(--green-dk); }

/* Wizard-Footer: Zurueck / Weiter */
.wizard-footer {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    background: var(--panel);
}

.btn-back {
    width: 48px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    font-size: 18px;
    color: var(--ink);
    cursor: pointer;
    transition: border-color .15s;
}
.btn-back:hover { border-color: var(--gold); }
.btn-back:disabled { opacity: .4; cursor: default; }

.btn-next {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: var(--green);
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-next:hover { background: var(--green-dk); }

.panel-footer {
    padding: 10px 20px 14px;
    font-size: 11px;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.panel-footer a { color: var(--muted); }
.panel-footer a:hover { color: var(--green); }

/* ---------- Mobile ---------- */

@media (max-width: 900px) {
    html, body { height: auto; }
    .stage {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        height: auto;
    }
    .preview-area { padding: 18px 18px 24px; }
    .preview-row {
        flex-direction: column-reverse;
        height: auto;
        align-items: center;
        gap: 14px;
    }
    .gallery-rail {
        flex-direction: row;
        max-height: none;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
    }
    .g-thumb { width: 52px; height: 52px; }
    .poster-wrap {
        height: auto;
        width: min(78vw, 46vh);
        max-width: none;
    }
    .poster { height: auto; aspect-ratio: 620 / 877; }
    .zoom-controls {
        right: 8px;
        top: auto;
        bottom: 8px;
        transform: none;
    }
    .panel { border-left: none; border-top: 1px solid var(--line); }
    .topbar-hint { display: none; }
    .steps { min-height: 40vh; }

    /* Weiter-Leiste bleibt sichtbar */
    .wizard-footer {
        position: sticky;
        bottom: 0;
        box-shadow: 0 -6px 16px rgba(0,0,0,.05);
        z-index: 20;
    }
}
