/*
 * FerienKalender X5 – zentrale Dialog-Komponente
 * Einheitliche modale Hinweise und Bestätigungen ohne Browserdialoge.
 */

.fkx-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(24, 30, 28, 0.56);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.16s ease, visibility 0.16s ease;
}

.fkx-dialog-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.fkx-dialog {
    width: min(100%, 500px);
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #e1e5e3;
    border-radius: 14px;
    box-shadow: 0 24px 65px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(10px) scale(0.985);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.fkx-dialog-overlay.is-visible .fkx-dialog {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.fkx-dialog-header {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 20px 22px 17px;
    border-bottom: 1px solid #e7eae8;
}

.fkx-dialog-icon {
    display: inline-flex;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #e8f0ed;
    color: #2f5d50;
    font-size: 21px;
    font-weight: 800;
}

.fkx-dialog-title {
    flex: 1;
    margin: 0;
    color: #303438;
    font-size: 22px;
    line-height: 1.25;
}

.fkx-dialog-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #62696d;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
}

.fkx-dialog-close:hover,
.fkx-dialog-close:focus-visible {
    background: #eef0f1;
    outline: none;
}

.fkx-dialog-body {
    padding: 22px;
    color: #4d5559;
    font-size: 16px;
    line-height: 1.55;
    white-space: pre-line;
}

.fkx-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 22px 22px;
}

.fkx-dialog-button {
    min-height: 43px;
    padding: 10px 18px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.fkx-dialog-button:focus-visible {
    outline: 3px solid rgba(47, 93, 80, 0.22);
    outline-offset: 2px;
}

.fkx-dialog-button-primary {
    background: #2f5d50;
    color: #ffffff;
}

.fkx-dialog-button-primary:hover {
    background: #24483d;
}

.fkx-dialog-button-secondary {
    background: #e1e3e5;
    color: #222222;
}

.fkx-dialog-button-secondary:hover {
    background: #d4d7d9;
}

.fkx-dialog-button-danger {
    background: #b4232d;
    color: #ffffff;
}

.fkx-dialog-button-danger:hover {
    background: #901b23;
}

.fkx-dialog-overlay[data-type="success"] .fkx-dialog-icon {
    background: #d9eee5;
    color: #236646;
}

.fkx-dialog-overlay[data-type="warning"] .fkx-dialog-icon {
    background: #fff0c2;
    color: #765600;
}

.fkx-dialog-overlay[data-type="error"] .fkx-dialog-icon,
.fkx-dialog-overlay[data-type="danger"] .fkx-dialog-icon {
    background: #f8dadd;
    color: #9a1f29;
}

body.fkx-dialog-open {
    overflow: hidden;
}

@media (max-width: 560px) {
    .fkx-dialog-overlay {
        align-items: flex-end;
        padding: 12px;
    }

    .fkx-dialog {
        width: 100%;
    }

    .fkx-dialog-header,
    .fkx-dialog-body {
        padding-left: 18px;
        padding-right: 18px;
    }

    .fkx-dialog-actions {
        flex-direction: column-reverse;
        padding: 0 18px 18px;
    }

    .fkx-dialog-button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fkx-dialog-overlay,
    .fkx-dialog {
        transition: none;
    }
}


/* v003: Dublettenprüfung für neue Gäste */
.fkx-duplicate-dialog {
    width: min(100%, 720px);
}

.fkx-duplicate-dialog .fkx-dialog-body > p {
    margin: 0 0 16px;
}

.fkx-duplicate-list {
    display: grid;
    gap: 10px;
    max-height: min(48vh, 420px);
    overflow: auto;
}

.fkx-duplicate-guest {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: start;
    padding: 13px 14px;
    border: 1px solid #d9dfdc;
    border-radius: 9px;
    background: #fff;
    cursor: pointer;
}

.fkx-duplicate-guest:hover,
.fkx-duplicate-guest.is-selected {
    border-color: #2f5d50;
    background: #eef6f2;
}

.fkx-duplicate-guest input {
    margin-top: 5px;
}

.fkx-duplicate-guest span,
.fkx-duplicate-guest small {
    display: block;
}

.fkx-duplicate-guest small {
    margin-top: 2px;
    color: #626b68;
    font-size: 13px;
}

.fkx-duplicate-actions {
    flex-wrap: wrap;
}

@media (max-width: 700px) {
    .fkx-duplicate-actions .fkx-dialog-button {
        width: 100%;
    }
}


/* v004: Dialoge lassen sich an der Titelleiste verschieben. */
.fkx-dialog-drag-handle {
    cursor: grab;
    user-select: none;
    touch-action: none;
}

body.fkx-dialog-dragging,
body.fkx-dialog-dragging * {
    cursor: grabbing !important;
    user-select: none !important;
}

.fkx-dialog.is-dragged {
    transform: none !important;
}

@media (max-width: 700px) {
    .fkx-dialog-drag-handle {
        cursor: default;
        touch-action: auto;
    }
}

/* v015: Buchung und Mitreisende getrennt verwalten */
.fkx-booking-tabs { display:flex; gap:6px; margin:0 0 10px; border-bottom:1px solid #d8e1dc; }
.fkx-booking-tab { border:0; border-bottom:3px solid transparent; background:transparent; padding:9px 14px 8px; font:inherit; font-weight:700; color:#52605a; cursor:pointer; }
.fkx-booking-tab.is-active { color:#145c3d; border-bottom-color:#1f7a52; }
.fkx-tab-count { display:inline-flex; min-width:22px; height:22px; padding:0 6px; margin-left:5px; align-items:center; justify-content:center; border-radius:11px; background:#e5eee9; font-size:.78rem; }
.fkx-travelers-panel { min-height:420px; }
.fkx-traveler-toolbar { margin-bottom:16px; }
.fkx-traveler-search-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:10px; align-items:end; }
.fkx-traveler-search-results { margin-top:6px; border:1px solid #cdd8d2; border-radius:8px; background:#fff; max-height:240px; overflow:auto; box-shadow:0 8px 20px rgba(25,52,39,.12); }
.fkx-traveler-search-results button { width:100%; display:flex; flex-direction:column; align-items:flex-start; gap:3px; padding:10px 12px; border:0; border-bottom:1px solid #edf1ef; background:#fff; text-align:left; cursor:pointer; }
.fkx-traveler-search-results button:hover,.fkx-traveler-search-results button:focus { background:#eef7f2; }
.fkx-traveler-search-results strong { line-height:1.3; }
.fkx-traveler-search-results span { width:100%; color:#63716a; font-size:.86rem; line-height:1.35; overflow-wrap:anywhere; }
.fkx-selected-travelers { display:grid; gap:8px; }
.fkx-empty-travelers { padding:22px; border:1px dashed #b9c8c0; border-radius:8px; color:#65736c; text-align:center; }
.fkx-selected-traveler { display:grid; grid-template-columns:minmax(0,1fr) 220px auto; gap:12px; align-items:end; padding:11px 12px; border:1px solid #d8e1dc; border-radius:8px; background:#f8faf9; }
.fkx-selected-traveler > div { display:flex; flex-direction:column; gap:3px; }
.fkx-selected-traveler > div span { color:#68756f; font-size:.85rem; }
.fkx-new-traveler-form { margin-top:16px; padding:14px; border:1px solid #cdd8d2; border-radius:8px; background:#f8faf9; }
.fkx-new-traveler-form h4 { margin:0 0 10px; }
.fkx-inline-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:12px; }
@media (max-width:800px) { .fkx-traveler-search-row,.fkx-selected-traveler { grid-template-columns:1fr; } }


/* v015a: konstante Dialoggröße und identische Gastsuche für Hauptgast/Mitreisende */
#bookingModal .fkx-modal-box {
    height: min(920px, calc(100vh - 24px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#bookingTabPanel, #travelersTabPanel {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}
#travelersTabPanel[hidden], #bookingTabPanel[hidden] { display: none !important; }
.fkx-main-guest-search { margin-bottom: 10px; }
.fkx-main-guest-search > label { margin-top: 0 !important; }
@media (max-width: 980px), (max-height: 760px) {
    #bookingModal .fkx-modal-box { height: calc(100vh - 24px); }
}


/* v015b: Hauptgastsuche sichtbar und konstante Dialogflaeche ohne Desktop-Scrollbar */
#bookingModal .fkx-modal-box {
    height: min(970px, calc(100vh - 8px));
}
#bookingTabPanel {
    overflow-y: hidden;
    padding-right: 0;
}
#travelersTabPanel {
    overflow-y: auto;
    padding-right: 4px;
}
.fkx-main-guest-search-prominent {
    position: relative;
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    margin: 0 0 8px;
    padding: 9px 12px;
    border: 1px solid #cdd8d2;
    border-radius: 9px;
    background: #f8faf9;
}
.fkx-main-guest-search-prominent > label {
    margin: 0 !important;
}
.fkx-main-guest-search-prominent .fkx-traveler-search-results {
    position: absolute;
    z-index: 30;
    top: calc(100% - 2px);
    right: 12px;
    left: 222px;
}
@media (max-width: 980px), (max-height: 850px) {
    #bookingModal .fkx-modal-box { height: calc(100vh - 8px); }
    #bookingTabPanel, #travelersTabPanel { overflow-y: auto; padding-right: 4px; }
    .fkx-main-guest-search-prominent { grid-template-columns: 1fr; }
    .fkx-main-guest-search-prominent .fkx-traveler-search-results { left: 12px; }
}


/* v015c: Namensvorschlaege direkt in der manuellen Eingabe */
.fkx-name-suggestions {
    margin-top: -2px;
    grid-column: 1 / -1;
    position: relative;
    z-index: 40;
}
.fkx-name-suggestions[hidden] { display: none !important; }
.fkx-new-traveler-form { margin-top: 0; margin-bottom: 14px; }
#bookingTabPanel { overflow-y: hidden; }
@media (max-width: 980px), (max-height: 850px) {
    #bookingTabPanel { overflow-y: auto; }
}

/* v015e: Anschrift fuer neue Mitreisende und klar sichtbare Entfernen-Aktion */
.fkx-checkbox-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border: 1px solid #d8e1dc;
    border-radius: 8px;
    background: #fff;
    font-weight: 600;
}
.fkx-checkbox-row input { width: auto; margin: 0; }
.fkx-traveler-address-fields {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid #d8e1dc;
    border-radius: 8px;
    background: #fff;
}
.fkx-traveler-address-fields[hidden] { display: none !important; }
.fkx-selected-traveler [data-remove-traveler] {
    white-space: nowrap;
    min-width: 105px;
}

/* v015f: gemeinsame Fußleiste und sichtbare Einzelaktion für Mitreisende */
.fkx-selected-traveler {
    grid-template-columns: minmax(0, 1fr) minmax(160px, 210px) 112px;
}
.fkx-traveler-remove {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    align-self: end;
}
@media (max-width: 800px) {
    .fkx-selected-traveler { grid-template-columns: 1fr; }
}


/* v016a-1: Namensvorschlaege als eingebetteter Bereich statt Overlay */
.fkx-main-guest-search-prominent .fkx-traveler-search-results.fkx-name-suggestions {
    position: relative;
    inset: auto;
    z-index: 1;
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 4px;
}
.fkx-name-suggestions {
    max-height: 190px;
}
#bookingTabPanel {
    overflow-y: auto;
}

/* v019b-91: Vermieterdialog auf Desktop maximal in der verfügbaren Höhe nutzen. */
#bookingModal { padding: 2px; }
#bookingModal .fkx-modal-box {
    height: calc(100dvh - 4px);
    max-height: calc(100dvh - 4px);
    max-width: 1220px;
}
@supports not (height: 100dvh) {
    #bookingModal .fkx-modal-box {
        height: calc(100vh - 4px);
        max-height: calc(100vh - 4px);
    }
}


/* v019b-99: Buchungsdialog nicht künstlich auf volle Bildschirmhöhe strecken. */
#bookingModal {
    padding: 12px;
}
#bookingModal .fkx-modal-box {
    width: min(1180px, calc(100vw - 24px));
    max-width: 1180px;
    height: auto;
    max-height: calc(100dvh - 24px);
}
@supports not (height: 100dvh) {
    #bookingModal .fkx-modal-box {
        height: auto;
        max-height: calc(100vh - 24px);
    }
}
@media (max-width: 980px) {
    #bookingModal .fkx-modal-box {
        width: min(760px, calc(100vw - 20px));
        max-width: 760px;
        height: auto;
        max-height: calc(100dvh - 20px);
    }
}
@media (max-width: 680px) {
    #bookingModal { padding: 6px; }
    #bookingModal .fkx-modal-box {
        width: calc(100vw - 12px);
        height: auto;
        max-height: calc(100dvh - 12px);
    }
}
