/**
 * Modals admin hôtel — format unifié (équipement, réservation, location, etc.)
 */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(15, 23, 42, 0.52);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top, 0px)) 0.75rem max(0.75rem, env(safe-area-inset-bottom, 0px));
}
.modal.open { display: flex; }

@media (max-width: 520px) {
    .modal.open {
        align-items: flex-end;
        padding: 0;
    }
    .modal.open .mkf-modal-sheet {
        border-radius: 20px 20px 0 0;
        max-height: min(94vh, calc(100dvh - 0.5rem));
        width: 100%;
    }
}

.mkf-modal-sheet,
.asset-modal-sheet,
.res-modal-sheet {
    width: min(520px, 100%);
    max-height: min(92vh, calc(100dvh - 1.5rem));
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    animation: mkfModalIn 0.22s ease-out;
}
.mkf-modal-sheet--wide { width: min(580px, 100%); }
.mkf-modal-sheet--medium { width: min(560px, 100%); }

@keyframes mkfModalIn {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.mkf-modal-form,
#assetForm,
#resForm,
#excForm,
#returnFormWrap,
#bookingForm,
#roomForm {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.mkf-modal-header,
.asset-modal-header,
.res-modal-header {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    padding: 1.35rem 1.35rem 1.05rem;
    background: linear-gradient(135deg, #f0f9ff 0%, #ecfeff 55%, #f0fdfa 100%);
    border-bottom: 1px solid #bae6fd;
    position: relative;
    flex-shrink: 0;
}
.mkf-modal-header--teal {
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 45%, #ecfeff 100%);
    border-bottom-color: #99f6e4;
}
.mkf-modal-header--green {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 45%, #f0fdf4 100%);
    border-bottom-color: #6ee7b7;
}

.mkf-modal-icon,
.asset-modal-icon,
.res-modal-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.55rem;
    background: linear-gradient(145deg, #0369a1, #0284c7);
    box-shadow: 0 8px 20px rgba(3, 105, 161, 0.28);
}
.mkf-modal-icon--teal {
    background: linear-gradient(145deg, #0f766e, #14b8a6);
    box-shadow: 0 8px 22px rgba(15, 118, 110, 0.28);
}
.mkf-modal-icon--green {
    background: linear-gradient(145deg, #047857, #059669);
    box-shadow: 0 8px 22px rgba(4, 120, 87, 0.28);
}

.mkf-modal-header-text,
.asset-modal-header-text,
.res-modal-header-text {
    flex: 1;
    min-width: 0;
    padding-right: 2rem;
}
.mkf-modal-header-text h3,
.asset-modal-header-text h3,
.res-modal-header-text h3,
.mkf-modal-header-text #resModalTitle {
    margin: 0;
    font-size: 1.22rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
}
.mkf-modal-header-text .sub,
.asset-modal-header-text .sub,
.res-modal-header-text .sub {
    margin: 0.35rem 0 0;
    font-size: 0.84rem;
    color: #475569;
    line-height: 1.45;
}

.modal-close-btn,
.modal-close[data-close] {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.8);
    color: #64748b;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    z-index: 2;
}
.modal-close-btn:hover,
.modal-close[data-close]:hover {
    background: #fff;
    color: #0f172a;
}

.mkf-modal-body,
.asset-modal-body,
.res-modal-body,
.modal-body.mkf-modal-body {
    padding: 1.25rem 1.35rem 1rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mkf-modal-footer,
.asset-modal-footer,
.res-modal-footer,
.modal-footer.mkf-modal-footer {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.55rem;
    padding: 1rem 1.35rem max(1.25rem, env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #e2e8f0;
    background: #fafbfc;
    flex-shrink: 0;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.06);
}
.mkf-modal-footer .btn,
.asset-modal-footer .btn,
.res-modal-footer .btn {
    min-width: 7.5rem;
    justify-content: center;
}
.mkf-modal-footer .btn-primary,
.asset-modal-footer .btn-primary,
.res-modal-footer .btn-primary {
    background: linear-gradient(135deg, #0f766e, #0d9488);
    box-shadow: 0 4px 14px rgba(15, 118, 110, 0.28);
}
.mkf-modal-footer .btn-primary:hover,
.asset-modal-footer .btn-primary:hover,
.res-modal-footer .btn-primary:hover {
    filter: brightness(1.05);
}

@media (max-width: 480px) {
    .mkf-modal-footer,
    .asset-modal-footer,
    .res-modal-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .mkf-modal-footer .btn,
    .asset-modal-footer .btn,
    .res-modal-footer .btn {
        width: 100%;
        min-width: 0;
    }
}

/* Formulaire */
.mkf-modal-body .form-grid,
.mkf-modal-form.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem 0.75rem;
}
.mkf-modal-body .form-grid .span2,
.form-grid .span2 { grid-column: span 2; }

.form-field label,
.mkf-modal-body .form-field label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: #334155;
}
.form-field label .req { color: #0284c7; }
.form-field .field-hint,
.field-hint {
    font-size: 0.72rem;
    color: #64748b;
    margin: 0.3rem 0 0;
    line-height: 1.4;
    display: block;
}

.mkf-modal-body .form-grid input,
.mkf-modal-body .form-grid select,
.mkf-modal-body .form-grid textarea,
.mkf-modal-body .form-group input,
.mkf-modal-body .form-group textarea,
.mkf-modal-body input,
.mkf-modal-body select,
.mkf-modal-body textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.62rem 0.78rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.9rem;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.mkf-modal-body .form-grid input:focus,
.mkf-modal-body .form-grid select:focus,
.mkf-modal-body .form-grid textarea:focus,
.mkf-modal-body .form-group input:focus,
.mkf-modal-body .form-group textarea:focus,
.mkf-modal-body input:focus,
.mkf-modal-body select:focus,
.mkf-modal-body textarea:focus {
    outline: none;
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14);
}
.mkf-modal-body .form-grid input::placeholder,
.mkf-modal-body input::placeholder { color: #94a3b8; }
.mkf-modal-body textarea { min-height: 72px; resize: vertical; }

.form-section {
    margin-bottom: 1.1rem;
    padding-bottom: 1.05rem;
    border-bottom: 1px solid #f1f5f9;
}
.form-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.form-section-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #0f766e;
    margin: 0 0 0.75rem;
}
.form-section-title span { font-size: 0.95rem; }

.rate-card {
    grid-column: span 2;
    background: linear-gradient(180deg, #f8fafc, #fff);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 0.9rem 1rem 1rem;
}
.rate-card-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
    font-weight: 800;
    color: #334155;
    margin: 0 0 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.rate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.input-currency { position: relative; }
.input-currency input { padding-right: 4.2rem; }
.input-currency .currency-tag {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    background: #f1f5f9;
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    pointer-events: none;
}

.check-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.check-row input[type="checkbox"] { width: auto; margin-top: 0.2rem; }

@media (max-width: 480px) {
    .mkf-modal-body .form-grid,
    .form-grid { grid-template-columns: 1fr; }
    .mkf-modal-body .form-grid .span2,
    .form-grid .span2 { grid-column: span 1; }
    .rate-grid { grid-template-columns: 1fr; }
}

/* Legacy: hide old flat modal layout when inside mkf sheet */
.mkf-modal-sheet > h3:first-child,
.mkf-modal-sheet > .sub:first-of-type { display: none; }
.mkf-modal-sheet > .form-grid.modal-actions-only { display: none; }

/* Recherche client existant (réservations) */
.guest-picker { margin-bottom: 0.85rem; }
.guest-picker-search { position: relative; }
.guest-picker-search input {
    width: 100%; box-sizing: border-box;
    padding: 0.55rem 0.85rem 0.55rem 2.2rem;
    border-radius: 12px; border: 1px solid #e2e8f0; font-size: 0.88rem;
    background: #fff url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%2364748b" viewBox="0 0 16 16"><path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.006a5 5 0 1 1 0-10 5 5 0 0 1 0 10z"/></svg>') no-repeat 0.65rem center;
}
.guest-picker-search input:focus {
    outline: none; border-color: #0f766e; box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}
.guest-picker-results {
    margin-top: 0.45rem;
    max-height: 220px; overflow-y: auto; background: #fff;
    border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    display: none;
}
.guest-picker-results.open { display: block; }
.guest-picker-results.guest-picker-loading {
    display: block; padding: 0.65rem 0.85rem; color: #64748b; font-size: 0.85rem;
}
.guest-picker-results.guest-picker-error {
    display: block; padding: 0.65rem 0.85rem; color: #b91c1c; font-size: 0.85rem;
    background: #fef2f2; border-color: #fecaca;
}
.guest-picker-item {
    display: block; width: 100%; text-align: left; padding: 0.65rem 0.85rem;
    border: none; border-bottom: 1px solid #f1f5f9; background: #fff; cursor: pointer;
    font-size: 0.85rem;
}
.guest-picker-item:last-child { border-bottom: none; }
.guest-picker-item:hover { background: #f0fdfa; }
.guest-picker-item strong { display: block; color: #0f172a; font-weight: 700; }
.guest-picker-item span { font-size: 0.78rem; color: #64748b; }
.guest-picker-selected {
    display: none; align-items: center; justify-content: space-between; gap: 0.75rem;
    padding: 0.7rem 0.9rem; margin-bottom: 0.75rem;
    background: linear-gradient(180deg, #f0fdfa, #fff);
    border: 1px solid #99f6e4; border-radius: 12px;
}
.guest-picker-selected.show { display: flex; }
.guest-picker-selected .info strong { display: block; font-size: 0.9rem; color: #0f766e; }
.guest-picker-selected .info span { font-size: 0.78rem; color: #64748b; }
.guest-picker-new-link {
    font-size: 0.78rem; font-weight: 600; color: #0f766e; background: none; border: none;
    cursor: pointer; text-decoration: underline; padding: 0; margin-top: 0.35rem;
}
.guest-fields-new .form-field input[readonly] { background: #f8fafc; color: #64748b; }

/* Galerie photos (max 5) */
.mkf-gallery-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-bottom: 0.65rem;
}
.mkf-gallery-thumb {
    position: relative;
    width: 88px;
    height: 66px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}
.mkf-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.mkf-gallery-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mkf-gallery-remove:hover {
    background: #dc2626;
}
.mkf-gallery-add-btn {
    cursor: pointer;
    margin: 0;
}
.mkf-gallery-add-btn input[type="file"] {
    display: none;
}

/* Téléversement photo (chambres, équipements) — legacy */
.mkf-image-upload-row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
}
.mkf-image-upload-preview {
    width: 120px;
    height: 90px;
    border-radius: 12px;
    border: 1px dashed #cbd5e1;
    background: #f8fafc
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="%2394a3b8" viewBox="0 0 16 16"><path d="M6.002 5.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z"/><path d="M2.002 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2h-12zm12 1a1 1 0 0 1 1 1v8l-3-3-4 4-2-2-4 4V2a1 1 0 0 1 1-1h12z"/></svg>')
        no-repeat center;
    overflow: hidden;
    flex-shrink: 0;
}
.mkf-image-upload-preview.has-image {
    border-style: solid;
    background: #fff;
}
.mkf-image-upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.mkf-image-upload-actions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    align-items: flex-start;
}
.mkf-image-upload-btn {
    cursor: pointer;
    margin: 0;
}
.mkf-image-upload-btn input[type="file"] {
    display: none;
}
.catalog-icon.has-photo,
.room-icon.has-photo {
    overflow: hidden;
    padding: 0;
    background: #f1f5f9;
}
.catalog-icon.has-photo img,
.room-icon.has-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
