﻿.api-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(2, 6, 23, .72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: apiOverlayEnter .2s ease both;
}

.api-dialog {
    --dialog-color: #dc2626;
    --dialog-color-dark: #991b1b;
    --dialog-soft: #fef2f2;
    --dialog-border: #fecaca;
    --dialog-glow: rgba(220, 38, 38, .25);
    position: relative;
    width: min(650px, 100%);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    direction: rtl;
    padding: 42px 42px 28px;
    color: #0f172a;
    background: radial-gradient( circle at top, var(--dialog-soft) 0, #ffffff 48% );
    border: 1px solid var(--dialog-border);
    border-radius: 30px;
    box-shadow: 0 40px 120px rgba(2, 6, 23, .48), 0 0 0 8px rgba(255, 255, 255, .06), 0 0 70px var(--dialog-glow);
    text-align: center;
    animation: apiDialogEnter .28s cubic-bezier(.2, .8, .2, 1) both;
}

.api-dialog-error {
    --dialog-color: #dc2626;
    --dialog-color-dark: #991b1b;
    --dialog-soft: #fef2f2;
    --dialog-border: #fecaca;
    --dialog-glow: rgba(220, 38, 38, .24);
}

.api-dialog-warning {
    --dialog-color: #d97706;
    --dialog-color-dark: #92400e;
    --dialog-soft: #fffbeb;
    --dialog-border: #fde68a;
    --dialog-glow: rgba(217, 119, 6, .22);
}

.api-dialog-info {
    --dialog-color: #2563eb;
    --dialog-color-dark: #1e40af;
    --dialog-soft: #eff6ff;
    --dialog-border: #bfdbfe;
    --dialog-glow: rgba(37, 99, 235, .22);
}

.api-dialog-success {
    --dialog-color: #15803d;
    --dialog-color-dark: #166534;
    --dialog-soft: #f0fdf4;
    --dialog-border: #bbf7d0;
    --dialog-glow: rgba(21, 128, 61, .22);
}

.api-dialog-close {
    position: absolute;
    top: 18px;
    left: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    color: #64748b;
    background: rgba(255, 255, 255, .72);
    border: 1px solid rgba(148, 163, 184, .22);
    border-radius: 14px;
    cursor: pointer;
    font-family: inherit;
    font-size: 28px;
    line-height: 1;
    transition: color .2s ease, background .2s ease, transform .2s ease, border-color .2s ease;
}

    .api-dialog-close:hover:not(:disabled) {
        color: #0f172a;
        background: #ffffff;
        border-color: #cbd5e1;
        transform: rotate(5deg);
    }

    .api-dialog-close:disabled {
        cursor: not-allowed;
        opacity: .5;
    }

.api-dialog-icon-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

    .api-dialog-icon-wrap::before,
    .api-dialog-icon-wrap::after {
        content: "";
        position: absolute;
        top: 50%;
        width: 84px;
        height: 1px;
        background: linear-gradient( 90deg, transparent, var(--dialog-border) );
    }

    .api-dialog-icon-wrap::before {
        right: calc(50% + 70px);
    }

    .api-dialog-icon-wrap::after {
        left: calc(50% + 70px);
        transform: rotate(180deg);
    }

.api-dialog-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 104px;
    height: 104px;
    color: #ffffff;
    background: linear-gradient( 145deg, var(--dialog-color), var(--dialog-color-dark) );
    border: 8px solid rgba(255, 255, 255, .78);
    border-radius: 32px;
    box-shadow: 0 20px 50px var(--dialog-glow), inset 0 1px 0 rgba(255, 255, 255, .28);
    font-size: 58px;
    font-weight: 800;
    line-height: 1;
    transform: rotate(-3deg);
}

.api-dialog-content {
    max-width: 520px;
    margin: 0 auto;
}

.api-dialog-label {
    margin-bottom: 10px;
    color: var(--dialog-color);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 3px;
}

.api-dialog-title {
    margin: 0 0 15px;
    color: #0f172a;
    font-size: clamp(26px, 4vw, 36px);
    font-weight: 900;
    line-height: 1.25;
}

.api-dialog-message {
    margin: 0;
    color: #475569;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.9;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.api-dialog-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 32px;
}

.api-dialog-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-width: 150px;
    min-height: 48px;
    padding: 11px 22px;
    border-radius: 14px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 800;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease, opacity .2s ease;
}

    .api-dialog-button:hover:not(:disabled) {
        transform: translateY(-2px);
    }

    .api-dialog-button:disabled {
        cursor: not-allowed;
        opacity: .62;
    }

.api-dialog-retry {
    color: #ffffff;
    background: linear-gradient( 135deg, var(--dialog-color), var(--dialog-color-dark) );
    border: 1px solid transparent;
    box-shadow: 0 14px 30px var(--dialog-glow);
}

    .api-dialog-retry:hover:not(:disabled) {
        box-shadow: 0 18px 38px var(--dialog-glow);
    }

.api-dialog-dismiss {
    color: #334155;
    background: #ffffff;
    border: 1px solid #dbe3ed;
}

    .api-dialog-dismiss:hover:not(:disabled) {
        background: #f8fafc;
        border-color: #cbd5e1;
        box-shadow: 0 10px 25px rgba(15, 23, 42, .10);
    }

.api-button-icon {
    font-size: 20px;
    line-height: 1;
}

.api-button-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, .42);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: apiSpin .7s linear infinite;
}

.api-dialog-footer {
    margin-top: 26px;
    padding-top: 18px;
    color: #94a3b8;
    border-top: 1px solid #e2e8f0;
    font-size: 12px;
    font-weight: 600;
}

/* Toasts */

.api-toast-container {
    position: fixed;
    top: 22px;
    right: 22px;
    z-index: 9999998;
    display: flex;
    flex-direction: column;
    gap: 13px;
    width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}

.api-toast {
    --toast-color: #2563eb;
    --toast-soft: #eff6ff;
    --toast-border: #bfdbfe;
    position: relative;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 32px;
    gap: 12px;
    align-items: flex-start;
    overflow: hidden;
    padding: 16px 15px 17px;
    direction: rtl;
    color: #0f172a;
    background: rgba(255, 255, 255, .97);
    border: 1px solid var(--toast-border);
    border-radius: 17px;
    box-shadow: 0 22px 60px rgba(15, 23, 42, .18), 0 8px 24px rgba(15, 23, 42, .10);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    pointer-events: auto;
    animation: apiToastEnter .25s ease both;
}

.api-toast-success {
    --toast-color: #15803d;
    --toast-soft: #f0fdf4;
    --toast-border: #bbf7d0;
}

.api-toast-warning {
    --toast-color: #d97706;
    --toast-soft: #fffbeb;
    --toast-border: #fde68a;
}

.api-toast-info {
    --toast-color: #2563eb;
    --toast-soft: #eff6ff;
    --toast-border: #bfdbfe;
}

.api-toast-error {
    --toast-color: #dc2626;
    --toast-soft: #fef2f2;
    --toast-border: #fecaca;
}

.api-toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    color: var(--toast-color);
    background: var(--toast-soft);
    border: 1px solid var(--toast-border);
    border-radius: 13px;
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
}

.api-toast-content {
    min-width: 0;
}

.api-toast-title {
    margin-bottom: 4px;
    color: #0f172a;
    font-size: 14px;
    font-weight: 850;
    line-height: 1.5;
}

.api-toast-message {
    color: #64748b;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.7;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.api-toast-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    color: #64748b;
    background: transparent;
    border: 0;
    border-radius: 9px;
    cursor: pointer;
    font-family: inherit;
    font-size: 23px;
    line-height: 1;
}

    .api-toast-close:hover {
        color: #0f172a;
        background: #f1f5f9;
    }

.api-toast-progress {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 4px;
    background: var(--toast-color);
    transform-origin: right center;
    animation-name: apiToastProgress;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

@keyframes apiOverlayEnter {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes apiDialogEnter {
    from {
        opacity: 0;
        transform: translateY(30px) scale(.94);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes apiToastEnter {
    from {
        opacity: 0;
        transform: translateX(28px) scale(.97);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes apiToastProgress {
    from {
        transform: scaleX(1);
    }

    to {
        transform: scaleX(0);
    }
}

@keyframes apiSpin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 650px) {
    .api-dialog-overlay {
        align-items: flex-end;
        padding: 12px;
    }

    .api-dialog {
        width: 100%;
        max-height: calc(100vh - 24px);
        padding: 36px 20px 24px;
        border-radius: 26px;
    }

    .api-dialog-icon {
        width: 88px;
        height: 88px;
        border-radius: 27px;
        font-size: 48px;
    }

    .api-dialog-title {
        font-size: 25px;
    }

    .api-dialog-message {
        font-size: 14px;
    }

    .api-dialog-actions {
        flex-direction: column;
    }

    .api-dialog-button {
        width: 100%;
    }

    .api-dialog-icon-wrap::before,
    .api-dialog-icon-wrap::after {
        display: none;
    }

    .api-toast-container {
        top: 14px;
        right: 14px;
        left: 14px;
        width: auto;
    }
}

/* Dark Mode */

html[data-theme="dark"] .api-dialog,
body.dark-mode .api-dialog,
.dark .api-dialog {
    color: #f8fafc;
    background: radial-gradient( circle at top, color-mix( in srgb, var(--dialog-color) 14%, #0f172a ), #0f172a 50% );
    border-color: rgba(148, 163, 184, .22);
}

html[data-theme="dark"] .api-dialog-title,
body.dark-mode .api-dialog-title,
.dark .api-dialog-title {
    color: #f8fafc;
}

html[data-theme="dark"] .api-dialog-message,
body.dark-mode .api-dialog-message,
.dark .api-dialog-message {
    color: #cbd5e1;
}

html[data-theme="dark"] .api-dialog-footer,
body.dark-mode .api-dialog-footer,
.dark .api-dialog-footer {
    color: #94a3b8;
    border-color: rgba(148, 163, 184, .18);
}

html[data-theme="dark"] .api-dialog-dismiss,
body.dark-mode .api-dialog-dismiss,
.dark .api-dialog-dismiss {
    color: #e2e8f0;
    background: #1e293b;
    border-color: #334155;
}

html[data-theme="dark"] .api-dialog-close,
body.dark-mode .api-dialog-close,
.dark .api-dialog-close {
    color: #cbd5e1;
    background: rgba(30, 41, 59, .82);
    border-color: #334155;
}

html[data-theme="dark"] .api-toast,
body.dark-mode .api-toast,
.dark .api-toast {
    color: #f8fafc;
    background: rgba(15, 23, 42, .96);
    border-color: rgba(148, 163, 184, .22);
}

html[data-theme="dark"] .api-toast-title,
body.dark-mode .api-toast-title,
.dark .api-toast-title {
    color: #f8fafc;
}

html[data-theme="dark"] .api-toast-message,
body.dark-mode .api-toast-message,
.dark .api-toast-message {
    color: #cbd5e1;
}
