/* MAC Form – Success popup (Apple HIG tokens, frontend-only) */
.mac-form-popup-overlay {
    --mac-popup-bg: #FFFFFF;
    --mac-popup-text: #1D1D1F;
    --mac-popup-muted: #6E6E73;
    --mac-popup-accent: #0071E3;
    --mac-popup-accent-hover: #0077ED;
    --mac-popup-success: #34C759;
    --mac-popup-success-soft: rgba(52, 199, 89, 0.12);
    --mac-popup-radius: 20px;
    --mac-popup-shadow: 0 24px 80px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(0, 0, 0, 0.08);
    --mac-popup-focus: 0 0 0 4px rgba(0, 113, 227, 0.25);
    --mac-popup-ease: cubic-bezier(0.25, 0.1, 0.25, 1);
    --mac-popup-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
    .mac-form-popup-overlay {
        --mac-popup-bg: #1C1C1E;
        --mac-popup-text: #F5F5F7;
        --mac-popup-muted: #98989D;
        --mac-popup-accent: #0A84FF;
        --mac-popup-accent-hover: #409CFF;
        --mac-popup-success: #30D158;
        --mac-popup-success-soft: rgba(48, 209, 88, 0.16);
        --mac-popup-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
        --mac-popup-focus: 0 0 0 4px rgba(10, 132, 255, 0.35);
    }
}

html.mac-form-popup-open,
html.mac-form-popup-open body {
    overflow: hidden;
}

.mac-form-popup-src[hidden],
.mac-form-popup-overlay[hidden] {
    display: none !important;
}

.mac-form-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.36);
    -webkit-backdrop-filter: blur(8px) saturate(140%);
    backdrop-filter: blur(8px) saturate(140%);
    box-sizing: border-box;
    font-family: var(--mac-popup-font);
}

.mac-form-popup-dialog {
    position: relative;
    width: 100%;
    max-width: 400px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 36px 28px 24px;
    background: var(--mac-popup-bg);
    color: var(--mac-popup-text);
    border-radius: var(--mac-popup-radius);
    box-shadow: var(--mac-popup-shadow);
    box-sizing: border-box;
    text-align: center;
    outline: none;
    animation: mac-form-popup-in 220ms var(--mac-popup-ease);
}

.mac-form-popup-dialog.is-template {
    max-width: 720px;
    padding: 0;
    text-align: initial;
    background: var(--mac-popup-bg);
}

.mac-form-popup-x {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    width: 28px;
    height: 28px;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 9999px;
    background: rgba(120, 120, 128, 0.16);
    color: var(--mac-popup-muted);
    font-size: 20px;
    line-height: 28px;
    cursor: pointer;
    transition: background 160ms var(--mac-popup-ease), color 160ms var(--mac-popup-ease);
}

.mac-form-popup-x:hover {
    background: rgba(120, 120, 128, 0.28);
    color: var(--mac-popup-text);
}

.mac-form-popup-x:focus-visible {
    outline: none;
    box-shadow: var(--mac-popup-focus);
}

.mac-form-popup-dialog:not(.is-template) .mac-form-popup-body {
    position: relative;
}

.mac-form-popup-dialog:not(.is-template) .mac-form-popup-body::before {
    content: "";
    display: block;
    width: 56px;
    height: 56px;
    margin: 4px auto 18px;
    border-radius: 50%;
    background: var(--mac-popup-success-soft);
    box-shadow: inset 0 0 0 2px var(--mac-popup-success);
}

.mac-form-popup-dialog:not(.is-template) .mac-form-popup-body::after {
    content: "";
    position: absolute;
    top: 18px;
    left: 50%;
    width: 28px;
    height: 28px;
    margin-left: -14px;
    background: var(--mac-popup-success);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 12 10.5 16.5 18 8'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 12 10.5 16.5 18 8'/%3E%3C/svg%3E") center / contain no-repeat;
}

.mac-form-popup-title {
    margin: 0 0 8px;
    font-family: inherit;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.022em;
    line-height: 1.25;
    color: var(--mac-popup-text);
}

.mac-form-popup-message {
    margin: 0 0 24px;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.47;
    letter-spacing: -0.016em;
    color: var(--mac-popup-muted);
    white-space: pre-line;
}

.mac-form-popup-actions {
    display: flex;
    justify-content: center;
}

.mac-form-popup-ok {
    min-width: 132px;
    height: 44px;
    padding: 0 22px;
    border: 0;
    border-radius: 9999px;
    background: var(--mac-popup-accent);
    color: #fff;
    font-family: inherit;
    font-size: 17px;
    font-weight: 590;
    letter-spacing: -0.022em;
    line-height: 1;
    cursor: pointer;
    transition: background 160ms var(--mac-popup-ease), transform 100ms var(--mac-popup-ease);
}

.mac-form-popup-ok:hover {
    background: var(--mac-popup-accent-hover);
}

.mac-form-popup-ok:active {
    transform: scale(0.97);
}

.mac-form-popup-ok:focus-visible {
    outline: none;
    box-shadow: var(--mac-popup-focus);
}

@keyframes mac-form-popup-in {
    from { opacity: 0; transform: translateY(10px) scale(0.96); }
    to   { opacity: 1; transform: none; }
}

@media (max-width: 600px) {
    .mac-form-popup-dialog {
        max-width: 100%;
        padding: 32px 20px 20px;
        border-radius: 16px;
    }
    .mac-form-popup-dialog.is-template {
        padding: 0;
    }
    .mac-form-popup-ok {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mac-form-popup-dialog {
        animation: none;
    }
    .mac-form-popup-ok:active {
        transform: none;
    }
}
