/* SmartPOS Hub — confirmation dialogs (SweetAlert 2.x `swal()`) + Bootstrap 3 modals, global restyle (2026-10-24).
   Docs: _context/38-DIALOGS-MODALS.md. Loaded after smartpos-ui.css from layouts/partials/css.blade.php, so every layout
   that includes that partial gets it (app, auth, auth2, install, restaurant, POS V1, POS V2, Super Admin).
   CSS only — no markup or JS changes; swal() behaviour (promises, buttons, dangerMode, content, closeOnClickOutside) untouched.
   Tokens: --spu-* (22-GLOBAL-UI). Owner rule: rectangular buttons (6px radius), never pill/circle. RTL via logical properties.

   Specificity:
   - swal: vendor CSS is injected at runtime (style tag) and copied again in layouts/partials/extracss — both come after this
     file, so swal rules use two classes (.swal-overlay .swal-…) to win.
   - modals: single-class selectors (same weight as vendor/bootstrap), so module CSS that styles its own modal
     (.spcf, .pv2, .ops-modal, html.spv1 #…, .scb-modal …) keeps winning. */

/* =============================================================== 1. SweetAlert confirm / alert dialogs */
.swal-overlay {
    display: flex; align-items: flex-start; justify-content: center; padding: 16px;
    background-color: rgba(16, 24, 40, .5);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    transition: opacity .18s ease-out;
}
.swal-overlay::before { display: none !important; }
.swal-overlay .swal-modal {
    width: min(440px, 100%); margin: auto; /* auto margins centre it and never clip a tall dialog */
    padding: 0; font-size: 14px; text-align: start; color: var(--spu-text, #344054);
    background: var(--spu-surface, #fff); border: 0; border-radius: var(--spu-radius-lg, 12px);
    box-shadow: 0 24px 48px -12px rgba(16, 24, 40, .28), 0 4px 10px -4px rgba(16, 24, 40, .08);
    transform: none; transition: opacity .15s ease-out;
}
.swal-overlay.swal-overlay--show-modal .swal-modal { animation: spdlg-in .2s cubic-bezier(.2, .8, .2, 1); }
@keyframes spdlg-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

/* icon: tinted rounded-square badge with a line icon (replaces the big outlined vendor circles) */
.swal-overlay .swal-icon { --spdlg-c: var(--spu-warning, #d97706); --spdlg-bg: #fef0c7; --spdlg-ring: #fffaeb; } /* per-type colours below (same weight, later) */
.swal-overlay .swal-icon:not(.swal-icon--custom) {
    width: 48px; height: 48px; padding: 0; margin: 24px 24px 16px; margin-inline-end: auto;
    display: flex; align-items: center; justify-content: center; box-sizing: border-box;
    border: 0; border-radius: 10px; background: var(--spdlg-bg); color: var(--spdlg-c);
    box-shadow: 0 0 0 6px var(--spdlg-ring); animation: none; position: relative;
}
.swal-overlay .swal-icon:not(.swal-icon--custom) > * { display: none !important; }
.swal-overlay .swal-icon:not(.swal-icon--custom)::after { content: none !important; display: none !important; }
.swal-overlay .swal-icon:not(.swal-icon--custom)::before {
    content: "" !important; display: block; position: static; inset: auto; margin: 0; padding: 0;
    width: 24px; height: 24px; border: 0; border-radius: 0; transform: none; animation: none;
    background: currentColor;
    -webkit-mask: var(--spdlg-svg) center / 24px 24px no-repeat; mask: var(--spdlg-svg) center / 24px 24px no-repeat;
}
.swal-overlay .swal-icon--warning {
    --spdlg-svg: 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' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
}
.swal-overlay .swal-icon--error {
    --spdlg-c: var(--spu-danger, #dc2626); --spdlg-bg: #fee4e2; --spdlg-ring: #fef3f2;
    --spdlg-svg: 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' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='m15 9-6 6M9 9l6 6'/%3E%3C/svg%3E");
}
.swal-overlay .swal-icon--success {
    --spdlg-c: var(--spu-success, #059669); --spdlg-bg: #d1fadf; --spdlg-ring: #ecfdf3;
    --spdlg-svg: 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' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='m8 12.5 2.5 2.5L16 9.5'/%3E%3C/svg%3E");
}
.swal-overlay .swal-icon--info {
    --spdlg-c: var(--spu-info, #0284c7); --spdlg-bg: #e0f2fe; --spdlg-ring: #f0f9ff;
    --spdlg-svg: 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' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M12 16v-4.5M12 8h.01'/%3E%3C/svg%3E");
}
/* destructive confirm (dangerMode → .swal-button--danger): the warning badge turns red */
.swal-overlay .swal-modal:has(.swal-button--danger) .swal-icon--warning { --spdlg-c: var(--spu-danger, #dc2626); --spdlg-bg: #fee4e2; --spdlg-ring: #fef3f2; }
.swal-overlay .swal-icon--custom { margin: 24px 24px 12px; margin-inline-end: auto; max-width: calc(100% - 48px); }
.swal-overlay .swal-icon--custom img { max-height: 96px; border-radius: var(--spu-radius-md, 8px); }

/* text */
.swal-overlay .swal-title {
    display: block; margin: 0; padding: 0 24px; font-size: 18px; font-weight: 600; line-height: 1.45;
    color: var(--spu-ink, #101828); text-align: start; text-transform: none; overflow-wrap: anywhere;
}
.swal-overlay .swal-title:first-child { margin-top: 24px; }
.swal-overlay .swal-title:not(:last-child) { margin-bottom: 6px; padding-bottom: 0; }
.swal-overlay .swal-text {
    display: block; float: none; max-width: none; margin: 0; padding: 0 24px; box-sizing: border-box;
    font-size: 14px; line-height: 1.55; font-weight: 400; color: var(--spu-muted, #667085); text-align: start; overflow-wrap: anywhere;
}
.swal-overlay .swal-text:first-child { margin-top: 24px; font-size: 15px; color: var(--spu-text, #344054); }
.swal-overlay .swal-text:last-child { margin-bottom: 24px; }
.swal-overlay .swal-title:last-child { margin-bottom: 24px; }

/* content (content: 'input' / element) */
.swal-overlay .swal-content { margin: 16px 0 0; padding: 0 24px; font-size: 14px; text-align: start; }
.swal-overlay .swal-content:last-child { margin-bottom: 24px; }
.swal-overlay .swal-content__input, .swal-overlay .swal-content__textarea,
.swal-overlay .swal-content input:not([type="checkbox"]):not([type="radio"]), .swal-overlay .swal-content select, .swal-overlay .swal-content textarea {
    display: block; width: 100%; min-height: 40px; padding: 8px 12px; box-sizing: border-box;
    font-size: 14px; line-height: 1.4; color: var(--spu-ink, #101828); background: var(--spu-surface, #fff);
    border: 1px solid var(--spu-line-strong, #d0d5dd); border-radius: var(--spu-radius, 6px); box-shadow: var(--spu-shadow-xs);
    transition: border-color .15s, box-shadow .15s;
}
.swal-overlay .swal-content__textarea, .swal-overlay .swal-content textarea { min-height: 88px; resize: vertical; }
.swal-overlay .swal-content__input:focus, .swal-overlay .swal-content__textarea:focus,
.swal-overlay .swal-content input:focus, .swal-overlay .swal-content select:focus, .swal-overlay .swal-content textarea:focus {
    outline: none; border-color: var(--spu-primary, #2742D8);
    box-shadow: 0 0 0 3px var(--spu-primary-soft-2, rgba(39, 66, 216, .16));
}

/* footer + buttons: right-aligned (end), Cancel = secondary, confirm = primary, dangerMode = red */
.swal-overlay .swal-footer {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px;
    margin: 24px 0 0; padding: 0 24px 24px; border: 0; background: none; text-align: end;
}
.swal-overlay .swal-button-container { margin: 0; display: inline-flex; position: relative; }
.swal-overlay .swal-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; min-width: 88px; margin: 0; padding: 0 18px;
    font-size: 14px; font-weight: 600; line-height: 1.2; letter-spacing: 0; text-transform: none;
    color: var(--spu-on-primary, #fff); background-color: var(--spu-primary, #2742D8); border: 1px solid transparent;
    border-radius: var(--spu-radius, 6px); box-shadow: var(--spu-shadow-xs); cursor: pointer;
    transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.swal-overlay .swal-button:not([disabled]):hover { background-color: var(--spu-primary-hover, #1e34b4); }
.swal-overlay .swal-button:not([disabled]):active { background-color: var(--spu-primary-active, #1a2d9c); }
.swal-overlay .swal-button:focus { outline: none; box-shadow: var(--spu-shadow-xs); }
.swal-overlay .swal-button:focus-visible { outline: 2px solid var(--spu-ring, rgba(39, 66, 216, .4)); outline-offset: 2px; }
.swal-overlay .swal-button--cancel {
    color: var(--spu-text, #344054); background-color: var(--spu-surface, #fff); border-color: var(--spu-line-strong, #d0d5dd);
}
.swal-overlay .swal-button--cancel:not([disabled]):hover { background-color: var(--spu-surface-2, #f9fafb); color: var(--spu-ink, #101828); }
.swal-overlay .swal-button--cancel:not([disabled]):active { background-color: #f2f4f7; }
.swal-overlay .swal-button--danger { color: #fff; background-color: var(--spu-danger, #dc2626); border-color: transparent; }
.swal-overlay .swal-button--danger:not([disabled]):hover { background-color: #b91c1c; }
.swal-overlay .swal-button--danger:not([disabled]):active { background-color: #991b1b; }
.swal-overlay .swal-button--danger:focus-visible { outline-color: rgba(220, 38, 38, .45); }
/* extra custom buttons (buttons: { draft: {...} }) = brand outline, so only the confirm button is solid */
.swal-overlay .swal-button:not(.swal-button--confirm):not(.swal-button--cancel):not(.swal-button--danger) {
    color: var(--spu-primary-text, var(--spu-primary, #2742D8)); background-color: var(--spu-surface, #fff); border-color: var(--spu-primary-line, rgba(39, 66, 216, .35));
}
.swal-overlay .swal-button:not(.swal-button--confirm):not(.swal-button--cancel):not(.swal-button--danger):not([disabled]):hover {
    background-color: var(--spu-primary-soft, rgba(39, 66, 216, .09));
}
.swal-overlay .swal-button[disabled] { opacity: .55; cursor: not-allowed; }
.swal-overlay .swal-button--loading { color: transparent !important; }
.swal-overlay .swal-button__loader div { border-radius: 2px; }

/* phones: centred, full-width stacked buttons (primary on top) */
@media (max-width: 480px) {
    .swal-overlay { padding: 12px; align-items: flex-end; }
    .swal-overlay .swal-modal { width: 100%; margin: auto 0 0; text-align: center; }
    .swal-overlay .swal-icon:not(.swal-icon--custom), .swal-overlay .swal-icon--custom { margin-inline: auto; }
    .swal-overlay .swal-title, .swal-overlay .swal-text { text-align: center; padding-inline: 20px; }
    .swal-overlay .swal-content { padding-inline: 20px; }
    .swal-overlay .swal-footer { flex-direction: column-reverse; align-items: stretch; gap: 10px; padding: 0 20px 20px; margin-top: 20px; }
    .swal-overlay .swal-button-container, .swal-overlay .swal-button { width: 100%; }
    .swal-overlay .swal-button { min-height: 44px; }
    .swal-overlay.swal-overlay--show-modal .swal-modal { animation-name: spdlg-up; }
    @keyframes spdlg-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
    .swal-overlay, .swal-overlay .swal-modal { transition: none; }
    .swal-overlay.swal-overlay--show-modal .swal-modal { animation: none; }
}

/* =============================================================== 2. Bootstrap 3 modals (core + module AJAX modals) */
.modal-backdrop { background-color: #101828; }
.modal-backdrop.in { opacity: .5; }
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .modal-backdrop.in { -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
}
.modal-content {
    border: 0; border-radius: var(--spu-radius-lg, 12px); overflow: visible; background-clip: padding-box;
    box-shadow: 0 24px 48px -12px rgba(16, 24, 40, .28), 0 4px 10px -4px rgba(16, 24, 40, .08);
}
/* entrance: short rise instead of the 25% drop (same selectors/weight as Bootstrap; POS V2 and the POS V1 phone sheet override with stronger selectors) */
.modal.fade .modal-dialog { transform: translate(0, -14px) scale(.985); transition: transform .2s cubic-bezier(.2, .8, .2, 1); }
.modal.in .modal-dialog { transform: translate(0, 0); }

/* header: title column + square ghost close button; sticky so Close stays reachable in long modals */
.modal-header {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: center;
    position: sticky; top: 0; z-index: 5; min-height: 64px; padding: 14px 16px 14px 20px; padding-inline: 20px 14px;
    background: var(--spu-surface, #fff); border-bottom: 1px solid var(--spu-line, #e4e7ec);
    border-radius: var(--spu-radius-lg, 12px) var(--spu-radius-lg, 12px) 0 0;
}
.modal-header::before, .modal-header::after { content: none; display: none; }
.modal-header > * { grid-column: 1; min-width: 0; }
.modal-header > .close { grid-column: 2; grid-row: 1; align-self: start; }
.modal-header .modal-title, .modal-header > h3, .modal-header > h4 {
    margin: 0; font-size: 18px; font-weight: 700; line-height: 1.35; color: var(--spu-ink, #101828); overflow-wrap: anywhere;
}
.modal-header > p, .modal-header > small, .modal-header .modal-title small { margin: 2px 0 0; font-size: 13px; font-weight: 400; color: var(--spu-muted, #667085); }
.modal-header > .close, .modal-header .close {
    float: none; margin: 0; padding: 0; width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 400; line-height: 1; color: var(--spu-ink, #101828); text-shadow: none; opacity: .65;
    background: transparent; border: 1px solid transparent; border-radius: var(--spu-radius, 6px);
    transition: background-color .15s, opacity .15s, border-color .15s;
}
.modal-header .close:hover { opacity: 1; background: #f2f4f7; border-color: var(--spu-line, #e4e7ec); }
.modal-header .close:focus { outline: none; }
.modal-header .close:focus-visible { opacity: 1; outline: 2px solid var(--spu-ring, rgba(39, 66, 216, .4)); outline-offset: 2px; }
.modal-header .close > span { display: block; line-height: 1; transform: translateY(-1px); }

/* body */
.modal-body { padding: 20px; }

/* footer: Cancel/Close at the start, actions at the end (contact-form pattern); sticky so it is always reachable */
.modal-footer {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px;
    position: sticky; bottom: 0; z-index: 5; padding: 12px 20px; text-align: end;
    background: var(--spu-surface, #fff); border-top: 1px solid var(--spu-line, #e4e7ec);
    border-radius: 0 0 var(--spu-radius-lg, 12px) var(--spu-radius-lg, 12px);
    box-shadow: 0 -6px 16px -12px rgba(16, 24, 40, .22);
}
.modal-footer::before, .modal-footer::after { content: none; display: none; }
.modal-footer .btn + .btn, .modal-footer .tw-dw-btn + .tw-dw-btn, .modal-footer .btn-group .btn + .btn { margin-inline-start: 0; }
.modal-footer > .btn, .modal-footer > .tw-dw-btn, .modal-footer > a.btn { margin: 0; min-height: 40px; }
.modal-footer > [data-dismiss="modal"] { order: -1; margin-inline-end: auto; }
.modal-footer > [data-dismiss="modal"] ~ [data-dismiss="modal"] { margin-inline-end: 0; }

/* old "view" modals (sell / purchase / transfer details): green table heads + grey tables → neutral cards */
.modal-body table.bg-gray { background: var(--spu-surface, #fff) !important; color: var(--spu-text, #344054) !important; border: 1px solid var(--spu-line, #e4e7ec); border-radius: var(--spu-radius-md, 8px); border-collapse: separate; border-spacing: 0; overflow: hidden; }
.modal-body table.bg-gray > tbody > tr:nth-child(even) > td, .modal-body table.bg-gray > tr:nth-child(even) > td { background: var(--spu-surface-2, #f9fafb); }
.modal-body table.bg-gray td, .modal-body table.bg-gray th { border-top-color: var(--spu-line, #e4e7ec) !important; }
.modal-body tr.bg-green, .modal-body thead.bg-green, .modal-body th.bg-green {
    background-color: #f2f4f7 !important; color: var(--spu-muted, #475467) !important;
}
.modal-body tr.bg-green > th, .modal-body tr.bg-green > td, .modal-body thead.bg-green th {
    font-size: 12px; font-weight: 600; letter-spacing: .02em; color: #475467 !important; border-bottom: 1px solid var(--spu-line, #e4e7ec) !important;
}
.modal-body .well.bg-gray { background: var(--spu-surface-2, #f9fafb) !important; color: var(--spu-text, #344054) !important; border: 1px solid var(--spu-line, #e4e7ec); border-radius: var(--spu-radius-md, 8px); }

/* sizes */
@media (min-width: 768px) {
    .modal-sm { width: 420px; }
}
/* phones: fit the viewport, no horizontal scroll, 40px tap targets, footer pinned to the bottom of the screen */
@media (max-width: 767px) {
    .modal-dialog { margin: 8px; width: auto; max-width: calc(100vw - 16px); }
    .modal-header { min-height: 56px; padding-block: 10px; padding-inline: 16px 10px; }
    .modal-header .modal-title, .modal-header > h3, .modal-header > h4 { font-size: 16px; }
    .modal-header > .close, .modal-header .close { width: 40px; height: 40px; }
    .modal-body { padding: 16px; }
    .modal-footer { padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
    .modal-footer > .btn, .modal-footer > .tw-dw-btn, .modal-footer > a.btn { flex: 1 1 auto; min-height: 40px; }
    .modal-footer > [data-dismiss="modal"] { margin-inline-end: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .modal.fade .modal-dialog { transition: none; }
}
