/*
 * CSS: POPUP
 * Gemeinsamer Standard für alle Dialoge im Admin- und Kundenportal.
 * Größen werden über ui-popup--compact / --medium / --wide / --license / --smtp gesteuert.
 */

.ui-popup,
.ui-popup * {
    box-sizing: border-box;
}

.ui-popup {
    width: min(360px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    min-width: 0;

    height: fit-content;
    min-height: 0;
    max-height: calc(100dvh - 32px);

    margin: auto;
    padding: 0;

    overflow-x: hidden;
    overflow-y: auto;

    color: var(--text);
    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 10px;

    box-shadow: 0 30px 100px rgba(0, 0, 0, .65);
}

.ui-popup::backdrop {
    background: rgba(0, 0, 0, .72);
}

/* Größenvarianten: Inhalt und Buttons bleiben identisch. */
.ui-popup--compact {
    width: min(360px, calc(100vw - 32px));
}

.ui-popup--medium {
    width: min(430px, calc(100vw - 32px));
}

.ui-popup--wide {
    width: min(520px, calc(100vw - 32px));
}

.ui-popup--license,
.ui-popup--smtp {
    width: min(460px, calc(100vw - 32px));
}

.ui-popup--license {
    max-height: calc(100dvh - 24px);
}

/* Einheitlicher Dialogkörper. */
.ui-popup > form,
.ui-popup > .ui-popup-shell,
.ui-popup > .ui-popup-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 10px;

    width: 100%;
    min-width: 0;
    max-width: 100%;

    margin: 0;
    padding: 16px 18px;
}

/* Inhalte, die innerhalb eines standardisierten Formular-Shells liegen. */
.ui-popup .ui-popup-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 10px;

    width: 100%;
    min-width: 0;
    max-width: 100%;

    margin: 0;
    padding: 0;
}

.ui-popup .ui-popup-content h2,
.ui-popup .ui-popup-content li {
    white-space: normal;
    overflow-wrap: anywhere;
}

.ui-popup .ui-popup-content ul,
.ui-popup .ui-popup-list {
    min-width: 0;
    margin: 0;
    padding-left: 20px;
}

.ui-popup .ui-popup-content li {
    margin-bottom: 10px;
    font-weight: normal;
}

.ui-popup .ui-popup-action-list {
    list-style: none;
    padding: 0 !important;
}

.ui-popup-list-item,
.ui-popup-list-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;

    min-width: 0;
}

.ui-popup-list-text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.ui-popup .eyebrow {
    margin: 0;
    font-size: .68rem;
    line-height: 1.15;
}

.ui-popup h2 {
    margin: 0 0 4px;
    font-size: 1.08rem;
    line-height: 1.2;
}

.ui-popup p {
    margin: 0;
    font-size: .80rem;
    line-height: 1.4;
}

.ui-popup .muted {
    color: var(--muted);
}

.ui-popup label {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;

    min-width: 0;
    margin: 0;

    font-size: .78rem;
    line-height: 1.3;
}

.ui-popup input[type="text"],
.ui-popup input[type="email"],
.ui-popup input[type="password"],
.ui-popup input[type="number"],
.ui-popup input[type="search"],
.ui-popup input[type="tel"],
.ui-popup input[type="url"],
.ui-popup input[type="date"],
.ui-popup select,
.ui-popup textarea {
    display: block;

    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 34px;
    height: 34px;

    padding: 6px 9px;

    box-sizing: border-box;
    font: inherit;
    font-size: .82rem;
}

.ui-popup textarea {
    height: auto;
    min-height: 60px;
    resize: vertical;
}

.ui-popup input[type="checkbox"],
.ui-popup input[type="radio"] {
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 0;
    padding: 0;
}

/* Einheitliche Aktionszeile und kompakte Buttons. */
.ui-popup .dialog-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;

    width: 100%;
    min-width: 0;

    margin: 6px 0 0;
    padding: 0;
}



/* Warnungen in Dialogen kompakt halten, ohne die Seitenwarnung global zu ändern. */
.ui-popup .archive-warning {
    margin: 0;
    padding: 10px 12px;
    border-width: 1px;
    font-size: .80rem;
    line-height: 1.4;
}

/* Tarif bearbeiten und die zweistufigen Bestätigungen. */
.ui-popup--medium#plan-edit-safe-dialog {
    width: min(430px, calc(100vw - 32px));
}

.ui-popup-body--plan-safe {
    gap: 10px;
}

.ui-popup-body--plan-safe .plan-edit-billing-note {
    line-height: 1.4;
}

#plan-safe-summary {
    max-height: calc(100dvh - 220px);
    overflow-x: hidden;
    overflow-y: auto;
}

.plan-edit-price-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.plan-edit-price-row input {
    width: 100%;
    min-width: 0;
}

/* Preisbestätigung. */
.ui-popup-body--price-confirm {
    gap: 10px;
}

.ui-popup-body--price-confirm .price-confirm-line {
    margin: 0;
    font-size: .80rem;
    line-height: 1.35;
}

.ui-popup-body--price-confirm .price-confirm-line strong {
    display: block;
    margin-top: 2px;
}

/* Benutzerlizenzen: längere Produktnamen und begrenzte Listenhöhe. */
.ui-popup--license .user-license-list {
    height: auto;
    min-height: 0;
    max-height: min(230px, calc(100dvh - 220px));
    overflow-x: hidden;
    overflow-y: auto;
}

.ui-popup--license select {
    min-width: 0;
    max-width: 100%;
}

.ui-popup--license .user-license-option {
    min-width: 0;
}

.ui-popup--license .user-license-option select {
    width: 100%;
}

/* SMTP-Test: gleiche Komponenten, nur mehr Platz für den Statusbericht. */
.ui-popup-body--smtp {
    gap: 10px;
    padding: 18px 20px 16px;
}

.ui-popup-body--smtp .smtp-test-title {
    margin: 0 0 2px;
    font-size: 1.08rem;
    line-height: 1.2;
}

.ui-popup-body--smtp .smtp-test-detail {
    max-width: 420px;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
}

.ui-popup-body--smtp .smtp-test-actions {
    gap: 8px;
    margin-top: 8px;
}

.ui-popup-body--smtp .smtp-test-ok {
    margin: 6px 0 8px;
    color: var(--accent);
}

.ui-popup-body--smtp .smtp-test-error {
    margin: 6px 0 8px;
    color: #ff7676;
}

/* Kundenbenutzer anlegen: zwei gestapelte Formulare im selben Popup. */
.ui-popup-body--customer-user-add {
    gap: 10px;
}

.ui-popup--customer-user-add .customer-user-create-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;

    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
}

.ui-popup--customer-user-add .customer-user-create-form label {
    display: grid;
    gap: 4px;
    margin: 0;
}

.ui-popup--customer-user-add .customer-user-create-form select,
.ui-popup--customer-user-add .customer-user-create-form input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.ui-popup-body--customer-user-add > .eyebrow:not(:first-child) {
    margin-top: 4px;
}

.ui-popup--customer-user-add .muted {
    margin: 2px 0 0;
}

/* Passwortdialog: inhaltliche Regeln gehören zum Popup-Modell. */
.ui-popup .user-password-rules {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-size: .84rem;
    line-height: 1.55;
}

.ui-popup .user-password-rules strong {
    display: block;
    margin-bottom: 3px;
    color: var(--text);
}

/* Kleine Details für die Statusbestätigung. */
#user-account-state-dialog .dialog-actions button[type="submit"] {
    font-weight: 600;
}
