/* ==========================================================================
   SwissDialog CSS
   Universal Promise-based dialogs for Admin V3
   ========================================================================== */

#swiss-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
}

#swiss-dialog-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

#swiss-dialog {
    background: var(--ad-surface, #fff);
    border: 1px solid var(--ad-border, #e5e7eb);
    border-radius: 12px;
    width: min(90vw, 420px);
    padding: 24px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0,0,0,0.05);
    transform: scale(0.96) translateY(8px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    color: var(--ad-text, #111827);
    font-family: inherit;
}

#swiss-dialog-overlay.is-open #swiss-dialog {
    transform: scale(1) translateY(0);
}

.sd-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.sd-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.sd-icon svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
}

.sd-type-success .sd-icon { color: var(--ad-success, #10b981); background: rgba(16, 185, 129, 0.15); }
.sd-type-error .sd-icon { color: var(--ad-danger, #dc2626); background: rgba(220, 38, 38, 0.15); }
.sd-type-warning .sd-icon { color: var(--ad-warning, #f59e0b); background: rgba(245, 158, 11, 0.15); }
.sd-type-prompt .sd-icon { color: var(--ad-accent, #7B1D1D); background: rgba(123, 29, 29, 0.15); }

.sd-title {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
}

.sd-message {
    font-size: 0.95rem;
    color: var(--ad-text-2, #4b5563);
    line-height: 1.5;
    margin-bottom: 20px;
}

.sd-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    border: 1px solid var(--ad-border, #e5e7eb);
    border-radius: 6px;
    background: var(--ad-surface-2, #f9fafb);
    color: var(--ad-text, #111827);
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.sd-input:focus {
    border-color: var(--ad-accent, #7B1D1D);
    box-shadow: 0 0 0 3px rgba(123, 29, 29, 0.1);
}

.sd-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.sd-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.sd-btn-cancel {
    background: transparent;
    color: var(--ad-text-2, #4b5563);
    border: 1px solid var(--ad-border, #e5e7eb);
}

.sd-btn-cancel:hover {
    background: var(--ad-surface-2, #f9fafb);
    color: var(--ad-text, #111827);
}

.sd-btn-confirm {
    background: var(--ad-accent, #7B1D1D);
    color: #fff;
}

.sd-btn-confirm:hover {
    filter: brightness(1.1);
}

/* Specific confirm button styling based on type */
.sd-type-error .sd-btn-confirm { background: var(--ad-danger, #dc2626); }
.sd-type-success .sd-btn-confirm { background: var(--ad-success, #10b981); }

/* ── Added when the script was finally wired up site-wide ──────────────
   The rules above were written for a dialog that only four pages loaded, so
   these gaps never showed. */

/* The page must not scroll behind an open dialog. */
body.sd-open {
    overflow: hidden;
}

/* prompt() is only ever used for irreversible actions in this codebase —
   both call sites ask the operator to type DELETE — so its confirm button
   is red rather than the default accent. */
.sd-type-prompt .sd-btn-confirm {
    background: var(--ad-danger, #dc2626);
}

.sd-btn:focus-visible,
.sd-input:focus-visible {
    outline: 2px solid var(--ad-accent, #7B1D1D);
    outline-offset: 2px;
}

@media (width <= 480px) {
    #swiss-dialog {
        width: calc(100vw - 24px);
        padding: 18px;
    }

    .sd-actions {
        flex-direction: column-reverse;
    }

    .sd-btn {
        width: 100%;
    }
}
