/*
 * Confirmation dialogs (qzConfirm, wwwroot/js/confirm-dialog.js) and the canvas's form dialogs that
 * share the look (the commit modal). Loaded by _Layout, so every page has the same one.
 *
 * Compact on purpose: a confirmation is a sentence and two buttons, not a page. The tone colours the
 * icon and the action — accent for an ordinary confirmation, amber for a security-sensitive or
 * disruptive one, red only for what cannot be undone. Tokens come from design-tokens.css where a
 * page loads it; the fallbacks are the same values, for pages that do not.
 */
.confirm-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(5, 8, 15, 0.55);
    animation: confirm-fade .12s ease-out;
}
.confirm-modal-backdrop[hidden] { display: none; }

.confirm-modal {
    --tone: var(--accent, #3b82f6);
    width: 100%;
    max-width: 420px;
    background: var(--bg-card, #232638);
    border: 1px solid var(--border, #2f3447);
    border-radius: 12px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
    color: var(--text, #e2e8f0);
    animation: confirm-rise .14s ease-out;
}
.qz-confirm[data-tone="warning"] .confirm-modal { --tone: var(--warn, #f59e0b); }
.qz-confirm[data-tone="danger"] .confirm-modal { --tone: var(--danger, #ef4444); }

.confirm-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px 6px;
}
.confirm-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 14px;
    color: var(--tone);
    background: color-mix(in srgb, var(--tone) 14%, transparent);
}
.confirm-modal-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text, #e2e8f0);
}
.confirm-modal-body {
    padding: 4px 18px 4px 60px;
    max-height: 55vh;
    overflow-y: auto;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}
.confirm-modal-body[hidden] { display: none; }

/* Only a body that scrolls takes focus (confirm-dialog.js adds the tabindex), and when it does the
   focus has to be visible — otherwise Tab appears to go nowhere before it reaches Cancel. */
.confirm-modal-body[tabindex]:focus-visible {
    outline: 2px solid var(--accent, #6366f1);
    outline-offset: -2px;
    border-radius: 6px;
}
.confirm-modal-body p {
    margin: 0 0 8px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-secondary, #94a3b8);
    overflow-wrap: anywhere;
}
.confirm-modal-body p:last-child { margin-bottom: 0; }
.confirm-modal-warning { color: var(--warn, #f59e0b) !important; font-weight: 500; }

.confirm-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 18px 16px;
}
.confirm-modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.confirm-modal-btn i { font-size: 12px; }
.confirm-modal-btn:focus-visible { outline: 2px solid var(--border-focus, #818cf8); outline-offset: 2px; }
.confirm-modal-btn-secondary {
    color: var(--text-secondary, #94a3b8);
    background: transparent;
    border-color: var(--border, #2f3447);
}
.confirm-modal-btn-secondary:hover { color: var(--text, #e2e8f0); background: var(--bg-hover, #1e2636); }
.confirm-modal-btn-primary { color: #fff; background: var(--accent, #3b82f6); }
.confirm-modal-btn-primary:hover { background: var(--accent-hover, #2563eb); }
.confirm-modal-btn-warning {
    color: #fcd34d;
    background: color-mix(in srgb, var(--warn, #f59e0b) 16%, transparent);
    border-color: color-mix(in srgb, var(--warn, #f59e0b) 45%, transparent);
}
.confirm-modal-btn-warning:hover { background: color-mix(in srgb, var(--warn, #f59e0b) 26%, transparent); }
.confirm-modal-btn-danger { color: #fff; background: #dc2626; }
.confirm-modal-btn-danger:hover { background: #b91c1c; }

/* qzPrompt: one field, its problem written right under it. */
.confirm-modal-field { display: flex; flex-direction: column; gap: 6px; padding: 8px 18px 0 60px; }
.confirm-modal-field[hidden] { display: none; }
.confirm-modal-field label { margin: 0; font-size: 12px; font-weight: 500; color: var(--text-secondary, #94a3b8); }
.confirm-modal-field label[hidden] { display: none; }
.confirm-modal-field input {
    width: 100%;
    height: 34px;
    padding: 0 10px;
    font: 13px var(--font-mono, ui-monospace, SFMono-Regular, Consolas, monospace);
    color: var(--text, #e2e8f0);
    background: var(--bg-input, #1c2230);
    border: 1px solid var(--border, #2f3447);
    border-radius: 7px;
    outline: none;
}
.confirm-modal-field input:focus { border-color: var(--border-focus, #818cf8); box-shadow: 0 0 0 3px color-mix(in srgb, var(--border-focus, #818cf8) 20%, transparent); }
.confirm-modal-field input[aria-invalid="true"] { border-color: color-mix(in srgb, var(--danger, #ef4444) 70%, transparent); }
.confirm-modal-error { min-height: 16px; font-size: 12px; line-height: 1.35; color: #fca5a5; }
.confirm-modal-btn:disabled { opacity: .45; cursor: not-allowed; }

/* qzNotify: top right, like the workspace toasts it sits beside; sticky ones wait to be dismissed. */
.qz-notify-stack {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(380px, calc(100vw - 40px));
    pointer-events: none;
}
.qz-notify {
    --tone: var(--accent, #3b82f6);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 10px 10px 14px;
    background: var(--bg-card, #232638);
    border: 1px solid var(--border, #2f3447);
    border-left: 3px solid var(--tone);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    font-size: 13px;
    line-height: 1.45;
    color: var(--text, #e2e8f0);
    pointer-events: auto;
    animation: confirm-rise .14s ease-out;
}
.qz-notify[data-tone="success"] { --tone: var(--success, #22c55e); }
.qz-notify[data-tone="warning"] { --tone: var(--warn, #f59e0b); }
.qz-notify[data-tone="error"] { --tone: var(--danger, #ef4444); }
.qz-notify > i { margin-top: 2px; color: var(--tone); }
.qz-notify-text { flex: 1; min-width: 0; white-space: pre-line; overflow-wrap: anywhere; }
.qz-notify-close { flex: none; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 5px; background: none; color: var(--text-muted, #64748b); font-size: 16px; line-height: 1; cursor: pointer; }
.qz-notify-close:hover { color: var(--text, #e2e8f0); background: var(--bg-hover, #1e2636); }

@keyframes confirm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes confirm-rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .confirm-modal-backdrop, .confirm-modal, .qz-notify { animation: none; }
}
