/*
 * VIETDESK — global popup visual skin
 * Chỉ thay đổi bề mặt, nền phủ, viền, bóng và nút đóng.
 * Giữ nguyên layout và kích thước riêng của từng popup nghiệp vụ.
 */

body.app-body {
    --vds-popup-ink: #132238;
    --vds-popup-muted: #667993;
    --vds-popup-line: rgba(213, 225, 242, .92);
    --vds-popup-radius: 24px;
    --vds-popup-surface:
        radial-gradient(520px 220px at 12% 0%, rgba(99, 164, 255, .10), transparent 72%),
        radial-gradient(500px 220px at 90% 0%, rgba(76, 213, 219, .09), transparent 74%),
        linear-gradient(180deg, rgba(255,255,255,.97), rgba(247,250,255,.96));
    --vds-popup-shadow:
        0 38px 88px rgba(10, 24, 48, .34),
        0 12px 30px rgba(18, 45, 88, .16),
        inset 0 1px 0 rgba(255,255,255,.98);
}

/* Nền phía sau chìm xuống; chỉ blur một lớp phủ để tránh lag. */
body.app-body .modal-backdrop.show,
body.app-body .vds-global-popup-overlay,
body.app-body .swal2-container.swal2-backdrop-show,
body.app-body .vds-glass-swal-container.swal2-container,
body.app-body .dc-modal-backdrop,
body.app-body .trial-popup__backdrop,
body.app-body .promo-modal__backdrop,
body.app-body .invalid-license-overlay,
body.app-body .expired-license-overlay-v2,
body.app-body [data-vds-popup-backdrop],
body.app-body [data-vds-glass-backdrop] {
    opacity: 1 !important;
    background: rgba(18, 29, 47, .52) !important;
    backdrop-filter: blur(10px) saturate(112%) !important;
    -webkit-backdrop-filter: blur(10px) saturate(112%) !important;
}

/* Bề mặt popup dùng chung, không can thiệp kích thước hay khoảng cách. */
body.app-body .modal .modal-content,
body.app-body .vds-global-popup-card,
body.app-body .swal2-popup,
body.app-body .vds-glass-swal-popup,
body.app-body .vds-popup-card,
body.app-body .confirm-modal,
body.app-body .dc-modal,
body.app-body .trial-popup__dialog,
body.app-body .promo-modal__dialog,
body.app-body .invalid-license-dialog,
body.app-body .expired-license-dialog-v2,
body.app-body [data-vds-popup-surface],
body.app-body [data-vds-glass-surface] {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.94) !important;
    border-radius: var(--vds-popup-radius) !important;
    background: var(--vds-popup-surface) !important;
    box-shadow: var(--vds-popup-shadow) !important;
    color: var(--vds-popup-ink) !important;
}

/* Viền sáng nhẹ giúp popup tách khỏi nền mà không đổi kích thước. */
body.app-body .modal .modal-content::after,
body.app-body .vds-global-popup-card::after,
body.app-body .swal2-popup::after,
body.app-body .dc-modal::after,
body.app-body [data-vds-popup-surface]::after,
body.app-body [data-vds-glass-surface]::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(192, 213, 240, .34);
    z-index: 0;
}

body.app-body .modal .modal-content > *,
body.app-body .vds-global-popup-card > *,
body.app-body .swal2-popup > *,
body.app-body .dc-modal > *,
body.app-body [data-vds-popup-surface] > *,
body.app-body [data-vds-glass-surface] > * {
    position: relative;
    z-index: 1;
}

/* Header/footer giữ kích thước gốc, chỉ đổi nền và đường phân cách. */
body.app-body .modal .modal-header {
    background: linear-gradient(180deg, rgba(255,255,255,.54), rgba(243,248,255,.30)) !important;
    border-bottom-color: rgba(214, 226, 242, .82) !important;
}

body.app-body .modal .modal-body {
    background: transparent !important;
}

body.app-body .modal .modal-footer {
    background: rgba(248, 251, 255, .58) !important;
    border-top-color: rgba(214, 226, 242, .82) !important;
}

/* Nút đóng đồng bộ DICOM, không ép kích thước nút nghiệp vụ. */
body.app-body .modal .btn-close,
body.app-body .modal [data-bs-dismiss="modal"].btn-close,
body.app-body .vds-global-popup-close,
body.app-body .vds-glass-modal-close,
body.app-body .vds-glass-custom-close,
body.app-body .swal2-close,
body.app-body [data-vds-glass-close] {
    border: 1px solid rgba(211, 225, 243, .94) !important;
    border-radius: 14px !important;
    background-color: rgba(255,255,255,.84) !important;
    color: #40536d !important;
    box-shadow:
        0 10px 24px rgba(21, 47, 87, .12),
        inset 0 1px 0 rgba(255,255,255,.96) !important;
    opacity: 1 !important;
}

body.app-body .modal .btn-close:hover,
body.app-body .vds-global-popup-close:hover,
body.app-body .vds-glass-modal-close:hover,
body.app-body .vds-glass-custom-close:hover,
body.app-body .swal2-close:hover,
body.app-body [data-vds-glass-close]:hover {
    background-color: #fff !important;
    border-color: rgba(101, 151, 224, .50) !important;
}

body.app-body .vds-global-popup-title,
body.app-body .swal2-title,
body.app-body .modal-title {
    color: var(--vds-popup-ink) !important;
}

body.app-body .vds-global-popup-msg,
body.app-body .swal2-html-container,
body.app-body .swal2-content {
    color: var(--vds-popup-muted) !important;
}

/* Popup gói kích hoạt giữ nguyên kích thước và cơ chế tự chạy riêng. */
body.app-body .license-renew-plans-modal .modal-content {
    background:
        radial-gradient(760px 300px at 12% 0%, rgba(73, 181, 219, .11), transparent 70%),
        radial-gradient(720px 300px at 88% 0%, rgba(78, 132, 255, .10), transparent 72%),
        linear-gradient(180deg, rgba(255,255,255,.96), rgba(239,248,251,.95)) !important;
}

/* Popup nghiệp vụ như phụ thu giữ nguyên bố cục riêng. */
body.app-body #vdsSurchargeChooser .modal-content,
body.app-body .vds-business-modal .modal-content {
    background:
        radial-gradient(520px 210px at 14% 0%, rgba(94, 165, 255, .08), transparent 72%),
        linear-gradient(180deg, rgba(255,255,255,.97), rgba(247,250,255,.96)) !important;
}

body.app-body .modal.fade .modal-dialog {
    transition: transform .18s ease-out, opacity .18s ease-out !important;
}

@media (max-width: 767.98px) {
    body.app-body {
        --vds-popup-radius: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.app-body .modal.fade .modal-dialog,
    body.app-body .vds-global-popup-card,
    body.app-body .swal2-popup {
        transition: none !important;
        animation: none !important;
    }
}


/* Media gallery overlays are thumbnail hover layers, not popup backdrops.
   Never blur or darken the uploaded image permanently. */
body.app-body .xq-thumb > .xq-overlay {
    opacity: 0 !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    pointer-events: none !important;
}

body.app-body .xq-thumb:hover > .xq-overlay {
    opacity: 1 !important;
    background: rgba(0, 0, 0, .08) !important;
}

/* VDS GLOBAL POPUP LAYOUT SAFETY FIX V3
   Fix Bootstrap dialogs whose close button/title were clipped by the global
   glass surface (modal-content uses overflow:hidden). Keep component widths
   and business-specific layouts unchanged. */
body.app-body .modal .modal-header {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 14px !important;
    min-width: 0 !important;
}

body.app-body .modal .modal-header > :first-child:not(.btn-close) {
    min-width: 0 !important;
    flex: 1 1 auto !important;
}

/* Bootstrap's default negative close-button margin is unsafe when the popup
   surface clips overflow. Reset it globally so the X always stays inside. */
body.app-body .modal .modal-header > .btn-close,
body.app-body .modal .modal-header > [data-bs-dismiss="modal"].btn-close {
    position: relative !important;
    inset: auto !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    padding: 0 !important;
    background-size: 12px 12px !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    box-sizing: border-box !important;
    z-index: 3 !important;
}

body.app-body .modal .modal-title,
body.app-body .modal .modal-header h1,
body.app-body .modal .modal-header h2,
body.app-body .modal .modal-header h3,
body.app-body .modal .modal-header h4,
body.app-body .modal .modal-header h5,
body.app-body .modal .modal-header h6 {
    min-width: 0 !important;
    max-width: 100% !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
    line-height: 1.25 !important;
}

/* Common subtitle/message nodes used throughout the application. */
body.app-body .modal .modal-header [class*="subtitle"],
body.app-body .modal .modal-header [class*="description"],
body.app-body .modal .modal-header [class*="desc"],
body.app-body .modal .modal-body [class*="message"] {
    min-width: 0 !important;
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
}

/* Avoid footer actions collapsing/overlapping on narrow dialogs. */
body.app-body .modal .modal-footer {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
}

body.app-body .modal .modal-footer > .btn {
    max-width: 100%;
}

/* SweetAlert uses an absolutely positioned close control; reserve title room
   so long titles never render underneath it. */
body.app-body .swal2-popup .swal2-title {
    min-width: 0 !important;
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
}

body.app-body .swal2-popup .swal2-close {
    margin: 0 !important;
    z-index: 3 !important;
}

@media (max-width: 575.98px) {
    body.app-body .modal .modal-header {
        gap: 10px !important;
    }

    body.app-body .modal .modal-header > .btn-close,
    body.app-body .modal .modal-header > [data-bs-dismiss="modal"].btn-close {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        min-height: 34px !important;
    }

    body.app-body .modal .modal-footer > .btn {
        flex: 1 1 120px;
    }
}


/* VDS GLOBAL MODAL CLOSE SAFETY V5 */
body.app-body .modal .modal-header > .btn-close {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
    margin: 0 !important;
    flex: 0 0 36px !important;
    align-self: flex-start !important;
}

body.app-body .modal .modal-header {
    box-sizing: border-box !important;
}

body.app-body .modal .modal-header > :first-child:not(.btn-close) {
    overflow: visible !important;
}


/* VIETDESK VET GLOBAL POPUP HARDENING V6
   Source-wide guard against clipped close buttons and zero-spacing text dialogs.
   Applied after page CSS from both shared layouts. */
body .modal .modal-content {
    min-width: 0;
}

body .modal .modal-header {
    box-sizing: border-box !important;
    min-width: 0 !important;
}

body .modal .modal-header > .btn-close,
body .modal .modal-header > [data-bs-dismiss="modal"].btn-close {
    position: relative !important;
    inset: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
    margin: 0 !important;
    flex: 0 0 36px !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    align-self: flex-start !important;
    box-sizing: border-box !important;
    z-index: 5 !important;
}

body .modal .modal-header > :first-child:not(.btn-close) {
    min-width: 0 !important;
    max-width: calc(100% - 50px);
    overflow: visible !important;
}

body .modal .modal-title,
body .modal .modal-header h1,
body .modal .modal-header h2,
body .modal .modal-header h3,
body .modal .modal-header h4,
body .modal .modal-header h5,
body .modal .modal-header h6 {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    text-overflow: clip !important;
}

/* Runtime auditor adds these only when it detects effectively-zero spacing. */
body .modal-content.vds-auto-fix-header > .modal-header {
    padding: 18px 20px 12px !important;
    gap: 12px !important;
    min-height: 64px;
}

body .modal-content.vds-auto-fix-body > .modal-body {
    padding: 0 20px 16px !important;
    overflow-wrap: anywhere !important;
}

body .modal-content.vds-auto-fix-footer > .modal-footer {
    padding: 12px 20px 18px !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
}

/* If a page-level rule tries to position a Bootstrap close button outside the
   rounded card, the auditor marks the surface and this keeps it in-flow. */
body .modal-content.vds-auto-fix-close > .modal-header {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 12px !important;
}

body .modal-content.vds-auto-fix-close > .modal-header > .btn-close {
    position: relative !important;
    inset: auto !important;
    transform: none !important;
    margin: 0 !important;
}

/* Common custom popup controls used across the application. Keep absolute close
   controls inside their own surface bounds even when local CSS changes. */
body.app-body .promo-modal__close,
body.app-body .tem-print-modal-close,
body.app-body .cash-modal-close,
body.app-body .contract-choice-modal__close,
body.app-body .btn-modal-close,
body.app-body .dc-modal-close,
body.app-body .pos-employee-close,
body.app-body [class*="popup"][class*="close"],
body.app-body [class*="modal"][class*="close"] {
    box-sizing: border-box !important;
    max-width: 52px;
    max-height: 52px;
}

@media (max-width: 575.98px) {
    body .modal-content.vds-auto-fix-header > .modal-header {
        padding: 16px 16px 10px !important;
    }
    body .modal-content.vds-auto-fix-body > .modal-body {
        padding: 0 16px 14px !important;
    }
    body .modal-content.vds-auto-fix-footer > .modal-footer {
        padding: 10px 16px 16px !important;
    }
    body .modal .modal-header > .btn-close,
    body .modal .modal-header > [data-bs-dismiss="modal"].btn-close {
        flex-basis: 34px !important;
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        min-height: 34px !important;
    }
}
/* Close controls must retain a visible icon even when component backgrounds reset it. */
body .modal .btn-close {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 3l10 10M13 3L3 13' fill='none' stroke='%23334155' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") !important;
    background-position: center !important;
    background-size: 16px 16px !important;
    background-repeat: no-repeat !important;
    opacity: 1 !important;
    filter: none !important;
}
body .modal .modal-header > .btn-close {
    margin-left: auto !important;
    order: 99;
}
/* Renewal headers contain only the close control. Keep them pinned to the card. */
body .license-renew-plans-modal .modal-content > .modal-header,
body .license-renew-plans-modal .modal-content.vds-auto-fix-close > .modal-header {
    position: absolute !important;
    inset: 12px 12px auto auto !important;
    width: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    z-index: 10 !important;
}
body .license-renew-plans-modal .modal-content > .modal-body {
    padding-top: 60px !important;
}
/* Camera scanner owns its dark surface instead of inheriting the global glass skin. */
body.app-body #barcodeCameraModal .modal-content {
    background: #000 !important;
    color: #fff !important;
    border-color: #333 !important;
    box-shadow: 0 32px 90px rgba(0,0,0,.6) !important;
}
body.app-body #barcodeCameraModal .modal-content::before,
body.app-body #barcodeCameraModal .modal-content::after { display: none !important; }
body.app-body #barcodeCameraModal .modal-content * { color: #fff !important; }
body.app-body #barcodeCameraModal input { background: #171717 !important; border-color: #555 !important; }
body.app-body #barcodeCameraModal input::placeholder { color: #fff !important; opacity: 1; }
body.app-body #barcodeCameraModal .barcode-scan-topbar { flex-direction: row-reverse; }
/* Mobile camera entry; hardware barcode keyboards continue using the search field. */
#btnOpenBarcodeCamera { display: none !important; }
@media (max-width: 767.98px) and (any-pointer: coarse) {
    #btnOpenBarcodeCamera { display: flex !important; }
}
