/**
 * Site-wide alert modals — custom tpModal + SweetAlert2 fallback.
 * Light / dark via html.dark (and html:not(.dark) for light).
 */

/* ── Custom tpModal ─────────────────────────────────────────────── */
.tp-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
    z-index: 10000020;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

html:not(.dark) .tp-modal-overlay {
    background: rgba(15, 23, 42, 0.42);
}

.tp-modal-overlay.active {
    display: flex;
}

.tp-modal-box {
    background: var(--tpz-surface, #111519);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 1.7rem 1.45rem 1.35rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    animation: tpModalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: 'Quicksand', 'Patrick Hand', system-ui, sans-serif;
    color: #edf2f7;
}

html:not(.dark) .tp-modal-box {
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.08);
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.16);
    color: #0f172a;
}

@keyframes tpModalIn {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.tp-modal-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1.05rem;
    font-weight: 700;
}

.tp-modal-icon.question {
    border-color: #93c5fd !important;
    color: #3b82f6 !important;
    background: transparent !important;
}

.tp-modal-icon.error {
    border-color: #fca5a5;
    color: #ef4444;
}

.tp-modal-icon.success {
    border-color: var(--tpz-green, #30995b);
    color: var(--tpz-green, #30995b);
    background: var(--tpz-green-dim, rgba(48, 153, 91, 0.12));
}

.tp-modal-icon.warning {
    border-color: #fcd34d;
    color: #f59e0b;
}

.tp-modal-icon.info {
    border-color: #93c5fd;
    color: #3b82f6;
}

.tp-modal-spinner {
    width: 46px;
    height: 46px;
    border: 3px solid rgba(255, 255, 255, 0.14);
    border-top-color: var(--tpz-green, #30995b);
    border-radius: 50%;
    animation: tpModalSpin 0.8s linear infinite;
    margin: 0 auto 1.1rem;
}

html:not(.dark) .tp-modal-spinner {
    border-color: rgba(15, 23, 42, 0.12);
    border-top-color: var(--tpz-green, #30995b);
}

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

.tp-modal-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: inherit;
    margin: 0 0 0.4rem;
    line-height: 1.25;
}

.tp-modal-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: #94a3b8;
    line-height: 1.5;
    margin: 0 0 1.35rem;
}

html:not(.dark) .tp-modal-text {
    color: #475569;
}

.tp-modal-btns {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.tp-modal-btns.row {
    flex-direction: row;
    gap: 0.65rem;
}

.tp-modal-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s, transform 0.12s, filter 0.12s;
}

.tp-modal-btn:hover {
    filter: brightness(1.06);
}

.tp-modal-btn:active {
    transform: scale(0.98);
}

.tp-modal-btn.primary {
    background: var(--tpz-green, #30995b) !important;
    color: #fff !important;
    box-shadow: 0 8px 18px var(--tpz-green-glow, rgba(48, 153, 91, 0.28));
}

.tp-modal-btn.ghost,
.tp-modal-btn.cancel {
    background: #64748b !important;
    color: #fff !important;
    border: none !important;
}

html.dark .tp-modal-btn.ghost,
html.dark .tp-modal-btn.cancel {
    background: #4b5563 !important;
}

.tp-modal-btn.danger {
    background: #ef4444;
    color: #fff;
    box-shadow: 0 8px 18px rgba(239, 68, 68, 0.28);
}

/* ── SweetAlert2 themed fallback ────────────────────────────────── */
.tp-swal-popup {
    border-radius: 18px !important;
    padding: 1.55rem 1.4rem 1.25rem !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    box-shadow: 0 24px 56px rgba(15, 23, 42, 0.18) !important;
    font-family: 'Quicksand', 'Patrick Hand', system-ui, sans-serif !important;
    max-width: 400px !important;
    width: calc(100% - 2rem) !important;
}

html.dark .tp-swal-popup {
    border-color: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5) !important;
}

.tp-swal-title {
    font-size: 1.35rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em;
    padding: 0 !important;
    margin: 0 0 0.35rem !important;
    color: inherit !important;
}

.tp-swal-text {
    font-size: 0.95rem !important;
    line-height: 1.5 !important;
    font-weight: 500 !important;
    padding: 0 !important;
    margin: 0 !important;
    color: #475569 !important;
}

html.dark .tp-swal-text {
    color: #94a3b8 !important;
}

.tp-swal-actions {
    gap: 0.65rem !important;
    margin-top: 1.35rem !important;
    width: 100%;
    flex-wrap: nowrap !important;
}

.tp-swal-btn {
    border-radius: 12px !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    font-family: inherit !important;
    padding: 0.72rem 1.1rem !important;
    min-width: 0;
    flex: 1 1 0;
    transition: transform 0.12s, filter 0.12s !important;
    box-shadow: none !important;
}

.tp-swal-btn:active {
    transform: scale(0.98);
}

.tp-swal-btn--confirm {
    background: var(--tpz-green, #30995b) !important;
    color: #fff !important;
    border: 1px solid var(--tpz-green, #30995b) !important;
    box-shadow: 0 8px 18px var(--tpz-green-glow, rgba(48, 153, 91, 0.28)) !important;
}

.tp-swal-btn--confirm:hover {
    filter: brightness(1.06);
}

.tp-swal-btn--cancel {
    background: #64748b !important;
    color: #fff !important;
    border: 1px solid #64748b !important;
}

html.dark .tp-swal-btn--cancel {
    background: #4b5563 !important;
    border-color: #4b5563 !important;
}

.tp-swal-popup.swal2-icon-warning .tp-swal-btn--confirm,
.tp-swal-popup[data-danger="1"] .tp-swal-btn--confirm {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    box-shadow: 0 8px 18px rgba(239, 68, 68, 0.28) !important;
}

.tp-swal-close,
.swal2-close {
    appearance: none !important;
    -webkit-appearance: none !important;
    width: 34px !important;
    height: 34px !important;
    margin: 8px 8px 0 0 !important;
    padding: 0 !important;
    border: 1px solid transparent !important;
    border-radius: 10px !important;
    background: transparent !important;
    color: #94a3b8 !important;
    font-size: 1.35rem !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    box-shadow: none !important;
    outline: none !important;
}

.tp-swal-close:hover,
.swal2-close:hover {
    color: #0f172a !important;
    background: rgba(15, 23, 42, 0.06) !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
}

html.dark .tp-swal-close:hover,
html.dark .swal2-close:hover {
    color: #f1f5f9 !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.tp-swal-popup .swal2-close {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
}

.tp-swal-icon {
    border: none !important;
    margin: 0 auto 1rem !important;
    transform: none !important;
}

.tp-swal-icon.swal2-question {
    color: #3b82f6 !important;
    border-color: #93c5fd !important;
}

.tp-swal-icon.swal2-success {
    color: var(--tpz-green, #30995b) !important;
    border-color: var(--tpz-green, #30995b) !important;
}

.tp-swal-icon.swal2-error {
    color: #ef4444 !important;
    border-color: #fca5a5 !important;
}

.tp-swal-icon.swal2-warning {
    color: #f59e0b !important;
    border-color: #fcd34d !important;
}

.tp-swal-icon.swal2-info {
    color: #3b82f6 !important;
    border-color: #93c5fd !important;
}

.tp-swal-toast {
    border-radius: 14px !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14) !important;
    font-family: 'Quicksand', system-ui, sans-serif !important;
    padding: 12px 16px !important;
}

html.dark .tp-swal-toast {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Hide colored timer strip on toast edges */
.tp-swal-toast .swal2-timer-progress-bar,
.swal2-timer-progress-bar {
    display: none !important;
    background: transparent !important;
}

.swal2-container.tp-swal-container {
    z-index: 10000020 !important;
}

/*
 * SweetAlert2 marks toast mode on body (body.swal2-toast-shown), then sizes the
 * container to a ~360px column. Backdrop-filter on that column frosts a tall
 * glassy strip behind the toast — never blur toast containers.
 */
body:not(.swal2-toast-shown) .swal2-container.tp-swal-container {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body.swal2-toast-shown .swal2-container.tp-swal-container,
.swal2-container.tp-swal-container.swal2-toast-shown,
.swal2-container.tp-swal-container:has(.swal2-toast) {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: transparent !important;
}
