/**
 * Modernisiertes Popup-System (v3.11)
 * Pfad: system/popup.css
 *
 * EIN Design für alle Popups projektweit. Wird in system/popup.php
 * verwendet. JS für Drag/Escape/Resize-Handling: system/popup.js.
 *
 * Verhalten:
 *  - Helles Theme (weißer Body, Header in Akzentfarbe)
 *  - Resize an unterer rechter Ecke (CSS resize: both)
 *  - Drag-and-drop am Header (JS)
 *  - Escape schließt
 *  - Backdrop-Klick schließt NICHT (Default; opt-in im Aufruf)
 *  - Mobile <768px: immer Vollbild, kein Drag/Resize
 */

#popup {
    position: fixed;
    width: 0%;
    height: 0%;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.5);
    overflow: hidden;
    z-index: 1200; /* Über nav-toggle (1001), unter login (1500) */
}

#popup.popup-aktiv {
    width: 100%;
    height: 100%;
}

#popup .rahmenpopup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    width: min(1100px, 90vw);
    height: min(720px, 85vh);
    min-width: 400px;
    min-height: 300px;
    max-width: 95vw;
    max-height: 95vh;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    resize: both;
    /* Wichtig: border-box damit beim Drag die per JS gesetzte Breite (aus getBoundingClientRect inkl. Border)
       nicht zur Content-Breite addiert wird → verhinderte +2px-Wachstum pro Verschiebung */
    box-sizing: border-box;
}

/* Beim Drag wird die Position über inline-Styles gesetzt; transform muss raus */
#popup .rahmenpopup.popup-verschoben {
    transform: none;
}

#popup .leiste {
    flex: 0 0 auto;
    background: var(--farbehaupt, #627E91);
    color: #fff;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

#popup .leiste a {
    flex: 0 0 auto;
    cursor: pointer;
    color: #fff;
    text-decoration: none;
    font-size: 22px;
    line-height: 1;
    padding: 0 4px;
    opacity: 0.85;
}

#popup .leiste a:hover {
    opacity: 1;
}

#popup .leiste a img {
    display: none; /* altes X-Bild aus popup.php nicht zeigen, wir nutzen Text-X */
}

#popup .leiste a::after {
    content: '\00D7';            /* multiplication sign = X */
    display: inline-block;
}

#popupleiste {
    flex: 1;
    color: #fff;
    font-weight: bold;
    font-size: 15px;
    padding-right: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#popup #popupinhalt {
    flex: 1;
    background: #fff;
    color: #333;
    padding: 18px;
    overflow: auto;
    min-height: 0;
}

#popup h2 {
    color: #333;
    margin-top: 0;
}

#popup h3, #popup h4 {
    color: #333;
}

/* Mobile: Vollbild, kein Drag/Resize/Border */
@media (max-width: 768px) {
    #popup .rahmenpopup {
        top: 0;
        left: 0;
        transform: none;
        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 0;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
        resize: none;
    }

    #popup .leiste {
        cursor: default;
        border-radius: 0;
    }
}
