/* ══════════════════════════════════════════════════════════════════
   notify.css  —  Toast · Error Modal · Loading Overlay · Page Loader
   ใช้ร่วมกันทุกหน้า  |  ต้อง include notify.js คู่กันด้วย
══════════════════════════════════════════════════════════════════ */

/* ── Google Fonts: Kanit (ดึงตรงจาก CDN) ── */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&display=swap');

/* ── Material Symbols (ใช้กับไอคอนใน toast) — โหลดเองกันพลาดกรณีหน้าเว็บไม่ได้ include ──
   ใช้ display=block (ไม่ใช่ swap) ตามคำแนะนำของ Google เพื่อกันปัญหาไอคอน
   ค้างเป็นข้อความ เช่น "check_circle" แทนที่จะเป็นรูปไอคอน ระหว่างฟอนต์โหลด ── */
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined&display=block');

/* ── Material Symbols Outlined — base ligature font rule ── */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    font-feature-settings: 'liga';
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

/* ── บังคับ font ทุก element ใน notify ── */
#toast,
#toast *,
#loadingOverlay,
#loadingOverlay *,
#errorModal,
#errorModal *,
#page-loader,
#page-loader *,
.modal-backdrop,
.modal-backdrop *,
.modal-box,
.modal-box *,
.pl-card,
.pl-card *,
#alertModal,
#alertModal * {
    font-family: 'Kanit', 'IBM Plex Sans Thai', 'Sarabun', sans-serif !important;
}

/* ── กันไอคอน material-symbols-outlined โดนกฎบังคับฟอนต์ Kanit ด้านบนทับ ──
   ต้องใช้ selector ที่ specificity สูงกว่า "#toast *" (id + universal)
   ถึงจะชนะได้แม้ทั้งคู่มี !important ── */
#toast .material-symbols-outlined,
#loadingOverlay .material-symbols-outlined,
#errorModal .material-symbols-outlined,
#page-loader .material-symbols-outlined,
.modal-backdrop .material-symbols-outlined,
.modal-box .material-symbols-outlined,
.pl-card .material-symbols-outlined,
#alertModal .material-symbols-outlined {
    font-family: 'Material Symbols Outlined' !important;
}

/* ── Toast animations ── */
@keyframes toastSpin {
    to { transform: rotate(360deg); }
}
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(24px); }
}

/* ── Toast element ── */
#toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fff;
    border-radius: 8px;
    padding: 14px 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.06);
    min-width: 360px;
    max-width: min(520px, calc(100vw - 40px));
    width: max-content;
}
#toast.toast-show {
    animation: toastSlideIn 0.22s cubic-bezier(.34,1.56,.64,1) forwards;
}
#toast.toast-hidden {
    animation: toastSlideOut 0.18s ease forwards;
    pointer-events: none;
}

/* ── Backdrop / Modal shared ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-box {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .18);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

/* alert modal (Alert.fire) */
.modal-box.alert-box {
    max-width: 440px;
}

/* ── Loading overlay ── */
#loadingOverlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(255, 255, 255, .7);
    display: flex;
    align-items: center;
    justify-content: center;
}
#loadingOverlay.hidden {
    display: none;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════
   Dark theme — Toast & Modals
══════════════════════════════════════════ */

/* toast */
[data-theme="black"] #toast {
    background: #3F3F3F !important;
    box-shadow: 0 2px 8px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.08) !important;
}
[data-theme="black"] #toast #toastTitle { color: #f0ece4 !important; }
[data-theme="black"] #toast #toastMsg   { color: #94a3b8 !important; }
[data-theme="black"] #toast #toastClose { color: #94a3b8 !important; }

/* modal backdrop & box */
[data-theme="black"] .modal-backdrop {
    background: rgba(15, 23, 42, .75) !important;
}
[data-theme="black"] .modal-box {
    background: #3F3F3F !important;
    color: #f0ece4 !important;
}

/* error modal specifics */
[data-theme="black"] #errorModal > div {
    background-color: #3F3F3F !important;
}
[data-theme="black"] #errorModal [style*="background:#fef2f2"] {
    background-color: rgba(220, 38, 38, .12) !important;
}
[data-theme="black"] #errorModal [style*="color:#ef4444"] {
    color: #fca5a5 !important;
}
[data-theme="black"] #errorModal [style*="background:#ef4444"] {
    background-color: #ef4444 !important;
}
[data-theme="black"] .w-16.h-16.rounded-full {
    background-color: rgba(220, 38, 38, .12) !important;
}

/* print / pring modals */
[data-theme="black"] #printTicketModal,
[data-theme="black"] #purchaseModal {
    background: rgba(15, 23, 42, .75) !important;
}

/* ══════════════════════════════════════════════════════════════════
   Page Loader  —  Backdrop + Spinner (รวมใน notify.css)
══════════════════════════════════════════════════════════════════ */

/* ── ป้องกัน scroll ขณะโหลด ── */
body.pl-loading {
    overflow: hidden;
}

/* ── Backdrop (เหมือน modal) ── */
#page-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    opacity: 1;
    visibility: visible;
}

[data-theme="black"] #page-loader {
    background: rgba(15, 23, 42, .75);
}

/* ── Hide state ── */
#page-loader.pl-hide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ── Inner card (เหมือน modal-box) ── */
.pl-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .18);
    padding: 36px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    min-width: 200px;
    text-align: center;
}

[data-theme="black"] .pl-card {
    background: #3F3F3F;
}

/* ── Spinner ── */
.pl-spinner-wrap {
    position: relative;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
}

.pl-spinner-track {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3.5px solid #e2e8f0;
}

[data-theme="black"] .pl-spinner-track {
    border-color: #52525b;
}

.pl-spinner-fill {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3.5px solid transparent;
    border-top-color: #2563eb;
    border-right-color: #2563eb;
    animation: pl-spin 0.75s cubic-bezier(.4,0,.2,1) infinite;
}

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

/* ── Text ── */
.pl-title {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    line-height: 1.4;
}

[data-theme="black"] .pl-title {
    color: #f4f4f5;
}

.pl-msg {
    font-size: 13px;
    color: #64748b;
    margin: -8px 0 0;
    line-height: 1.5;
}

[data-theme="black"] .pl-msg {
    color: #a1a1aa;
}

/* ── Error state ── */
.pl-error-icon {
    display: none;
    width: 52px;
    height: 52px;
    background: #fef2f2;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

[data-theme="black"] .pl-error-icon {
    background: rgba(220,38,38,.15);
}

.pl-error-icon svg {
    width: 26px;
    height: 26px;
    color: #dc2626;
}

#page-loader.pl-error .pl-spinner-wrap { display: none; }
#page-loader.pl-error .pl-error-icon   { display: flex; }
#page-loader.pl-error .pl-title        { color: #dc2626; }

.pl-reload-btn {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: #2563eb;
    border: none;
    border-radius: 8px;
    padding: 9px 20px;
    cursor: pointer;
    transition: background .15s;
    margin-top: 4px;
}

.pl-reload-btn:hover { background: #1d4ed8; }

#page-loader.pl-error .pl-reload-btn { display: flex; }

/* ── Dots animation ── */
.pl-dots::after {
    content: '';
    animation: pl-dots 1.4s steps(4, end) infinite;
}
@keyframes pl-dots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

/* ══════════════════════════════════════════════════════════════════
   Alert System (SweetAlert-style)  —  ใช้กับ Alert.fire() ใน notify.js
   ครอบคลุม: success · error · warning · info · question · loading ·
             confirm (มีปุ่มยกเลิก) · prompt (มี input) · toast (ใช้ #toast เดิม)
══════════════════════════════════════════════════════════════════ */
#alertModal {
    z-index: 10000;
}

.alert-box {
    padding: 34px 28px 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transform: scale(.9);
    opacity: 0;
    transition: transform .18s cubic-bezier(.34,1.56,.64,1), opacity .18s ease;
}
#alertModal.alert-show .alert-box {
    transform: scale(1);
    opacity: 1;
}

/* ── Icon circle ── */
.alert-icon-wrap {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    flex-shrink: 0;
    animation: alertIconPop .3s cubic-bezier(.34,1.56,.64,1);
}
.alert-icon-wrap svg {
    width: 36px;
    height: 36px;
}
.alert-icon-wrap.alert-icon-loading {
    animation: none;
}
.alert-icon-wrap.alert-icon-loading .alert-spinner {
    width: 40px;
    height: 40px;
    border: 3.5px solid rgba(37,99,235,.2);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: pl-spin .75s cubic-bezier(.4,0,.2,1) infinite;
}

@keyframes alertIconPop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* ── Text ── */
.alert-title {
    margin: 0 0 6px;
    font-size: 19px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.4;
}

.alert-text {
    margin: 0 0 4px;
    font-size: 14px;
    color: #64748b;
    line-height: 1.6;
    white-space: pre-line;
}

/* ── Input / Textarea ── */
.alert-input {
    width: 100%;
    margin-top: 16px;
    padding: 10px 14px;
    font-size: 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    outline: none;
    color: #1e293b;
    background: #fff;
    transition: border-color .15s;
    box-sizing: border-box;
}
.alert-input:focus {
    border-color: #2563eb;
}
.alert-textarea {
    min-height: 84px;
    resize: vertical;
    font-family: inherit;
}

/* ── Buttons ── */
.alert-buttons {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    width: 100%;
    justify-content: center;
}

.alert-btn {
    flex: 0 1 auto;
    min-width: 96px;
    max-width: 220px;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, transform .1s, opacity .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.alert-btn:active { transform: scale(.97); }
.alert-btn:disabled { opacity: .6; cursor: not-allowed; }

.alert-btn-confirm {
    background: #2563eb;
    color: #fff;
}
.alert-btn-confirm:hover { background: #1d4ed8; }

.alert-btn-cancel {
    background: #f1f5f9;
    color: #475569;
}
.alert-btn-cancel:hover { background: #e2e8f0; }

.alert-btn-danger {
    background: #dc2626;
    color: #fff;
}
.alert-btn-danger:hover { background: #b91c1c; }

/* ── Dark theme ── */
[data-theme="black"] .alert-title { color: #f4f4f5 !important; }
[data-theme="black"] .alert-text  { color: #a1a1aa !important; }
[data-theme="black"] .alert-input {
    background: #2a2a2a !important;
    border-color: #52525b !important;
    color: #f4f4f5 !important;
}
[data-theme="black"] .alert-btn-cancel {
    background: #4b4b4b !important;
    color: #e4e4e7 !important;
}
[data-theme="black"] .alert-btn-cancel:hover { background: #565656 !important; }