
/* =========================================================
   PAULSOFT 3D VIEWER
   Vollständiges Stylesheet für 3DHOP 4.3
   ========================================================= */


/* =========================================================
   1. PAULSOFT DESIGN-VARIABLEN
   ========================================================= */

:root {
    --paulsoft-primary: #123B8F;
    --paulsoft-primary-dark: #0D1F3D;
    --paulsoft-primary-soft: #E8EEF9;
    --paulsoft-accent: #E53935;
    --paulsoft-background: #F5F7FA;
    --paulsoft-surface: #FFFFFF;
    --paulsoft-text: #2E3440;
    --paulsoft-border: #D9DEE7;
    --ps-radius-l: 16px;
    --viewer-shadow: 0 8px 28px rgba(13, 31, 61, 0.06);
    --viewer-panel-shadow: 0 10px 28px rgba(13, 31, 61, 0.14);
}


/* =========================================================
   2. GRUNDLAGEN
   ========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--paulsoft-text);
    background: var(--paulsoft-background);
}

button,
select,
input {
    font: inherit;
}

[hidden] {
    display: none !important;
}


/* =========================================================
   3. SEITENLAYOUT
   ========================================================= */

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}


/* =========================================================
   4. KOPFBEREICH
   ========================================================= */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    min-height: 76px;
    gap: 16px;
    padding: 14px 24px;
    background: var(--paulsoft-surface);
    border-bottom: 1px solid var(--paulsoft-border);
}

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

.brandmark {
    color: var(--paulsoft-primary);
    font-size: 30px;
    line-height: 1;
}

.brand strong {
    display: block;
    color: var(--paulsoft-primary-dark);
    font-size: 17px;
    font-weight: 700;
}

.brand small {
    display: block;
    margin-top: 3px;
    color: #64748B;
    font-size: 12px;
}

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

    .modelpicker label,
    #status {
        color: #64748B;
        font-size: 12px;
    }

    .modelpicker select {
        max-width: 45vw;
        padding: 10px 14px;
        background: #FFFFFF;
        color: var(--paulsoft-text);
        border: 1px solid var(--paulsoft-border);
        border-radius: 6px;
    }

        .modelpicker select:focus-visible {
            outline: 3px solid var(--paulsoft-primary-soft);
            border-color: var(--paulsoft-primary);
        }


/* =========================================================
   5. VIEWER-BEREICH
   ========================================================= */

.stage {
    display: flex;
    flex: 1;
    min-height: 0;
    padding: 20px;
}

.viewer-card {
    position: relative;
    isolation: isolate;
    flex: 1;
    min-width: 0;
    min-height: 420px;
    overflow: hidden;
    background: var(--paulsoft-surface);
    border: 1px solid var(--paulsoft-border);
    border-radius: var(--ps-radius-l);
    box-shadow: var(--viewer-shadow);
}


/* =========================================================
   6. 3DHOP-CANVAS
   ========================================================= */

.tdhop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#draw-canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: transparent !important;
}

    #draw-canvas.measure-cursor {
        cursor: crosshair;
    }

#tdhlg {
    display: none !important;
}


/* =========================================================
   7. WERKZEUGLEISTE
   ========================================================= */

.tools {
    position: absolute;
    z-index: 30;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    max-width: calc(100% - 24px);
    gap: 7px;
    padding: 9px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--paulsoft-border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(13, 31, 61, 0.12);
}


    /* =========================================================
   8. BUTTONS – NORMALZUSTAND
   ========================================================= */

    .tools button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        flex: 0 0 42px;
        padding: 6px;
        background-color: #FFFFFF;
        color: var(--paulsoft-primary);
        border: 1px solid var(--paulsoft-border);
        border-radius: 6px;
        font-size: 20px;
        font-weight: 600;
        line-height: 1;
        cursor: pointer;
        /* Keine Bewegung oder Größenänderung */
        transform: none !important;
        /* Nur Farbwechsel animieren */
        transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
    }


        /* =========================================================
   9. SVG-ICONS
   ========================================================= */

        .tools button svg {
            display: block;
            width: 21px;
            height: 21px;
            flex-shrink: 0;
            fill: none;
            stroke: currentColor;
            stroke-width: 1.8;
            stroke-linecap: round;
            stroke-linejoin: round;
            pointer-events: none;
        }


        /* =========================================================
   10. BUTTONS – HOVER
   ========================================================= */

        .tools button:hover:not(:disabled) {
            background-color: var(--paulsoft-primary);
            border-color: var(--paulsoft-primary);
            color: #FFFFFF;
            /* Kein Hochspringen */
            transform: none !important;
        }


        /* =========================================================
   11. BUTTONS – AKTIV
   ========================================================= */

        /*
   Gilt für alle Werkzeuge:
   Licht, Messung, Kamera, Schnitt usw.
*/

        .tools button.active,
        .tools button.is-active,
        .tools button[aria-pressed="true"] {
            background-color: var(--paulsoft-primary);
            border-color: var(--paulsoft-primary);
            color: #FFFFFF;
        }


            /* =========================================================
   12. BUTTONS – AKTIV + HOVER
   ========================================================= */

            .tools button.active:hover:not(:disabled),
            .tools button.is-active:hover:not(:disabled),
            .tools button[aria-pressed="true"]:hover:not(:disabled) {
                background-color: var(--paulsoft-primary-dark);
                border-color: var(--paulsoft-primary-dark);
                color: #FFFFFF;
                transform: none !important;
            }


/* =========================================================
   13. MESSBUTTON – EBENFALLS BLAU
   ========================================================= */

/*
   Diese Regeln stellen sicher, dass alte rote
   Messbutton-Formatierungen nicht benötigt werden.
*/

.viewer-card .tools button#measure {
    background-color: #FFFFFF;
    border-color: var(--paulsoft-border);
    color: var(--paulsoft-primary);
}

    .viewer-card .tools button#measure:hover:not(:disabled) {
        background-color: var(--paulsoft-primary);
        border-color: var(--paulsoft-primary);
        color: #FFFFFF;
    }

    .viewer-card .tools button#measure.active,
    .viewer-card .tools button#measure.is-active,
    .viewer-card .tools button#measure[aria-pressed="true"] {
        background-color: var(--paulsoft-primary);
        border-color: var(--paulsoft-primary);
        color: #FFFFFF;
    }

        .viewer-card .tools button#measure.active:hover:not(:disabled),
        .viewer-card .tools button#measure.is-active:hover:not(:disabled),
        .viewer-card .tools button#measure[aria-pressed="true"]:hover:not(:disabled) {
            background-color: var(--paulsoft-primary-dark);
            border-color: var(--paulsoft-primary-dark);
            color: #FFFFFF;
        }


/* =========================================================
   14. BUTTONS – FOKUS, DISABLED, HIDDEN
   ========================================================= */

.tools button:focus-visible {
    outline: 3px solid var(--paulsoft-primary);
    outline-offset: 2px;
}

.tools button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.tools button[hidden] {
    display: none !important;
}


/* =========================================================
   15. TRENNLINIEN
   ========================================================= */

.tooldiv {
    width: 1px;
    height: 26px;
    flex: 0 0 1px;
    margin: 0 2px;
    background: var(--paulsoft-border);
}


/* =========================================================
   16. ALLGEMEINE PANELS
   ========================================================= */

.viewer-panel {
    position: absolute;
    z-index: 25;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid var(--paulsoft-border);
    border-radius: 12px;
    box-shadow: var(--viewer-panel-shadow);
    color: var(--paulsoft-text);
    font-size: 13px;
}

    .viewer-panel strong {
        color: var(--paulsoft-primary-dark);
    }


/* =========================================================
   17. MESSPANEL
   ========================================================= */

.measure-panel {
    top: 18px;
    right: 18px;
    display: flex;
    flex-direction: column;
    max-width: calc(100% - 36px);
    gap: 8px;
    padding: 14px 18px;
    border-left: 4px solid var(--paulsoft-accent);
}

    .measure-panel strong {
        color: var(--paulsoft-accent);
    }

#measureOutput {
    color: var(--paulsoft-text);
    font-size: 14px;
    font-weight: 600;
}


/* =========================================================
   18. SCHNITTDARSTELLUNG
   ========================================================= */

.clipping-panel {
    top: 18px;
    right: 18px;
    width: 340px;
    max-width: calc(100% - 36px);
    max-height: calc(100% - 105px);
    overflow-y: auto;
    padding: 18px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.panel-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: #FFFFFF;
    color: var(--paulsoft-primary);
    border: 1px solid var(--paulsoft-border);
    border-radius: 6px;
    font-size: 23px;
    line-height: 1;
    cursor: pointer;
}

    .panel-close:hover {
        background: var(--paulsoft-primary);
        border-color: var(--paulsoft-primary);
        color: #FFFFFF;
    }

.clip-axis {
    margin-bottom: 18px;
}

.clip-axis-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 9px;
}

    .clip-axis-header > label:first-child {
        margin-right: auto;
        color: var(--paulsoft-primary);
        font-weight: 700;
    }

    .clip-axis-header label,
    .clip-options label {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        font-size: 12px;
        cursor: pointer;
    }

.clipping-panel input[type="checkbox"] {
    accent-color: var(--paulsoft-primary);
}

.clipping-panel input[type="range"] {
    display: block;
    width: 100%;
    margin: 0;
    accent-color: var(--paulsoft-primary);
    cursor: pointer;
}

.clip-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--paulsoft-border);
}

.panel-reset {
    width: 100%;
    margin-top: 18px;
    padding: 10px 14px;
    background: var(--paulsoft-primary-soft);
    color: var(--paulsoft-primary);
    border: 1px solid var(--paulsoft-border);
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

    .panel-reset:hover {
        background: var(--paulsoft-primary);
        border-color: var(--paulsoft-primary);
        color: #FFFFFF;
    }

.viewer-panel button:focus-visible {
    outline: 3px solid var(--paulsoft-primary);
    outline-offset: 2px;
}


/* =========================================================
   19. BEDIENHINWEISE
   ========================================================= */

.hint {
    position: absolute;
    z-index: 5;
    top: 18px;
    left: 18px;
    max-width: calc(100% - 36px);
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.88);
    color: #64748B;
    border: 1px solid var(--paulsoft-border);
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.5;
    pointer-events: none;
}

/* Desktop: Mausbedienung */

.hint-desktop {
    display: inline;
}

.hint-touch {
    display: none;
}

/* Touchgeräte: Fingerbedienung */

@media (hover: none) and (pointer: coarse) {

    .hint-desktop {
        display: none;
    }

    .hint-touch {
        display: inline;
    }

    .hint {
        max-width: calc(100% - 20px);
        font-size: 11px;
    }
}


/* =========================================================
   20. BRICKS-EINBETTUNG
   ========================================================= */

body.embed .topbar {
    display: none;
}

body.embed .app {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
}

body.embed .stage {
    padding: 0;
}

body.embed .viewer-card {
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}


/* =========================================================
   21. VOLLBILD
   ========================================================= */

.viewer-card:fullscreen {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    background: var(--paulsoft-surface);
    border: 0;
    border-radius: 0;
}

    .viewer-card:fullscreen .tools {
        z-index: 30;
        bottom: 22px;
    }

    .viewer-card:fullscreen .viewer-panel {
        z-index: 25;
    }

    .viewer-card:fullscreen .hint {
        z-index: 5;
    }


/* =========================================================
   22. MOBILE ANSICHT
   ========================================================= */

@media (max-width: 700px) {

    .topbar {
        gap: 10px;
        padding: 12px;
    }

    .brand strong {
        font-size: 14px;
    }

    .brand small,
    #status,
    .modelpicker label {
        display: none;
    }

    .modelpicker select {
        max-width: 52vw;
        font-size: 12px;
    }

    .stage {
        padding: 8px;
    }

    .viewer-card {
        min-height: 360px;
    }

    .tools {
        bottom: 10px;
        max-width: calc(100% - 16px);
        gap: 5px;
        padding: 7px;
    }

        .tools button {
            width: 36px;
            height: 36px;
            flex-basis: 36px;
            padding: 5px;
        }

            .tools button svg {
                width: 19px;
                height: 19px;
            }

    .tooldiv {
        height: 22px;
        margin: 0 1px;
    }

    .hint {
        top: 10px;
        left: 10px;
        font-size: 10px;
    }

    .clipping-panel {
        top: 10px;
        right: 10px;
        max-width: calc(100% - 20px);
        max-height: calc(100% - 115px);
    }

    .measure-panel {
        top: 10px;
        right: 10px;
    }
}


/* =========================================================
   23. KLEINE MOBILGERÄTE
   ========================================================= */

@media (max-width: 400px) {

    .tools {
        gap: 4px;
        padding: 6px;
    }

        .tools button {
            width: 34px;
            height: 34px;
            flex-basis: 34px;
        }

            .tools button svg {
                width: 18px;
                height: 18px;
            }

    .tooldiv {
        margin: 0;
    }

    .clipping-panel {
        padding: 14px;
    }
}


/* =========================================================
   24. REDUZIERTE ANIMATIONEN
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .tools button {
        transition: none;
    }
}


/* =========================================================
   25. MOBILE EINBETTUNG – WERKZEUGLEISTE
   ========================================================= */

@media (max-width: 700px) {
    body.embed .tools {
        left: 20px;
        right: 20px;
        bottom: 24px;
        width: auto;
        max-width: none;
        transform: none;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 5px;
        padding: 7px;
    }

        body.embed .tools button {
            width: 100%;
            min-width: 0;
            height: 38px;
            flex: none;
        }

        body.embed .tools .tooldiv {
            display: none;
        }
}

@media (max-width: 350px) {
    body.embed .tools {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* =========================================================
   26. BEDIENHINWEIS – GRÖSSER UND ZENTRIERT
   ========================================================= */

.hint {
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 24px);
    text-align: center;
    font-size: 13px;
    line-height: 1.6;
    padding: 10px 14px;
}

@media (max-width: 700px) {
    .hint {
        top: 12px;
        left: 50%;
        width: calc(100% - 24px);
        max-width: none;
        font-size: 13px;
        line-height: 1.5;
        padding: 10px 12px;
    }
}


/* iPhone: bildschirmfüllender Viewer */

.viewer-card.ps-mobile-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    z-index: 2147483647 !important;
    overflow: hidden !important;
}

