/**
 * ERepair Unified Modal System — v2.0
 * Linear / Stripe-inspired · Pure white · Ultra-minimal
 * Zero dependencies · PHP/HTML compatible
 */

/* ============================================================
   TOKENS  (Tailwind-aligned)
   ============================================================ */
:root {
    /* Primary — navy-blue palette */
    --er-primary: #1e3a8a;
    --er-primary-mid: #2563eb;
    --er-primary-end: #3b82f6;

    /* Success — emerald */
    --er-success: #059669;
    /* emerald-600 */
    --er-success-light: #ecfdf5;
    /* emerald-50  */
    --er-success-border: #a7f3d0;
    /* emerald-200 */

    /* Danger — rose */
    --er-danger: #e11d48;
    /* rose-600 */
    --er-danger-light: #fff1f2;
    /* rose-50  */
    --er-danger-border: #fecdd3;
    /* rose-200 */

    /* Warning — amber */
    --er-warning: #d97706;
    /* amber-600 */
    --er-warning-light: #fffbeb;
    /* amber-50  */
    --er-warning-border: #fde68a;
    /* amber-200 */

    /* Info — blue */
    --er-info: #2563eb;
    /* blue-600 */
    --er-info-light: #eff6ff;
    /* blue-50  */
    --er-info-border: #bfdbfe;
    /* blue-200 */

    /* Text */
    --er-text-heading: #111827;
    /* gray-900 */
    --er-text-body: #4b5563;
    /* gray-600 */
    --er-text-muted: #9ca3af;
    /* gray-400 */

    /* Geometry */
    --er-radius-2xl: 16px;
    /* rounded-2xl */
    --er-radius-lg: 8px;
    /* rounded-lg  */
    --er-pad: 24px;
    /* p-6 */
    --er-btn-gap: 12px;
    /* space-x-3 */

    /* Motion */
    --er-spring: cubic-bezier(0.22, 1, 0.36, 1);
    --er-ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Background Lock */
html.er-modal-open,
body.er-modal-open {
    overflow: hidden !important;
    height: 100vh !important;
    overscroll-behavior: none !important;
    touch-action: none !important;
}

body.er-modal-open {
    padding-right: var(--scrollbar-width, 0px);
}


/* ============================================================
   KEYFRAMES
   ============================================================ */
@keyframes er-icon-pop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    60% {
        transform: scale(1.08);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes er-fade-up {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes er-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Spinner Utilities */
.er-spinner {
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
    animation: er-spin 0.8s linear infinite;
}


/* ============================================================
   OVERLAY
   ============================================================ */
.er-modal {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.45) !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
    z-index: 200000 !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: var(--er-pad);
    box-sizing: border-box;

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s var(--er-ease);
    overflow-y: auto;
}

.er-modal.show {
    opacity: 1;
    pointer-events: all;
}

.er-modal.er-closing {
    opacity: 0;
    transition: opacity 0.2s ease;
}


/* ============================================================
   INNER CARD  — Pure white, soft border, deep shadow
   ============================================================ */
.er-modal-inner {
    background: #ffffff;
    border: 1px solid #f3f4f6;
    /* border-gray-100 */
    border-radius: var(--er-radius-2xl);
    /* rounded-2xl */
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.03),
        0 4px 12px rgba(0, 0, 0, 0.04),
        0 16px 40px rgba(0, 0, 0, 0.08);
    /* shadow-xl  */

    width: 100%;
    max-width: 420px;
    margin: auto;
    padding: var(--er-pad);
    /* p-6 */
    position: relative;
    overflow: hidden;

    display: flex;
    flex-direction: column;

    opacity: 0;
    transform: translateY(8px) scale(0.98);
    transition: opacity 0.3s var(--er-spring), transform 0.3s var(--er-spring);
    max-height: calc(100vh - 48px);
}

.er-modal.show .er-modal-inner {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.er-modal.er-closing .er-modal-inner {
    opacity: 0;
    transform: translateY(4px) scale(0.99);
}


/* ============================================================
   ICON CIRCLE  — 48 × 48, fully round
   ============================================================ */
.er-modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 9999px;
    /* full circle */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    animation: er-icon-pop 0.4s var(--er-spring) 0.05s both;
}

.er-modal-icon svg {
    width: 22px;
    height: 22px;
}


/* ============================================================
   TYPOGRAPHY
   ============================================================ */
/* Title — text-lg font-semibold */
.er-modal-title {
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 1.125rem;
    /* text-lg = 18px */
    font-weight: 600;
    /* font-semibold */
    color: var(--er-text-heading);
    margin: 0 0 4px;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

/* Message */
.er-modal-message {
    font-family: inherit;
    font-size: 0.875rem;
    /* text-sm */
    color: var(--er-text-body);
    line-height: 1.6;
    margin: 0 0 20px;
}

/* Optional detail box */
.er-modal-detail {
    background: #f9fafb;
    /* gray-50 */
    border: 1px solid #f3f4f6;
    /* gray-100 */
    border-radius: var(--er-radius-lg);
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 0.8125rem;
    color: var(--er-text-body);
    line-height: 1.6;
}

.er-modal-detail ul {
    margin: 4px 0 0 16px;
    padding: 0;
}

.er-modal-detail li {
    margin-bottom: 3px;
}

/* Custom HTML wrapper */
.er-modal-custom {
    margin-bottom: 16px;
}


/* ============================================================
   BUTTONS  — rounded-lg, space-x-3
   ============================================================ */
.er-modal-actions {
    display: flex;
    flex-direction: row !important;
    gap: var(--er-btn-gap);
    /* 12px = space-x-3 */
    flex-wrap: nowrap !important;
}

.er-modal-actions.er-stacked {
    flex-direction: column;
}

.er-btn {
    flex: 1;
    min-width: 0;
    padding: 10px 16px;
    border: none;
    border-radius: var(--er-radius-lg);
    /* rounded-lg */
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition:
        background 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.1s ease;
}

.er-btn:hover {
    transform: translateY(-1px);
}

.er-btn:active {
    transform: translateY(0) scale(0.98);
}

.er-btn:focus-visible {
    outline: 2px solid var(--er-primary-mid);
    outline-offset: 2px;
}

/* Cancel / secondary — subtle gray */
.er-btn-cancel {
    background: #f3f4f6;
    /* gray-100 */
    color: #374151;
    /* gray-700 */
    border: 1px solid #e5e7eb;
    /* gray-200 */
}

.er-btn-cancel:hover {
    background: #e5e7eb;
}

/* Primary — solid navy-to-blue */
.er-btn-primary {
    background: var(--er-primary-mid);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}

.er-btn-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

/* Danger — rose-600 */
.er-btn-danger {
    background: var(--er-danger);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(225, 29, 72, 0.25);
}

.er-btn-danger:hover {
    background: #be123c;
    /* rose-700 */
    box-shadow: 0 2px 8px rgba(225, 29, 72, 0.35);
}

/* Warning — amber-600 */
.er-btn-warning {
    background: var(--er-warning);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(217, 119, 6, 0.25);
}

.er-btn-warning:hover {
    background: #b45309;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.35);
}

/* Success — emerald-600 */
.er-btn-success {
    background: var(--er-success);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(5, 150, 105, 0.25);
}

.er-btn-success:hover {
    background: #047857;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.35);
}


/* ============================================================
   ICON VARIANT COLORS
   ============================================================ */
/* Success — emerald-50 bg, emerald-600 stroke */
.er-icon-success {
    background: var(--er-success-light);
    color: var(--er-success);
}

/* Danger — rose-50 bg, rose-600 stroke */
.er-icon-danger {
    background: var(--er-danger-light);
    color: var(--er-danger);
}

/* Warning — amber-50 bg, amber-600 stroke */
.er-icon-warning {
    background: var(--er-warning-light);
    color: var(--er-warning);
}

/* Info / Primary — blue-50 bg, blue-600 stroke */
.er-icon-primary,
.er-icon-info {
    background: var(--er-info-light);
    color: var(--er-info);
}


/* ============================================================
   FORM CONTROLS INSIDE MODALS
   ============================================================ */
.er-modal-inner .form-control,
.er-modal-inner .form-select {
    border-radius: var(--er-radius-lg);
    border-color: #e5e7eb;
    font-size: 0.875rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.er-modal-inner .form-control:focus,
.er-modal-inner .form-select:focus {
    border-color: var(--er-primary-mid);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}


/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
    .er-modal {
        padding: 16px !important;
    }

    .er-modal-inner {
        max-width: 100%;
        border-radius: 14px;
        padding: 20px;
    }

    .er-modal-actions {
        /* Force side-by-side even on small mobile */
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 8px;
        /* Slightly tighter on mobile */
    }

    .er-btn {
        flex: 1;
        width: auto;
    }
}