/* Runtime UI components used by global JavaScript helpers. */

.clipboard-hidden-textarea {
    position: fixed;
    left: -999999px;
    top: -999999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.toast-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: auto;
    max-width: min(450px, calc(100vw - 40px));
    overflow-wrap: anywhere;
    padding: 12px 24px;
    border-radius: 8px;
    color: #fff;
    font-weight: 500;
    z-index: 9999;
    animation: choiceryToastSlideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-notification.toast-success {
    background-color: #28a745;
}

.toast-notification.toast-error {
    background-color: #dc3545;
}

.toast-notification.toast-warning {
    background-color: #ffc107;
    color: #212529;
}

.toast-notification.toast-info {
    background-color: #17a2b8;
}

.toast-notification.toast-notification-exit {
    animation: choiceryToastSlideOut 0.3s ease;
}

@keyframes choiceryToastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes choiceryToastSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

#notify-snackbar-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
    max-width: min(450px, calc(100vw - 48px));
}

.notify-snackbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: #323232;
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    font-size: 14px;
    font-weight: 500;
    pointer-events: auto;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 100%;
    overflow-wrap: anywhere;
}

.notify-snackbar.show {
    transform: translateY(0);
    opacity: 1;
}

.notify-snackbar.hiding {
    transform: translateY(100px);
    opacity: 0;
}

.notify-snackbar.success {
    background: #2e7d32;
}

.notify-snackbar.error {
    background: #c62828;
}

.notify-snackbar.warning {
    background: #f57c00;
}

.notify-snackbar.info {
    background: #1565c0;
}

.notify-snackbar.undo {
    position: relative;
    overflow: hidden;
    background: #323232;
}

.notify-snackbar-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notify-snackbar-message {
    flex: 1;
    line-height: 1.4;
}

.notify-snackbar-message a {
    color: #4fc3f7;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.notify-snackbar-message a:hover {
    color: #81d4fa;
}

.notify-snackbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.notify-snackbar-btn {
    background: transparent;
    border: none;
    color: #ffeb3b;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background 0.2s;
    letter-spacing: 0.5px;
}

.notify-snackbar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.notify-snackbar-btn.undo-btn {
    color: #4fc3f7;
}

.notify-snackbar-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.notify-snackbar-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.notify-snackbar-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 0 0 8px 8px;
    transform: scaleX(1);
    transform-origin: left center;
}

.notify-snackbar-progress.running {
    animation-name: notifyProgressShrink;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

.notify-progress-duration-1000 { animation-duration: 1000ms; }
.notify-progress-duration-2000 { animation-duration: 2000ms; }
.notify-progress-duration-3000 { animation-duration: 3000ms; }
.notify-progress-duration-4000 { animation-duration: 4000ms; }
.notify-progress-duration-5000 { animation-duration: 5000ms; }
.notify-progress-duration-6000 { animation-duration: 6000ms; }
.notify-progress-duration-8000 { animation-duration: 8000ms; }
.notify-progress-duration-10000 { animation-duration: 10000ms; }

@keyframes notifyProgressShrink {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.notify-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.notify-modal-backdrop.show {
    opacity: 1;
}

.notify-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 420px;
    width: 90%;
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
    /* A confirm dialog can carry a long list (publish blockers, flow-integrity
       warnings). Without a viewport bound the dialog grows past both screen
       edges and the Cancel/Confirm buttons become unreachable: the backdrop is
       position:fixed, so nothing scrolls it back into view. Bound the dialog to
       the viewport and let the body scroll instead, keeping the title and the
       buttons pinned. */
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
}

/* Opt-in wider dialog for list content (publish blockers, flow-integrity
   warnings). `width: 90%` above still keeps it inside narrow viewports. */
.notify-modal-wide {
    max-width: 680px;
}

.notify-modal-backdrop.show .notify-modal {
    transform: scale(1);
    opacity: 1;
}

.notify-modal-header {
    padding: 20px 24px 0;
    flex: 0 0 auto;
}

.notify-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a202c;
    margin: 0;
}

.notify-modal-body {
    padding: 16px 24px;
    font-size: 14px;
    color: #4a5568;
    line-height: 1.6;
    /* Long unbroken tokens (e.g. a full email address in a confirm message)
       must wrap inside the fixed-width modal instead of overflowing it. */
    overflow-wrap: anywhere;
    word-break: break-word;
    /* Scroll region of the bounded dialog. min-height:0 lets this flex child
       shrink below its content height, which is what makes the scroll happen
       instead of the dialog growing. */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.notify-modal-footer {
    padding: 16px 24px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex: 0 0 auto;
}

.notify-modal-btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.notify-modal-btn-cancel {
    background: #f7fafc;
    color: #4a5568;
    border: 1px solid #e2e8f0;
}

.notify-modal-btn-cancel:hover {
    background: #edf2f7;
}

.notify-modal-btn-confirm {
    background: #3182ce;
    color: #fff;
}

.notify-modal-btn-confirm:hover {
    background: #2c5282;
}

.notify-modal-btn-confirm.btn-danger {
    background: #e53e3e;
}

.notify-modal-btn-confirm.btn-danger:hover {
    background: #c53030;
}

.notify-modal-btn-confirm.btn-warning {
    background: #dd6b20;
}

.notify-modal-btn-confirm.btn-warning:hover {
    background: #c05621;
}

.notify-modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.notify-modal-icon.danger {
    background: #fed7d7;
    color: #c53030;
}

.notify-modal-icon.warning {
    background: #feebc8;
    color: #c05621;
}

.notify-modal-icon.info {
    background: #bee3f8;
    color: #2b6cb0;
}

.notify-modal-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border-strong, #94a3b8);
    border-radius: 6px;
    font-size: 14px;
    margin-top: 12px;
    box-shadow: var(--input-inset-shadow, inset 0 1px 2px rgba(0, 0, 0, 0.06));
    transition: border-color 0.2s, box-shadow 0.2s;
}

.notify-modal-input:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.2);
}

.notify-modal-input.error {
    border-color: #e53e3e;
}

.notify-modal-hint {
    font-size: 12px;
    color: #718096;
    margin-top: 8px;
}

.rich-editor-min-44 { min-height: 44px; }
.rich-editor-min-48 { min-height: 48px; }
.rich-editor-min-50 { min-height: 50px; }
.rich-editor-min-60 { min-height: 60px; }
.rich-editor-min-72 { min-height: 72px; }
.rich-editor-min-96 { min-height: 96px; }
.rich-editor-min-150 { min-height: 150px; }
.rich-editor-min-180 { min-height: 180px; }
.rich-editor-min-200 { min-height: 200px; }

.analysis-lock-overlay {
    --analysis-lock-color: #0d6efd;
    --analysis-lock-progress: 0%;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-align: center;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.15s ease;
}

.analysis-lock-overlay.is-visible {
    opacity: 1;
}

.analysis-lock-content {
    background: rgba(30, 30, 30, 0.98);
    padding: 2rem 3rem;
    border-radius: 16px;
    border: 2px solid var(--analysis-lock-color);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    min-width: 360px;
    max-width: 420px;
}

.analysis-lock-content--monitor {
    border-color: rgba(245, 158, 11, 0.8);
    background: rgba(17, 24, 39, 0.98);
}

.analysis-lock-content h4 {
    margin: 0 0 0.25rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.analysis-lock-run-name {
    margin: 0 0 1rem;
    font-size: 0.95rem;
    color: var(--analysis-lock-color);
}

.analysis-lock-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--analysis-lock-color);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: analysisLockSpin 1s linear infinite;
}

.analysis-lock-monitor-icon {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.14);
    border: 1px solid rgba(245, 158, 11, 0.35);
    font-size: 1.45rem;
}

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

.analysis-lock-percent {
    font-size: 3rem;
    font-weight: 700;
    color: var(--analysis-lock-color);
    margin: 0;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.analysis-lock-progress {
    width: 100%;
    height: 14px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 7px;
    margin: 0.75rem 0 1rem;
    overflow: hidden;
}

.analysis-lock-progress-bar {
    height: 100%;
    width: var(--analysis-lock-progress);
    background: var(--analysis-lock-color);
    border-radius: 7px;
    transition: width 0.3s ease;
}

.analysis-lock-phase {
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    margin: 0 0 0.25rem;
}

.analysis-lock-status {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 1rem;
    max-width: 350px;
    word-break: break-word;
    min-height: 1.2em;
    font-family: monospace;
}

.analysis-lock-warning {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 0 0 1.25rem;
}

.analysis-lock-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.analysis-lock-cancel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.analysis-lock-cancel-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.analysis-lock-cancel-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
    color: #f87171;
}

.analysis-lock-cancel-btn:active {
    background: rgba(239, 68, 68, 0.3);
}

.analysis-lock-hidden {
    display: none !important;
}

.analysis-lock-btn-spinner {
    width: 0.9rem;
    height: 0.9rem;
    border: 2px solid rgba(248, 113, 113, 0.25);
    border-top-color: #f87171;
    border-radius: 50%;
    animation: analysisLockSpin 0.8s linear infinite;
}

/* =========================================================================
   Step-up password confirmation modal (inline; built by utils.js) + busy spinner
   ========================================================================= */
.stepup-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4, 16px);
    background: var(--overlay-scrim, rgba(15, 23, 42, 0.5));
    animation: stepupOverlayIn 120ms ease-out;
}

.stepup-modal {
    width: 100%;
    max-width: 420px;
    background: var(--surface-panel, #ffffff);
    border: 1px solid var(--border-default, #e2e8f0);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 24px 60px var(--shadow-slate-18, rgba(15, 23, 42, 0.18));
    padding: var(--space-6, 24px);
    font-family: var(--font-sans);
    color: var(--text-default, #1e293b);
    animation: stepupModalIn 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.stepup-modal-title {
    margin: 0 0 var(--space-2, 8px);
    font-size: var(--font-size-lg, 1.125rem);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-strong, #0f172a);
}

.stepup-modal-desc {
    margin: 0 0 var(--space-4, 16px);
    font-size: var(--font-size-sm, 0.875rem);
    line-height: var(--line-height-body, 1.5);
    color: var(--text-muted, #64748b);
}

.stepup-modal-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-2, 8px);
}

.stepup-modal-label {
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: var(--font-weight-medium, 500);
    color: var(--text-default, #1e293b);
}

.stepup-modal-input {
    width: 100%;
    padding: 10px 12px;
    font-size: var(--font-size-base, 1rem);
    font-family: inherit;
    color: var(--text-strong, #0f172a);
    background: var(--gray-0, #ffffff);
    border: 1.5px solid var(--gray-400, #94a3b8);
    border-radius: var(--radius-md, 8px);
    box-shadow: inset 0 1px 2px var(--shadow-neutral-05, rgba(0, 0, 0, 0.05));
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.stepup-modal-input:focus {
    outline: none;
    border-color: var(--brand-primary, var(--brand-primary, #1a9c8d));
    box-shadow: 0 0 0 3px rgba(61, 161, 184, 0.18);
}

.stepup-modal-error {
    min-height: 1.1em;
    margin: 0;
    font-size: var(--font-size-sm, 0.875rem);
    color: var(--danger-600, #dc2626);
}

.stepup-modal-error:empty {
    min-height: 0;
}

.stepup-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2, 8px);
    margin-top: var(--space-3, 12px);
}

.stepup-modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: var(--font-weight-semibold, 600);
    font-family: inherit;
    border-radius: var(--radius-md, 8px);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.stepup-modal-btn:disabled {
    opacity: 0.65;
    cursor: default;
}

.stepup-modal-btn--ghost {
    background: var(--surface-panel, #ffffff);
    border-color: var(--border-strong, #cbd5e1);
    color: var(--text-default, #334155);
}

.stepup-modal-btn--ghost:hover:not(:disabled) {
    background: var(--surface-hover, #f1f5f9);
}

.stepup-modal-btn--primary {
    background: var(--brand-primary, var(--brand-primary, #1a9c8d));
    border-color: var(--brand-primary, var(--brand-primary, #1a9c8d));
    color: #ffffff;
}

.stepup-modal-btn--primary:hover:not(:disabled) {
    background: var(--brand-primary-deep, #0f6158);
    border-color: var(--brand-primary-deep, #0f6158);
}

/* Inline spinner reused by busy buttons (recovery restore, etc.) */
.stepup-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    vertical-align: -2px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: stepupSpin 600ms linear infinite;
}

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

@keyframes stepupOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes stepupModalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .stepup-modal-overlay,
    .stepup-modal { animation: none; }
    .stepup-spinner { animation-duration: 1200ms; }
}
.page-navigation-feedback {
    position: fixed;
    top: calc(var(--header-height, 64px) + 0.75rem);
    left: 50%;
    z-index: 1100;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    max-width: calc(100vw - 2rem);
    padding: 0.6rem 0.9rem;
    color: var(--text-default, #111827);
    background: var(--surface-panel, #fff);
    border: 1px solid var(--border-default, #d1d5db);
    border-radius: 999px;
    box-shadow: var(--elevation-lg, 0 10px 25px rgba(15, 23, 42, 0.18));
    font-size: 0.875rem;
    font-weight: 600;
    pointer-events: none;
    transform: translateX(-50%);
}

.page-navigation-feedback[hidden] {
    display: none;
}

.page-navigation-feedback .spinner-border {
    width: 1rem;
    height: 1rem;
    color: var(--brand-primary, #0f766e);
}
