/* HR-style alert/confirm modals and busy overlay */

body.vs-modal-open {
    overflow: hidden;
}

.vs-modal-root {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
    color: var(--vs-text);
}

/* Global alert/confirm hosts must stack above page-level workflow modals (z-index 3000).
   Keep child backdrop/dialog z-index values unchanged so the dialog stays above its own backdrop. */
.vs-modal-root.vs-portal-dialog {
    z-index: 5200;
}

.vs-modal-root .vs-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2995;
    background: var(--vs-modal-backdrop);
    animation: vs-modal-backdrop-in 0.15s ease-out;
}

.vs-modal-dialog {
    position: relative;
    z-index: 3000;
    width: 100%;
    max-width: 500px;
    margin: 1.75rem auto;
    pointer-events: none;
    animation: vs-modal-dialog-in 0.3s ease-out;
}

.vs-modal-dialog-wide {
    max-width: 860px;
}

.vs-modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: var(--vs-bg-card);
    color: var(--vs-text);
    border: 1px solid var(--vs-border);
    border-radius: 0.5rem;
    box-shadow: var(--vs-shadow-lg);
    outline: 0;
}

.vs-modal-header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--vs-bg-secondary);
    border-bottom: 1px solid var(--vs-border);
    border-top: 3px solid var(--vs-accent);
    border-top-left-radius: calc(0.5rem - 1px);
    border-top-right-radius: calc(0.5rem - 1px);
}

.vs-modal-header.vs-modal-success {
    background: var(--vs-modal-success-bg);
    border-bottom-color: var(--vs-modal-success-border);
    border-top-color: var(--vs-success);
}

.vs-modal-header.vs-modal-error {
    background: var(--vs-modal-error-bg);
    border-bottom-color: var(--vs-modal-error-border);
    border-top-color: var(--vs-danger);
}

.vs-modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.vs-modal-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--vs-text);
}

.vs-modal-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
}

.vs-modal-success .vs-modal-icon {
    background: var(--vs-modal-icon-success-bg);
    color: var(--vs-success);
}

.vs-modal-error .vs-modal-icon {
    background: var(--vs-modal-icon-error-bg);
    color: var(--vs-danger);
}

.vs-modal-header.vs-modal-confirm {
    background: color-mix(in srgb, var(--vs-accent) 8%, var(--vs-bg-secondary));
    border-bottom-color: var(--vs-border);
    border-top-color: var(--vs-accent);
}

.vs-modal-confirm .vs-modal-icon {
    background: color-mix(in srgb, var(--vs-accent) 14%, transparent);
    color: var(--vs-accent);
}

.vs-modal-footer--split {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
}

.vs-modal-close {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    margin: -0.25rem -0.25rem -0.25rem 0;
    border: none;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--vs-text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.vs-modal-close:hover {
    opacity: 1;
    color: var(--vs-text);
    background: var(--vs-accent-soft);
}

.vs-modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1.25rem;
    background: var(--vs-bg-card);
}

.vs-modal-body p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--vs-text-muted);
}

.vs-modal-footer {
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--vs-bg-secondary);
    border-top: 1px solid var(--vs-border);
    border-bottom-right-radius: calc(0.5rem - 1px);
    border-bottom-left-radius: calc(0.5rem - 1px);
}

.vs-modal-footer .vs-btn {
    min-width: 5.5rem;
    justify-content: center;
}

@keyframes vs-modal-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes vs-modal-dialog-in {
    from {
        opacity: 0;
        transform: translateY(-1.5rem) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.vs-busy-overlay {
    position: fixed;
    inset: 0;
    z-index: 3100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--vs-modal-backdrop);
}

.vs-busy-overlay-card {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    background: var(--vs-bg-card);
    border: 1px solid var(--vs-border);
    border-radius: 12px;
    box-shadow: var(--vs-shadow-lg);
    padding: 0.85rem 1rem;
    color: var(--vs-text);
    font-weight: 600;
}

.vs-busy-spinner {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--vs-accent) 28%, #ffffff);
    border-top-color: var(--vs-accent);
    animation: vs-busy-spin 0.8s linear infinite;
}

@keyframes vs-busy-spin {
    to { transform: rotate(360deg); }
}
