/* App Alerts — Premium modal, toast, loading */
body.app-alert-open {
    overflow: hidden;
}

.app-alert-layer {
    position: fixed;
    inset: 0;
    z-index: 1;
}

#app-alerts-root {
    --aa-navy: #0f172a;
    --aa-navy-soft: #1e293b;
    --aa-gold: #c9a227;
    --aa-gold-hover: #b8921f;
    --aa-white: #ffffff;
    --aa-overlay: rgba(15, 23, 42, 0.55);
    position: fixed;
    inset: 0;
    z-index: 99990;
    pointer-events: none;
}

.app-alert-overlay {
    position: fixed;
    inset: 0;
    background: var(--aa-overlay);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: auto;
}
.app-alert-overlay.is-visible { opacity: 1; }

.app-alert-modal {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -48%) scale(0.94);
    width: min(420px, calc(100vw - 2rem));
    background: var(--aa-white);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(15, 23, 42, 0.06);
    opacity: 0;
    transition: transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.22s ease;
    pointer-events: auto;
    overflow: hidden;
}
.app-alert-modal.is-visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.app-alert-modal__icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1.5rem auto 0;
    font-size: 1.35rem;
}
.app-alert-modal--success .app-alert-modal__icon { background: #ecfdf5; color: #059669; }
.app-alert-modal--warning .app-alert-modal__icon { background: #fffbeb; color: #d97706; }
.app-alert-modal--danger .app-alert-modal__icon { background: #fef2f2; color: #dc2626; }
.app-alert-modal--info .app-alert-modal__icon { background: #eff6ff; color: #2563eb; }

.app-alert-modal__body {
    padding: 1rem 1.5rem 1.25rem;
    text-align: center;
}
.app-alert-modal__title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--aa-navy);
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
}
.app-alert-modal__message {
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.55;
    margin: 0;
}
.app-alert-modal__extra {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    text-align: left;
    font-size: 0.85rem;
    color: var(--aa-navy-soft);
}
.app-alert-modal__extra strong { color: var(--aa-navy); }

.app-alert-modal__actions {
    display: flex;
    gap: 0.65rem;
    padding: 0 1.5rem 1.5rem;
}
.app-alert-modal__btn {
    flex: 1;
    padding: 0.65rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.app-alert-modal__btn:active { transform: scale(0.98); }
.app-alert-modal__btn--cancel {
    background: #f1f5f9;
    color: #475569;
}
.app-alert-modal__btn--cancel:hover { background: #e2e8f0; }
.app-alert-modal__btn--ok {
    background: var(--aa-navy);
    color: #fff;
}
.app-alert-modal__btn--ok:hover { background: var(--aa-navy-soft); }
.app-alert-modal--danger .app-alert-modal__btn--ok,
.app-alert-modal__btn--ok.app-alert-modal__btn--danger {
    background: #dc2626;
}
.app-alert-modal--danger .app-alert-modal__btn--ok:hover,
.app-alert-modal__btn--ok.app-alert-modal__btn--danger:hover { background: #b91c1c; }
.app-alert-modal--warning .app-alert-modal__btn--ok { background: #d97706; }
.app-alert-modal--success .app-alert-modal__btn--ok { background: #059669; }

/* Toast */
.app-toast-stack {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 99995;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-width: min(380px, calc(100vw - 2rem));
    pointer-events: none;
}
.app-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: var(--aa-white);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15);
    border-left: 4px solid var(--aa-navy);
    pointer-events: auto;
    animation: appToastIn 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.app-toast--success { border-left-color: #059669; }
.app-toast--warning { border-left-color: #d97706; }
.app-toast--danger { border-left-color: #dc2626; }
.app-toast--info { border-left-color: #2563eb; }
.app-toast__icon { font-size: 1.1rem; margin-top: 0.1rem; }
.app-toast--success .app-toast__icon { color: #059669; }
.app-toast--warning .app-toast__icon { color: #d97706; }
.app-toast--danger .app-toast__icon { color: #dc2626; }
.app-toast--info .app-toast__icon { color: #2563eb; }
.app-toast__text { flex: 1; font-size: 0.875rem; color: var(--aa-navy); line-height: 1.45; }
.app-toast__close {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
}
@keyframes appToastIn {
    from { opacity: 0; transform: translateX(1rem); }
    to { opacity: 1; transform: translateX(0); }
}

/* Loading */
.app-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(4px);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: auto;
}
.app-loading-overlay.is-visible { opacity: 1; }
.app-loading-box {
    background: var(--aa-white);
    padding: 1.5rem 2rem;
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.12);
    text-align: center;
    border: 1px solid #e2e8f0;
}
.app-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--aa-gold);
    border-radius: 50%;
    animation: appSpin 0.7s linear infinite;
    margin: 0 auto 0.75rem;
}
.app-loading-text { font-size: 0.9rem; color: #64748b; font-weight: 500; }
@keyframes appSpin { to { transform: rotate(360deg); } }
