/*
 * SweetAlert2 (v11) skin for the Utility ERP.
 *
 * Load after sweetalert2.min.css (and after theme.css on app pages). Colours come
 * from the theme.css tokens when present and fall back to the same values, so
 * standalone pages (login, 2FA, map editor) look the same without theme.css.
 *
 * Works with every way pages call Swal.fire: default buttons, buttonsStyling:false
 * with "btn btn-primary", and the legacy confirmButtonColor/cancelButtonColor
 * (inline colours are overridden so every dialog uses the brand colours).
 */

.swal2-container {
    --sw-font: var(--ui-font, "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
    --sw-surface: var(--ui-surface, #ffffff);
    --sw-surface-2: var(--ui-surface-2, #f0f4f1);
    --sw-border: var(--ui-border, #e1e8e3);
    --sw-border-strong: var(--ui-border-strong, #cdd7d0);
    --sw-text: var(--ui-text, #16201b);
    --sw-text-2: var(--ui-text-2, #4a5a51);
    --sw-text-3: var(--ui-text-3, #76877d);
    --sw-brand: var(--ui-brand, #0e7a4b);
    --sw-brand-hover: var(--ui-brand-hover, #0a6840);
    --sw-brand-soft: var(--ui-brand-soft, #e2f3e9);
    --sw-ring: var(--ui-ring, rgba(14, 122, 75, .25));
    --sw-danger: var(--ui-danger, #c0352a);
    --sw-danger-soft: var(--ui-danger-soft, #fdeceb);
    --sw-warn: var(--ui-warn, #a8530a);
    --sw-warn-soft: var(--ui-warn-soft, #fdf1df);
    --sw-info: var(--ui-info, #1f68ad);
    --sw-info-soft: var(--ui-info-soft, #e7f0fa);
    --sw-radius: 16px;
    --sw-control-radius: 10px;
}

/* ------------------------------------------------------------- backdrop */
.swal2-container.swal2-backdrop-show,
.swal2-container.swal2-noanimation {
    background: rgba(12, 22, 17, .42);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

/* ---------------------------------------------------------------- popup */
.swal2-popup:not(.swal2-toast) {
    width: 25rem;
    max-width: calc(100vw - 2rem);
    padding: 1.75rem 1.5rem 1.5rem;
    border: 1px solid var(--sw-border);
    border-radius: var(--sw-radius);
    background: var(--sw-surface);
    color: var(--sw-text);
    font-family: var(--sw-font);
    box-shadow: 0 24px 64px -12px rgba(16, 32, 24, .28), 0 2px 6px rgba(16, 32, 24, .06);
}

.swal2-popup.swal2-show:not(.swal2-toast) { animation: sw-in .2s cubic-bezier(.16, 1, .3, 1); }
.swal2-popup.swal2-hide:not(.swal2-toast) { animation: sw-out .12s ease-in forwards; }

@keyframes sw-in {
    from { opacity: 0; transform: translateY(8px) scale(.97); }
    to { opacity: 1; transform: none; }
}

@keyframes sw-out {
    to { opacity: 0; transform: scale(.98); }
}

/* ----------------------------------------------------------------- icon */
/* The stock icons (big outlined circles drawn from CSS lines) are replaced by
   one glyph in a soft tinted circle. The glyph is an SVG mask in currentColor. */
.swal2-popup:not(.swal2-toast) .swal2-icon {
    position: relative;
    box-sizing: border-box;
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1.125rem;
    border: 0 !important;
    border-radius: 50%;
    background: var(--sw-tint, var(--sw-surface-2));
    color: var(--sw-tone, var(--sw-text-2));
    box-shadow: 0 0 0 6px var(--sw-halo, transparent);
    animation: none !important;
}

.swal2-popup:not(.swal2-toast) .swal2-icon > * { display: none !important; }

.swal2-popup:not(.swal2-toast) .swal2-icon::before {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 1.5rem;
    height: 1.5rem;
    background: currentColor;
    -webkit-mask: var(--sw-glyph) center / contain no-repeat;
    mask: var(--sw-glyph) center / contain no-repeat;
}

.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-icon-show { animation: sw-icon .32s cubic-bezier(.34, 1.56, .64, 1) !important; }

@keyframes sw-icon {
    from { transform: scale(.6); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.swal2-icon.swal2-success {
    --sw-tone: var(--sw-brand);
    --sw-tint: var(--sw-brand-soft);
    --sw-halo: rgba(14, 122, 75, .07);
    --sw-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

.swal2-icon.swal2-error {
    --sw-tone: var(--sw-danger);
    --sw-tint: var(--sw-danger-soft);
    --sw-halo: rgba(192, 53, 42, .06);
    --sw-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
}

.swal2-icon.swal2-warning {
    --sw-tone: var(--sw-warn);
    --sw-tint: var(--sw-warn-soft);
    --sw-halo: rgba(168, 83, 10, .06);
    --sw-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E");
}

.swal2-icon.swal2-info {
    --sw-tone: var(--sw-info);
    --sw-tint: var(--sw-info-soft);
    --sw-halo: rgba(31, 104, 173, .06);
    --sw-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 10.5v7.5M12 6h.01'/%3E%3C/svg%3E");
}

.swal2-icon.swal2-question {
    --sw-tone: var(--sw-info);
    --sw-tint: var(--sw-info-soft);
    --sw-halo: rgba(31, 104, 173, .06);
    --sw-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8.6 8.6a3.5 3.5 0 0 1 6.8 1.2c0 2.3-3.4 3.3-3.4 3.3M12 18h.01'/%3E%3C/svg%3E");
}

/* ----------------------------------------------------------------- text */
.swal2-popup:not(.swal2-toast) .swal2-title {
    margin: 0;
    padding: 0;
    color: var(--sw-text);
    font-size: 1.125rem;
    font-weight: 650;
    line-height: 1.35;
    letter-spacing: -.01em;
}

.swal2-popup:not(.swal2-toast) .swal2-html-container {
    margin: .5rem 0 0;
    padding: 0;
    color: var(--sw-text-2);
    font-size: .9375rem;
    font-weight: 400;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

/* a dialog with only a message (no title): give the message the title's weight */
.swal2-popup:not(.swal2-toast) .swal2-title[style*="display: none"] + .swal2-html-container,
.swal2-popup:not(.swal2-toast) .swal2-title:empty + .swal2-html-container {
    margin-top: 0;
    color: var(--sw-text);
    font-size: 1rem;
    font-weight: 500;
}

.swal2-popup:not(.swal2-toast) .swal2-footer {
    margin: 1.25rem -1.5rem -.25rem;
    padding: 1rem 1.5rem 0;
    border-top: 1px solid var(--sw-border);
    color: var(--sw-text-3);
    font-size: .8125rem;
}

.swal2-popup .swal2-image { margin: 0 auto 1rem; border-radius: var(--sw-control-radius); }

/* -------------------------------------------------------------- actions */
.swal2-popup:not(.swal2-toast) .swal2-actions {
    width: 100%;
    margin: 1.5rem 0 0;
    padding: 0;
    gap: .625rem;
    flex-wrap: wrap;
    justify-content: stretch;
}

/* cancel on the left, the action on the right */
.swal2-actions .swal2-loader { order: 0; }
.swal2-actions .swal2-cancel { order: 1; }
.swal2-actions .swal2-deny { order: 2; }
.swal2-actions .swal2-confirm { order: 3; }

.swal2-popup:not(.swal2-toast) .swal2-actions > button {
    -webkit-appearance: none;
    appearance: none;
    flex: 1 1 7.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    width: auto;
    height: 2.625rem;
    margin: 0 !important;
    padding: 0 1rem !important;
    border: 1px solid transparent !important;
    border-radius: var(--sw-control-radius) !important;
    font-family: var(--sw-font) !important;
    font-size: .9rem !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    box-shadow: none !important;
    cursor: pointer;
    transform: none !important;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease;
}

.swal2-popup .swal2-actions > button.swal2-confirm {
    background: var(--sw-brand) !important;
    color: #fff !important;
}

.swal2-popup .swal2-actions > button.swal2-confirm:hover:not(:disabled) { background: var(--sw-brand-hover) !important; }

.swal2-popup .swal2-actions > button.swal2-deny {
    background: var(--sw-danger-soft) !important;
    border-color: transparent !important;
    color: var(--sw-danger) !important;
}

.swal2-popup .swal2-actions > button.swal2-deny:hover:not(:disabled) { background: #fadad7 !important; }

.swal2-popup .swal2-actions > button.swal2-cancel {
    background: var(--sw-surface) !important;
    border-color: var(--sw-border-strong) !important;
    color: var(--sw-text) !important;
}

.swal2-popup .swal2-actions > button.swal2-cancel:hover:not(:disabled) { background: var(--sw-surface-2) !important; }

.swal2-popup .swal2-actions > button:focus { outline: 0; }
.swal2-popup .swal2-actions > button:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--sw-ring) !important; }
.swal2-popup .swal2-actions > button.swal2-deny:focus-visible { box-shadow: 0 0 0 3px rgba(192, 53, 42, .25) !important; }
.swal2-popup .swal2-actions > button:disabled { opacity: .6; cursor: progress; }

.swal2-popup .swal2-loader {
    width: 1.75rem;
    height: 1.75rem;
    border-width: .2rem;
    border-color: var(--sw-brand) transparent var(--sw-brand) transparent;
}

/* --------------------------------------------------------------- inputs */
.swal2-popup .swal2-input,
.swal2-popup .swal2-textarea,
.swal2-popup .swal2-select,
.swal2-popup .swal2-file {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin: 1rem 0 0;
    padding: .55rem .75rem;
    border: 1px solid var(--sw-border-strong);
    border-radius: var(--sw-control-radius);
    background: var(--sw-surface);
    color: var(--sw-text);
    font-family: var(--sw-font);
    font-size: .9375rem;
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.swal2-popup .swal2-input { height: 2.625rem; }
.swal2-popup .swal2-textarea { min-height: 6.5rem; resize: vertical; }
.swal2-popup .swal2-input::placeholder,
.swal2-popup .swal2-textarea::placeholder { color: var(--sw-text-3); }

.swal2-popup .swal2-input:focus,
.swal2-popup .swal2-textarea:focus,
.swal2-popup .swal2-select:focus {
    border-color: var(--sw-brand);
    outline: 0;
    box-shadow: 0 0 0 3px var(--sw-ring);
}

.swal2-popup .swal2-input.swal2-inputerror,
.swal2-popup .swal2-textarea.swal2-inputerror {
    border-color: var(--sw-danger) !important;
    box-shadow: 0 0 0 3px rgba(192, 53, 42, .15) !important;
}

.swal2-popup .swal2-input-label { margin: 1rem 0 0; color: var(--sw-text); font-size: .875rem; font-weight: 600; justify-content: flex-start; }

.swal2-popup .swal2-validation-message {
    margin: .75rem 0 0;
    padding: .55rem .75rem;
    border-radius: var(--sw-control-radius);
    background: var(--sw-danger-soft);
    color: var(--sw-danger);
    font-size: .8125rem;
    font-weight: 500;
    justify-content: flex-start;
}

.swal2-popup .swal2-validation-message::before {
    width: 1.1rem;
    min-width: 1.1rem;
    height: 1.1rem;
    margin: 0 .5rem 0 0;
    background-color: var(--sw-danger);
    font-size: .75rem;
    line-height: 1.1rem;
}

/* ---------------------------------------------------- close + progress */
.swal2-popup .swal2-close {
    width: 2rem;
    height: 2rem;
    margin: -.75rem -.5rem 0 0;
    border-radius: 8px;
    color: var(--sw-text-3);
    font-size: 1.5rem;
    transition: background-color .15s ease, color .15s ease;
}

.swal2-popup .swal2-close:hover { background: var(--sw-surface-2); color: var(--sw-text); }
.swal2-popup .swal2-close:focus-visible { box-shadow: 0 0 0 3px var(--sw-ring); }

.swal2-popup .swal2-timer-progress-bar-container { border-radius: 0 0 var(--sw-radius) var(--sw-radius); }
.swal2-popup .swal2-timer-progress-bar { height: 3px; background: var(--sw-brand); opacity: .55; }

/* ---------------------------------------------------------------- small */
@media (max-width: 480px) {
    .swal2-popup:not(.swal2-toast) { padding: 1.5rem 1.25rem 1.25rem; }
    .swal2-popup:not(.swal2-toast) .swal2-footer { margin-left: -1.25rem; margin-right: -1.25rem; padding-left: 1.25rem; padding-right: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
    .swal2-popup.swal2-show:not(.swal2-toast),
    .swal2-popup.swal2-hide:not(.swal2-toast),
    .swal2-popup:not(.swal2-toast) .swal2-icon.swal2-icon-show { animation: none !important; }
}
