/* ==========================================================================
   Discover Suba South — Overlay Notifications, Modals & Mobile Bottom Sheets
   Error toasts: 5s · Info/Success/Warning toasts: 3s · WCAG-accessible
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. FLOATING NOTIFICATION STACK
   -------------------------------------------------------------------------- */
.ss-toast-stack {
    position: fixed;
    top: 4.25rem;
    right: 1rem;
    z-index: 95;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: min(392px, calc(100vw - 1.5rem));
    max-width: calc(100vw - 1.5rem);
    pointer-events: none;
}

@media (max-width: 639px) {
    .ss-toast-stack {
        top: 4rem;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: calc(100vw - 1.25rem);
    }
}

.ss-toast {
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 0.9375rem 0.9375rem;
    border-radius: var(--radius-lg);
    background-color: var(--toast-bg);
    color: var(--toast-text);
    border: 1px solid var(--toast-border);
    box-shadow: var(--toast-shadow);
    opacity: 0;
    transform: translateY(-8px) scale(0.985);
    transition: opacity 0.2s var(--ease-smooth), transform 0.2s var(--ease-smooth);
}

.ss-toast.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.ss-toast.is-leaving {
    opacity: 0;
    transform: translateX(20px) scale(0.98);
}

.ss-toast__icon {
    width: 1.875rem;
    height: 1.875rem;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 0.05rem;
}

.ss-toast--success { border-left: 3.5px solid var(--color-success); }
.ss-toast--success .ss-toast__icon { background-color: var(--color-success-bg); color: var(--color-success); }
.ss-toast--success .ss-toast__progress { background-color: var(--color-success); }

.ss-toast--error { border-left: 3.5px solid var(--color-error); }
.ss-toast--error .ss-toast__icon { background-color: var(--color-error-bg); color: var(--color-error); }
.ss-toast--error .ss-toast__progress { background-color: var(--color-error); }

.ss-toast--warning { border-left: 3.5px solid var(--color-warning); }
.ss-toast--warning .ss-toast__icon { background-color: var(--color-warning-bg); color: var(--color-warning); }
.ss-toast--warning .ss-toast__progress { background-color: var(--color-warning); }

.ss-toast--info { border-left: 3.5px solid var(--color-info); }
.ss-toast--info .ss-toast__icon { background-color: var(--color-info-bg); color: var(--color-info); }
.ss-toast--info .ss-toast__progress { background-color: var(--color-info); }

.ss-toast__body {
    flex: 1 1 auto;
    min-width: 0;
}

.ss-toast__title {
    font-family: var(--font-heading);
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 0.125rem;
    color: var(--toast-text);
}

.ss-toast__message {
    font-size: 0.84375rem;
    line-height: 1.45;
    color: var(--toast-text-muted);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.ss-toast__close {
    flex-shrink: 0;
    width: 1.875rem;
    height: 1.875rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.14s ease, color 0.14s ease;
}

.ss-toast__close:hover {
    background-color: var(--color-surface-secondary);
    color: var(--toast-text);
}

.ss-toast__bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2.5px;
    background-color: var(--color-surface-secondary);
}

.ss-toast__progress {
    height: 100%;
    width: 100%;
    transform-origin: left center;
}

/* --------------------------------------------------------------------------
   2. OVERLAY MODALS (Centered on Desktop · Bottom Sheet on Mobile)
   -------------------------------------------------------------------------- */
.ss-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: var(--overlay-backdrop);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s var(--ease-smooth), visibility 0.2s var(--ease-smooth);
}

.ss-modal-backdrop.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.ss-modal-dialog {
    width: 100%;
    max-width: 448px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    border-radius: var(--radius-xl);
    background-color: var(--modal-bg);
    color: var(--color-text);
    border: 1px solid var(--modal-border);
    box-shadow: var(--modal-shadow);
    padding: 1.5rem;
    transform: translateY(8px) scale(0.97);
    transition: transform 0.22s var(--ease-smooth);
}

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

/* Mobile bottom-sheet presentation for modals */
@media (max-width: 639px) {
    .ss-modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .ss-modal-dialog {
        max-width: 100%;
        max-height: 88vh;
        border-radius: 1rem 1rem 0 0;
        border-bottom: none;
        border-left: none;
        border-right: none;
        padding: 1.25rem 1.25rem max(1.25rem, env(safe-area-inset-bottom));
        transform: translateY(100%);
    }

    .ss-modal-dialog::before {
        content: "";
        display: block;
        width: 2.25rem;
        height: 4px;
        border-radius: 9999px;
        background-color: var(--color-border);
        margin: -0.25rem auto 1rem;
    }

    .ss-modal-backdrop.is-open .ss-modal-dialog {
        transform: translateY(0);
    }
}

.ss-modal__icon-wrap {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.875rem;
}

.ss-modal__icon-wrap--danger {
    background-color: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid var(--color-error-border);
}

.ss-modal__icon-wrap--warning {
    background-color: var(--color-warning-bg);
    color: var(--color-warning);
    border: 1px solid var(--color-warning-border);
}

.ss-modal__icon-wrap--primary {
    background-color: var(--color-info-bg);
    color: var(--color-primary);
    border: 1px solid var(--color-info-border);
}

.ss-modal__icon-wrap--success {
    background-color: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid var(--color-success-border);
}

.ss-modal__title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.3;
    margin-bottom: 0.375rem;
}

.ss-modal__desc {
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--color-text-secondary);
}

.ss-modal__ref {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-md);
    background-color: var(--color-surface-secondary);
    border: 1px solid var(--color-border);
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--color-text);
}

.ss-modal__actions {
    margin-top: 1.375rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

@media (max-width: 639px) {
    .ss-modal__actions {
        flex-direction: column-reverse;
    }
    .ss-modal__actions > * {
        width: 100%;
    }
}

.ss-btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4375rem;
    min-height: 40px;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    background-color: var(--color-error);
    color: #FFFFFF;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity 0.16s ease, transform 0.12s ease;
}

@media (max-width: 767px) {
    .ss-btn-danger {
        min-height: 44px;
    }
}

.ss-btn-danger:hover {
    opacity: 0.92;
}

.ss-btn-danger:disabled,
.ss-modal__btn-loading {
    opacity: 0.65;
    cursor: not-allowed;
}

@keyframes ssSpin {
    to { transform: rotate(360deg); }
}

.ss-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 9999px;
    display: inline-block;
    animation: ssSpin 0.65s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    .ss-toast,
    .ss-modal-backdrop,
    .ss-modal-dialog {
        transition: none !important;
    }
    .ss-spinner {
        animation: none !important;
    }
}
