/* ============================================================================
 * textur-konfigurator.css
 * Oberflaeche der Textur-Vorschau. Farbwelt 1:1 aus der bestehenden Seite
 * uebernommen (Amber #ffc107, helle Flaechen, Font Awesome als Icon-Satz).
 *
 * Aufbau: vier Schritte, gefuehrt ueber die Pfeilkette oben. Je Schritt ist
 * genau eine Tafel sichtbar - das haelt die Bedienung auch auf dem Handy
 * uebersichtlich, wo alles untereinander steht.
 *
 * Developed by Toni Sciacca - mail@tonisciacca.com
 * ========================================================================== */

.tk-section {
    padding: 46px 0 80px;
    background: #fff;
    /* Die Seite hat eine feste Navigationsleiste. Ohne diesen Abstand
     * verschwindet die Pfeilkette darunter, sobald zum Schritt gerollt wird. */
    scroll-margin-top: 110px;
}

/* ── Rahmen ──────────────────────────────────────────────────────────────────
 * Bewusst ein eigener Name. ".container" gibt es nicht in jeder Vorlage:
 * auf expresspolsterei.de existiert die Klasse gar nicht, dort lief die
 * Sektion ueber die ganze Fensterbreite. So haengt der Konfigurator an
 * keiner fremden Klasse mehr.
 */
.tk-container {
    width: 89%;
    max-width: 1340px;
    margin: 0 auto;
}

.tk-pfeile { scroll-margin-top: 110px; }

/* ── Pfeilkette ───────────────────────────────────────────────────────────── */
.tk-pfeile {
    display: flex;
    gap: 4px;
    margin-bottom: 26px;
}

.tk-pfeil {
    flex: 1 1 0;
    min-width: 0;
    border: none;
    text-align: center;
    padding: 13px 8px;
    font-size: .84rem;
    font-weight: 700;
    font-family: inherit;
    background: #eef2f6;
    color: #94a3b8;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    /* Pfeilform: rechts eine Spitze, links die passende Kerbe */
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%);
}
.tk-pfeil:first-child { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); }
.tk-pfeil:last-child  { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 12px 50%); }

.tk-pfeil-nr {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,.7);
    color: #94a3b8;
    font-size: .74rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 22px;
}
.tk-pfeil-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tk-pfeil.done {
    background: rgba(255,193,7,.18);
    color: #a97a00;
    cursor: pointer;
}
.tk-pfeil.done .tk-pfeil-nr { background: #ffc107; color: #fff; }
.tk-pfeil.done:hover { background: rgba(255,193,7,.3); }

.tk-pfeil.cur {
    background: #ffc107;
    color: #fff;
}
.tk-pfeil.cur .tk-pfeil-nr { background: rgba(255,255,255,.9); color: #a97a00; }

/* ── Spalten ──────────────────────────────────────────────────────────────── */
.tk-wrap {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 28px;
    align-items: start;
}

.tk-steuerung {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 22px;
}

.tk-vorschau { min-width: 0; }

/* ── Tafelkopf ────────────────────────────────────────────────────────────── */
.tk-panel-kopf { margin-bottom: 16px; }
.tk-panel-kopf b {
    display: block;
    font-size: 1.02rem;
    color: #333;
    margin-bottom: 5px;
}
.tk-panel-kopf span {
    display: block;
    font-size: .86rem;
    line-height: 1.6;
    color: #6b7280;
}
.tk-panel-kopf span b { display: inline; font-size: inherit; color: #333; }

/* ── Upload ───────────────────────────────────────────────────────────────── */
.tk-upload {
    border: 2px dashed #ddd;
    border-radius: 10px;
    background: #fff;
    padding: 34px 18px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.tk-upload:hover,
.tk-upload.drag { border-color: #ffc107; background: #fffdf3; }
.tk-upload i { font-size: 36px; color: #ffc107; display: block; margin-bottom: 10px; }
.tk-upload p { margin: 0; font-size: 14px; color: #666; }
.tk-upload .tk-klein { margin-top: 6px; font-size: 12px; color: #aaa; }

/* ── Texturbibliothek ─────────────────────────────────────────────────────── */
.tk-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tk-tab {
    border: 1px solid #e0e0e0;
    background: #fff;
    color: #666;
    border-radius: 20px;
    padding: 7px 15px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .15s;
}
.tk-tab:hover { border-color: #ffc107; color: #333; }
.tk-tab.active { background: #ffc107; border-color: #ffc107; color: #fff; }

.tk-gitter {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #fff;
    -webkit-overflow-scrolling: touch;
}
.tk-gitter-leer {
    grid-column: 1 / -1;
    text-align: center;
    padding: 22px;
    color: #aaa;
    font-size: 13px;
}

.tk-textur {
    position: relative;
    border: 2px solid transparent;
    border-radius: 7px;
    overflow: hidden;
    cursor: pointer;
    background: #f8f9fa;
    transition: border-color .15s, transform .15s;
}
.tk-textur:hover { transform: translateY(-2px); }
.tk-textur img { width: 100%; height: 66px; object-fit: cover; display: block; }
.tk-textur-name {
    display: block;
    font-size: 10px;
    line-height: 1.3;
    padding: 5px;
    color: #666;
    background: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tk-textur-haken {
    position: absolute;
    top: 4px; right: 4px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #ffc107;
    color: #fff;
    font-size: 10px;
    display: none;
    align-items: center;
    justify-content: center;
}
.tk-textur.selected { border-color: #ffc107; }
.tk-textur.selected .tk-textur-haken { display: flex; }

/* ── Werkzeuge ────────────────────────────────────────────────────────────── */
.tk-werkzeuge {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 14px;
    margin-top: 12px;
}
.tk-werkzeug-reihe { display: flex; gap: 6px; margin-bottom: 14px; }
.tk-werkzeug {
    flex: 1;
    border: 1px solid #e0e0e0;
    background: #fff;
    color: #666;
    border-radius: 8px;
    padding: 12px 4px;
    font-size: 11.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .15s;
    min-height: 62px;
}
.tk-werkzeug i,
.tk-werkzeug .tk-zeichen { display: block; font-size: 19px; line-height: 1; margin-bottom: 5px; }
.tk-werkzeug .tk-zeichen { font-weight: 700; }
.tk-werkzeug:hover { border-color: #ffc107; color: #333; }
.tk-werkzeug.active { background: #ffc107; border-color: #ffc107; color: #fff; }

.tk-regler { margin-bottom: 13px; }
.tk-regler:last-child { margin-bottom: 0; }
.tk-regler-kopf {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}
.tk-regler-kopf b { color: #333; font-weight: 600; }
.tk-regler input[type=range] {
    width: 100%;
    accent-color: #ffc107;
    margin: 0;
    height: 26px;
}

.tk-feld {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 7px;
    padding: 11px 12px;
    font-size: 15px;          /* darunter zoomt iOS beim Antippen hinein */
    font-family: inherit;
    color: #333;
    background: #fff;
}
.tk-feld:focus { outline: none; border-color: #ffc107; }

.tk-neben { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tk-klein-btn {
    flex: 1 1 90px;
    border: 1px solid #e0e0e0;
    background: #fff;
    color: #666;
    border-radius: 7px;
    padding: 11px 8px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}
.tk-klein-btn:hover:not(:disabled) { border-color: #ffc107; color: #333; }
.tk-klein-btn:disabled { opacity: .45; cursor: default; }

/* Aufklapper fuer Zusaetzliches (Hilfe, Feineinstellung) */
.tk-mehr {
    width: 100%;
    margin-top: 14px;
    border: none;
    background: none;
    color: #a97a00;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    text-align: left;
    padding: 8px 0;
    cursor: pointer;
}
.tk-mehr:hover { color: #7a5c00; text-decoration: underline; }

/* ── Buehne ───────────────────────────────────────────────────────────────── */
.tk-buehne {
    position: relative;
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 12px;
    overflow: hidden;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tk-buehne canvas { max-width: 100%; height: auto; display: block; }

#tkCanvasFoto { display: none; }

#tkBuehne {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
}

#tkCanvasErgebnis {
    cursor: crosshair;
    /*
     * pan-y laesst das senkrechte Rollen durch. Mit touch-action: none blieb
     * die Seite stehen, sobald der Finger auf dem Foto lag - kein Tester kam
     * damit weiter. Gesperrt wird nur waehrend des Streichens, siehe
     * .tk-malmodus.
     */
    touch-action: pan-y;
    border-radius: 8px;
}

/* Markierung liegt deckungsgleich ueber dem Bild, nur waehrend der Bearbeitung. */
#tkCanvasMaske {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    display: none;
    border-radius: 8px;
}
#tkBuehne.tk-maske-an #tkCanvasMaske { display: block; }

.tk-platzhalter { text-align: center; color: #aaa; padding: 56px 20px; }
.tk-platzhalter i { font-size: 44px; color: #e0e0e0; display: block; margin-bottom: 12px; }
.tk-platzhalter p { margin: 0; font-size: 14px; line-height: 1.6; }

.tk-laden {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 4;
}
.tk-spinner {
    width: 38px; height: 38px;
    border: 3px solid #f0f0f0;
    border-top-color: #ffc107;
    border-radius: 50%;
    animation: tkDreh .8s linear infinite;
}
@keyframes tkDreh { to { transform: rotate(360deg); } }
.tk-laden p { margin: 0; font-size: 13px; color: #666; text-align: center; padding: 0 20px; }

/* ── Pinselumfang ─────────────────────────────────────────────────────────── */
.tk-pinsel-ring {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    display: none;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 1px rgba(0,0,0,.35);
    z-index: 3;
}
.tk-pinsel-ring.tk-hinzu { border: 2px solid #ffc107; background: rgba(255,193,7,.18); }
.tk-pinsel-ring.tk-weg   { border: 2px dashed #e53935; background: rgba(229,57,53,.12); }

/* ── Hinweise ─────────────────────────────────────────────────────────────── */
.tk-hinweis {
    margin-top: 12px;
    padding: 11px 14px;
    border-radius: 8px;
    background: #fffdf3;
    border: 1px solid #ffe9a8;
    color: #7a5c00;
    font-size: 13.5px;
    line-height: 1.55;
}
.tk-hinweis-fehler { background: #fdf2f2; border-color: #f5c6c6; color: #a02020; }

.tk-rapport-info { margin-top: 10px; font-size: 12px; color: #888; line-height: 1.5; }
.tk-rapport-info i { color: #ffc107; }

/* ── Hilfe ────────────────────────────────────────────────────────────────── */
.tk-hilfe {
    margin-top: 10px;
    padding: 14px;
    border: 1px solid #ffe9a8;
    border-radius: 8px;
    background: #fffdf3;
    display: grid;
    gap: 14px;
}
.tk-hilfe-punkt { display: flex; gap: 12px; align-items: flex-start; }
.tk-hilfe-nr {
    flex: 0 0 26px;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: #ffc107;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.tk-hilfe-punkt > div { font-size: 13px; line-height: 1.6; color: #6b5a2e; }
.tk-hilfe-punkt b { display: block; color: #333; font-size: 13.5px; margin-bottom: 2px; }
.tk-hilfe-punkt div b:not(:first-child) { display: inline; font-size: inherit; margin: 0; }

/* ── Schaltflaechen ───────────────────────────────────────────────────────── */
.tk-btn {
    border: none;
    border-radius: 8px;
    padding: 14px 18px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    transition: filter .15s;
}
.tk-btn:hover:not(:disabled) { filter: brightness(.94); }
.tk-btn:disabled { opacity: .45; cursor: default; }
.tk-btn-haupt { background: #ffc107; color: #fff; }
.tk-btn-neben { background: #fff; color: #666; border: 1px solid #e0e0e0; }
.tk-btn-neben:hover:not(:disabled) { border-color: #ffc107; color: #333; }

.tk-weiter { width: 100%; margin-top: 16px; }

/* ── Anfrage ──────────────────────────────────────────────────────────────── */
.tk-anfrage { display: grid; gap: 9px; }
.tk-anfrage textarea { resize: vertical; }

/* ── Handy und Tablet ─────────────────────────────────────────────────────── */
@media (max-width: 991px) {
    .tk-section { padding: 26px 0 44px; }

    .tk-wrap { grid-template-columns: 1fr; gap: 18px; }

    /* Bild nach oben: beim Markieren muss man sehen, was man tut, ohne
     * zwischen Werkzeug und Vorschau hin und her zu scrollen. */
    .tk-vorschau { order: -1; }

    .tk-steuerung { padding: 18px; }

    /* Pfeile bleiben nebeneinander, notfalls waagerecht scrollbar */
    .tk-pfeile {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin-bottom: 18px;
    }
    .tk-pfeile::-webkit-scrollbar { display: none; }
    .tk-pfeil {
        flex: 1 0 auto;
        min-width: 78px;
        font-size: .78rem;
        padding: 11px 6px;
        gap: 5px;
    }
    .tk-pfeil-nr { width: 19px; height: 19px; flex-basis: 19px; font-size: .68rem; }

    .tk-gitter {
        grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
        max-height: 264px;
    }
    .tk-textur img { height: 74px; }

    .tk-werkzeug { min-height: 68px; font-size: 12px; }
    .tk-klein-btn { padding: 13px 8px; }
    .tk-btn { padding: 15px 18px; font-size: 15px; }
}

@media (max-width: 420px) {
    .tk-pfeil { min-width: 66px; font-size: .72rem; }
    .tk-pfeil-txt { display: none; }
    .tk-pfeil.cur .tk-pfeil-txt { display: inline; }
}

/* ── Wegwahl nach dem Upload ───────────────────────────────────────────────
 * Zwei Wege zum Ziel: die KI macht alles allein, oder der Kunde markiert die
 * Flaeche und bekommt dafuer den Stoff originalgetreu. */
.tk-weg {
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 10px;
    padding: 15px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.tk-weg:hover { border-color: #ffc107; box-shadow: 0 3px 10px rgba(0,0,0,.05); }
.tk-weg-kopf {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 15px;
    font-weight: 700;
    color: #333;
    margin-bottom: 6px;
}
.tk-weg-kopf i { color: #ffc107; }
.tk-weg-tipp {
    margin-left: auto;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    background: #ffc107;
    color: #fff;
    border-radius: 999px;
    padding: 3px 9px;
}
.tk-weg-tipp-grau { background: #e9ecef; color: #6b7280; }
.tk-weg-txt { display: block; font-size: 13px; line-height: 1.55; color: #6b7280; }

/* Beim KI-Weg entfaellt das Markieren - der Schritt bleibt sichtbar,
 * aber blass und nicht anspringbar. */
.tk-pfeil.tk-uebersprungen { opacity: .45; }

/* ── Bauteile einzeln behandeln (nur im KI-Weg) ───────────────────────────── */
.tk-teile-hinweis {
    margin: 0 0 12px;
    font-size: 12.5px;
    line-height: 1.55;
    color: #7a5c00;
    background: #fffdf3;
    border: 1px solid #ffe9a8;
    border-radius: 7px;
    padding: 9px 11px;
}
.tk-teil {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 9px;
}
.tk-teil > span {
    flex: 0 0 108px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}
.tk-teil .tk-feld { flex: 1; padding: 9px 10px; }

@media (max-width: 991px) {
    .tk-teil { flex-wrap: wrap; gap: 5px; }
    .tk-teil > span { flex: 1 1 100%; }
}

/* ── Masseingabe ──────────────────────────────────────────────────────────
 * Steht bewusst weit vorn: ohne die reale Breite laesst sich nicht
 * ausrechnen, wie gross das Stoffmuster im Foto erscheinen muss. */
.tk-masse {
    background: #fffdf3;
    border: 1px solid #ffe9a8;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
}
.tk-masse label b {
    display: block;
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
}
.tk-masse label span {
    display: block;
    font-size: 12.5px;
    line-height: 1.55;
    color: #7a5c00;
    margin-bottom: 10px;
}
.tk-masse-feld { display: flex; align-items: center; gap: 9px; }
.tk-masse-feld .tk-feld { flex: 1; font-size: 17px; font-weight: 600; text-align: center; }
.tk-masse-feld .tk-einheit { font-size: 14px; font-weight: 600; color: #7a5c00; flex: 0 0 auto; }
.tk-masse-feld .tk-feld:invalid { border-color: #ddd; }

/* ── Wegwahl gesperrt, solange die Breite fehlt ───────────────────────────
   Ohne das Mass laesst sich die Musterskalierung nicht berechnen; die
   beiden Knoepfe waeren dann eine Sackgasse. */
.tk-weg:disabled {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}

/* Waehrend Pinsel oder Radierer aktiv sind, darf die Seite nicht mitrollen. */
#tkCanvasErgebnis.tk-malmodus { touch-action: none; }

/* Der Auslöser steht jetzt ueber der Stoffliste und braucht Luft nach unten,
   sonst klebt die Kategorienreihe daran. */
#tkNeulauf { margin-bottom: 18px; }
