/* Modern Login Modal — frontend styles
 * Mobile-first: bottom sheet on phones, centered dialog on tablet/desktop.
 */

.mlm-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

.mlm-modal.is-open {
    display: flex;
    align-items: flex-end;          /* mobile: bottom sheet */
    justify-content: center;
    animation: mlm-fade 0.18s ease-out;
}

.mlm-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

/* ---------- Dialog: mobile (bottom sheet) ---------- */
.mlm-modal__dialog {
    position: relative;
    width: 100%;
    max-width: 100%;
    background: #fff;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
    padding: 28px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    max-height: 92vh;
    max-height: 92dvh;              /* dynamic viewport handles iOS chrome */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: mlm-slide-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
    touch-action: pan-y;
}

/* Drag handle indicator on mobile bottom sheet */
.mlm-modal__dialog::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
}

/* ---------- Dialog: tablet & up (centered) ---------- */
@media (min-width: 601px) {
    .mlm-modal.is-open {
        align-items: center;
    }
    .mlm-modal__dialog {
        max-width: 420px;
        margin: 16px;
        border-radius: 12px;
        padding: 32px 28px 24px;
        max-height: calc(100vh - 32px);
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
        animation: mlm-pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
    }
    .mlm-modal__dialog::before {
        display: none;              /* no drag handle on desktop */
    }
}

@keyframes mlm-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes mlm-slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

@keyframes mlm-pop {
    from { transform: translateY(8px) scale(0.98); opacity: 0; }
    to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* ---------- Close button — large tap target ---------- */
.mlm-modal__close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    font-size: 28px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mlm-modal__close:hover,
.mlm-modal__close:focus-visible {
    background: #f1f5f9;
    color: #0f172a;
    outline: none;
}

/* ---------- Title ---------- */
.mlm-modal__title {
    margin: 8px 0 18px;
    font-size: 19px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.3;
    padding-right: 36px;            /* avoid overlap with close button */
}

@media (min-width: 601px) {
    .mlm-modal__title {
        font-size: 20px;
        margin-top: 0;
        padding-right: 0;
    }
}

/* ---------- Alert ---------- */
.mlm-modal__alert {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    margin-bottom: 14px;
    line-height: 1.4;
}

.mlm-modal__alert.is-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

/* ---------- Form ---------- */
.mlm-modal__form { display: block; }

.mlm-modal__label {
    display: block;
    margin-bottom: 14px;
}

.mlm-modal__label-text {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    margin-bottom: 6px;
}

/* Inputs: 16px font prevents iOS Safari zoom-on-focus.
 * 48px min-height is the recommended mobile tap target. */
.mlm-modal__input {
    width: 100%;
    box-sizing: border-box;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 16px;
    color: #0f172a;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

.mlm-modal__input:focus {
    outline: none;
    border-color: var(--mlm-accent, #2271b1);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mlm-accent, #2271b1) 18%, transparent);
}

/* "Remember me" — large enough to tap comfortably */
.mlm-modal__check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0 18px;
    min-height: 44px;
    font-size: 15px;
    color: #475569;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mlm-modal__check input {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--mlm-accent, #2271b1);
}

/* Submit — big, thumb-friendly, prominent on mobile */
.mlm-modal__submit {
    width: 100%;
    min-height: 50px;
    padding: 14px 16px;
    background: var(--mlm-accent, #2271b1);
    color: #fff;
    border: 0;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s, transform 0.05s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mlm-modal__submit:hover { filter: brightness(1.08); }
.mlm-modal__submit:active { transform: translateY(1px); filter: brightness(0.95); }
.mlm-modal__submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ---------- Footer links ---------- */
.mlm-modal__links {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
    font-size: 14px;
}

.mlm-modal__links a {
    color: var(--mlm-accent, #2271b1);
    text-decoration: none;
    padding: 6px 2px;               /* slight padding for easier tapping */
    -webkit-tap-highlight-color: transparent;
}

.mlm-modal__links a:hover,
.mlm-modal__links a:focus-visible { text-decoration: underline; }
.mlm-modal__links a[hidden] { display: none; }

/* ---------- Google Sign-In ---------- */
.mlm-modal__google {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.mlm-modal__google-btn {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Google's iframe button doesn't always honor width — center it instead */
.mlm-modal__google-btn > div { margin: 0 auto !important; }

.mlm-modal__divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    margin: 4px 0 16px;
    gap: 10px;
}

.mlm-modal__divider::before,
.mlm-modal__divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

/* ---------- Body scroll lock ---------- */
body.mlm-modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}
