/**
 * Surebound Enterprise Modal & Dialog Design System
 * Modern, accessible, brand-aligned replacement for native browser alert() and confirm()
 */

/* ==========================================================================
   MODAL OVERLAY & BACKDROP
   ========================================================================== */
.sb-modal-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(9, 19, 46, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.sb-modal-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   MODAL CARD CONTAINER
   ========================================================================== */
.sb-modal-card {
    background: #ffffff;
    width: 100%;
    max-width: 440px;
    border-radius: 20px;
    box-shadow: 
        0 25px 50px -12px rgba(15, 23, 42, 0.28),
        0 0 0 1px rgba(226, 232, 240, 0.9),
        0 8px 16px -4px rgba(0, 0, 0, 0.04);
    padding: 28px 24px 22px 24px;
    box-sizing: border-box;
    text-align: center;
    position: relative;
    transform: scale(0.92) translateY(8px);
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #0f172a;
}

.sb-modal-overlay.is-active .sb-modal-card {
    transform: scale(1) translateY(0);
}

/* Close corner 'x' button */
.sb-modal-close-corner {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.sb-modal-close-corner:hover {
    background: #f1f5f9;
    color: #334155;
}

/* ==========================================================================
   ICON BADGE
   ========================================================================== */
.sb-modal-icon-badge {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    margin: 0 auto 16px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.2s ease;
}

.sb-modal-icon-badge svg {
    width: 28px;
    height: 28px;
}

/* Type variations for Icon Badge */
.sb-modal-card.type-success .sb-modal-icon-badge {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.15);
}

.sb-modal-card.type-primary .sb-modal-icon-badge,
.sb-modal-card.type-info .sb-modal-icon-badge {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.15);
}

.sb-modal-card.type-warning .sb-modal-icon-badge {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.15);
}

.sb-modal-card.type-danger .sb-modal-icon-badge {
    background: #fff1f2;
    color: #e11d48;
    border: 1px solid #fecdd3;
    box-shadow: 0 4px 14px rgba(225, 29, 72, 0.15);
}

/* ==========================================================================
   OPTIONAL REFERENCE BADGE (e.g. #SB-Q-74892)
   ========================================================================== */
.sb-modal-ref-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'JetBrains Mono', monospace, ui-monospace;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #0369a1;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    padding: 3px 10px;
    border-radius: 9999px;
    margin-bottom: 12px;
}

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */
.sb-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #09132e;
    margin: 0 0 8px 0;
    line-height: 1.35;
    letter-spacing: -0.015em;
}

.sb-modal-message {
    font-size: 0.9375rem;
    line-height: 1.55;
    color: #475569;
    margin: 0 0 24px 0;
    word-break: break-word;
}

/* ==========================================================================
   BUTTONS ACTION BAR
   ========================================================================== */
.sb-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.sb-modal-btn {
    flex: 1;
    height: 44px;
    padding: 0 18px;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    outline: none;
    user-select: none;
}

.sb-modal-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

/* Cancel Button */
.sb-modal-btn-cancel {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #475569;
}

.sb-modal-btn-cancel:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

.sb-modal-btn-cancel:active {
    background: #e2e8f0;
}

/* Confirm / Primary / Got It Buttons */
.sb-modal-btn-confirm {
    border: none !important;
    color: #ffffff !important;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
    font-weight: 600;
}
.sb-modal-btn-confirm:hover {
    background: linear-gradient(135deg, #0369a1 0%, #075985 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.45);
}

.sb-modal-card.type-info .sb-modal-btn-confirm,
.sb-modal-card.type-primary .sb-modal-btn-confirm {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}
.sb-modal-card.type-info .sb-modal-btn-confirm:hover,
.sb-modal-card.type-primary .sb-modal-btn-confirm:hover {
    background: linear-gradient(135deg, #0369a1 0%, #075985 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.45);
}

.sb-modal-card.type-success .sb-modal-btn-confirm {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
}
.sb-modal-card.type-success .sb-modal-btn-confirm:hover {
    background: linear-gradient(135deg, #047857 0%, #065f46 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(5, 150, 105, 0.45);
}

.sb-modal-card.type-warning .sb-modal-btn-confirm {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.35);
}
.sb-modal-card.type-warning .sb-modal-btn-confirm:hover {
    background: linear-gradient(135deg, #b45309 0%, #92400e 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(217, 119, 6, 0.45);
}

.sb-modal-card.type-danger .sb-modal-btn-confirm {
    background: linear-gradient(135deg, #e11d48 0%, #be123c 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(225, 29, 72, 0.35);
}
.sb-modal-card.type-danger .sb-modal-btn-confirm:hover {
    background: linear-gradient(135deg, #be123c 0%, #9f1239 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(225, 29, 72, 0.45);
}

.sb-modal-btn:active {
    transform: translateY(0) scale(0.98) !important;
}

/* Single button mode (Alert / Got it) */
.sb-modal-actions.single-btn .sb-modal-btn {
    width: 100%;
    height: 48px;
    font-size: 1.025rem;
    font-weight: 700;
    letter-spacing: 0.015em;
    border-radius: 12px;
}

/* ==========================================================================
   TOAST NOTIFICATION COMPONENT
   ========================================================================== */
.sb-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: calc(100vw - 32px);
}

.sb-toast-item {
    pointer-events: auto;
    background: #ffffff;
    border-radius: 12px;
    padding: 12px 18px;
    box-shadow: 
        0 10px 25px -5px rgba(15, 23, 42, 0.15),
        0 0 0 1px rgba(226, 232, 240, 0.8);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 420px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    color: #1e293b;
    animation: sbToastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes sbToastSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.sb-toast-item.sb-toast-leave {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.2s ease;
}

.sb-toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sb-toast-item.type-success .sb-toast-icon { color: #059669; }
.sb-toast-item.type-primary .sb-toast-icon,
.sb-toast-item.type-info .sb-toast-icon { color: #2563eb; }
.sb-toast-item.type-warning .sb-toast-icon { color: #d97706; }
.sb-toast-item.type-danger .sb-toast-icon { color: #e11d48; }

/* ==========================================================================
   MOBILE RESPONSIVENESS
   ========================================================================== */
@media (max-width: 480px) {
    .sb-modal-card {
        padding: 24px 18px 20px 18px;
        border-radius: 16px;
    }
    .sb-modal-title {
        font-size: 1.125rem;
    }
    .sb-modal-message {
        font-size: 0.875rem;
        margin-bottom: 20px;
    }
    .sb-modal-actions {
        flex-direction: column-reverse;
        gap: 10px;
    }
    .sb-modal-btn {
        width: 100%;
        height: 42px;
        font-size: 0.875rem;
    }
    .sb-toast-container {
        top: 16px;
        right: 16px;
        left: 16px;
    }
    .sb-toast-item {
        min-width: 0;
        width: 100%;
    }
}
