/* ==========================================================================
   MODAL COMPONENT
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    transform: translateY(20px) scale(0.98);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-backdrop.is-open .modal {
    transform: translateY(0) scale(1);
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-6);
    border-bottom: 1px solid var(--border);
}

.modal__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.modal__close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--sp-1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}

.modal__close:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.modal__body {
    padding: var(--sp-6);
    overflow-y: auto;
}

.modal__footer {
    padding: var(--sp-4) var(--sp-6);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

/* ==========================================================================
   DRAWER VARIANT  (.modal-backdrop--drawer)
   Create / edit forms slide in from the right, full height.
   Footer stays at the bottom, body scrolls. Centred .modal is unchanged.
   ========================================================================== */
.modal-backdrop--drawer {
    justify-content: flex-end;
    align-items: stretch;
}
.modal-backdrop--drawer .modal,
.modal-backdrop--drawer .modal.modal--wide,
.modal-backdrop--drawer .modal.modal--lg {
    width: min(560px, 100vw);
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0 !important;
    border-radius: 0;
    transform: translateX(40px);
    transition: transform .25s var(--ease);
}
.modal-backdrop--drawer.is-open .modal { transform: none; }
.modal-backdrop--drawer .modal > form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.modal-backdrop--drawer .modal__header { padding: var(--sp-5) var(--sp-6); }
.modal-backdrop--drawer .modal__body { flex: 1; min-height: 0; overflow-y: auto; }
.modal-backdrop--drawer .modal__footer { border-top: 1px solid var(--border); justify-content: flex-start; margin-top: auto; }
/* helper markup is [Cancel][Primary]: show the primary action first, like the other drawers */
.modal-backdrop--drawer form .modal__footer { flex-direction: row-reverse; justify-content: flex-end; }
