/* Shared PSU buttons */
.btn-psu,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 16px;
    border-radius: 10px;
    font-family: inherit;
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.2;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.btn-psu {
    border: 0;
    background: #003C71;
    color: #fff;
}

.btn-psu:hover,
.btn-psu:focus {
    border-color: #00284d;
    background: #00284d;
    color: #fff;
}

.btn-psu-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid #c5d6e8;
    border-radius: 10px;
    background: #fff;
    color: #003C71;
    font-family: inherit;
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.2;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.btn-psu-outline:hover,
.btn-psu-outline:focus {
    background: #003C71;
    border-color: #003C71;
    color: #fff;
}

.btn-psu.btn-lg,
.btn-psu-outline.btn-lg,
.btn-secondary.btn-lg,
.btn-warning.btn-lg {
    min-height: 48px;
    padding: 12px 18px;
    font-size: 1rem;
    line-height: 1.2;
}

/* Standardized modal footer & button spacing */
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px !important;
}

.modal-footer > * {
    margin: 0 !important;
}

.modal-footer.justify-content-center {
    justify-content: center !important;
}

.modal-footer .btn-psu,
.modal-footer .btn-secondary {
    min-width: 120px;
    min-height: 42px;
    padding: 8px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 10px;
    margin: 0 !important;
}


.text-psu {
    color: #003C71 !important;
}

.btn-warning {
    --bs-btn-color: #003C71;
    --bs-btn-bg: #c9a227;
    --bs-btn-border-color: #c9a227;
    --bs-btn-hover-color: #003C71;
    --bs-btn-hover-bg: #b18d1f;
    --bs-btn-hover-border-color: #a7831d;
    --bs-btn-active-color: #003C71;
    --bs-btn-active-bg: #a7831d;
    --bs-btn-active-border-color: #99781a;
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: #9aa6b2;
    --bs-btn-disabled-border-color: #9aa6b2;
}

.btn-secondary {
    border: 1px solid #6c757d;
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover,
.btn-secondary:focus {
    border-color: #5c636a;
    background: #5c636a;
    color: #fff;
}

.btn-danger-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid #f0c4c4;
    border-radius: 10px;
    background: #fff5f5;
    color: #a12b2b;
    font-family: inherit;
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.2;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.btn-danger-outline:hover,
.btn-danger-outline:focus {
    border-color: #a12b2b;
    background: #a12b2b;
    color: #fff;
}

.btn-danger-outline.btn-sm {
    min-height: 32px;
    padding: 6px 12px;
    font-size: .82rem;
}

.btn-psu-outline.btn-sm {
    min-height: 32px;
    padding: 6px 12px;
    font-size: .82rem;
}
/* Tracking history modal */
.tracking-history-modal .modal-content {
    border: 0;
    border-radius: 18px;
    overflow: hidden;
}

.tracking-history-modal .modal-header,
.admin-body .tracking-history-modal .modal-header {
    padding: 18px 22px;
    background: #f7fafc;
    border-bottom: 1px solid #e7edf3;
}

.tracking-history-modal .modal-title {
    color: #003C71;
    font-weight: 800;
}

.tracking-history-modal-subtitle,
.tracking-history-modal .modal-subtitle {
    margin-top: 3px;
    color: #738397;
    font-size: .84rem;
}

.tracking-history-modal .modal-body,
.admin-body .tracking-history-modal .modal-body,
.admin-body .admin-modal.tracking-history-modal .modal-body {
    padding: 8px 8px 16px;
    max-height: min(68vh, 640px);
    overflow-y: auto;
}

.tracking-history-list {
    position: relative;
    margin: 0;
    padding: 8px 12px 4px 18px;
}

.tracking-history-spine {
    position: absolute;
    left: 23px;
    top: 18px;
    bottom: 18px;
    width: 2px;
    background: #d7e2ec;
    border-radius: 99px;
    pointer-events: none;
}

.tracking-history-item {
    position: relative;
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr);
    column-gap: 14px;
    padding: 0 0 18px;
}

.tracking-history-item:last-child {
    padding-bottom: 4px;
}

.tracking-history-dot {
    position: relative;
    z-index: 1;
    width: 12px;
    height: 12px;
    margin-top: 5px;
    border: 2px solid #9aaabd;
    border-radius: 50%;
    background: #fff;
    box-sizing: border-box;
}

.tracking-history-item.is-first .tracking-history-dot {
    border-color: #003C71;
    background: #003C71;
}

.tracking-history-status-delivered .tracking-history-dot {
    border-color: #27834b;
}

.tracking-history-item.is-first.tracking-history-status-delivered .tracking-history-dot {
    background: #27834b;
    border-color: #27834b;
}

.tracking-history-status-out_for_delivery .tracking-history-dot {
    border-color: #c9a227;
}

.tracking-history-item.is-first.tracking-history-status-out_for_delivery .tracking-history-dot {
    background: #c9a227;
    border-color: #c9a227;
}

.tracking-history-body {
    min-width: 0;
}

.tracking-history-when {
    display: block;
    margin-bottom: 2px;
    color: #8a9aab;
    font-size: .78rem;
    font-weight: 600;
}

.tracking-history-title {
    margin: 0;
    color: #1d2a38;
    font-size: .95rem;
    font-weight: 700;
    line-height: 1.45;
}

.tracking-history-item.is-first .tracking-history-title {
    color: #003C71;
}

.tracking-history-place {
    margin: 2px 0 0;
    color: #66788a;
    font-size: .84rem;
    line-height: 1.45;
}

.tracking-history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 36px 16px;
    color: #738397;
    text-align: center;
}

.tracking-history-empty i {
    font-size: 1.6rem;
    color: #9aaabd;
    margin-bottom: 4px;
}

.tracking-history-empty strong {
    color: #355064;
}

.tracking-history-empty span {
    font-size: .86rem;
}

.tracking-history-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.tracking-history-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid #003C71;
    border-radius: 10px;
    background: #003C71;
    color: #fff;
    font-family: inherit;
    font-size: .86rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.tracking-history-btn:hover,
.tracking-history-btn:focus {
    background: #00284d;
    border-color: #00284d;
    color: #fff;
}

.tracking-history-btn:focus-visible {
    outline: 2px solid #c9a227;
    outline-offset: 2px;
}

.tracking-history-btn.is-outline {
    background: #fff;
    color: #003C71;
}

.tracking-history-btn.is-outline:hover,
.tracking-history-btn.is-outline:focus {
    background: #eef4fb;
    border-color: #003C71;
    color: #003C71;
}

.tracking-history-btn-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #c9a227;
    color: #00284d;
    font-size: .75rem;
    font-weight: 800;
}

.admin-body .tracking-history-btn,
.admin-body a.tracking-history-btn {
    color: #fff;
}

.admin-body .tracking-history-btn.is-outline,
.admin-body a.tracking-history-btn.is-outline {
    color: #003C71;
}
@media (max-width: 575.98px) {

    .tracking-history-modal .modal-header,
    .admin-body .tracking-history-modal .modal-header {
        padding: 16px 16px 14px;
    }

    .tracking-history-modal .modal-body,
    .admin-body .tracking-history-modal .modal-body,
    .admin-body .admin-modal.tracking-history-modal .modal-body {
        padding: 4px 4px 12px;
    }

    .tracking-history-list {
        padding: 6px 10px 2px 14px;
    }

    .tracking-history-spine {
        left: 19px;
    }

    .tracking-history-item {
        column-gap: 12px;
        padding-bottom: 16px;
    }

    .tracking-history-btn {
        flex: 1 1 auto;
    }
}
:root {
    --psu-blue: #003C71;
    --psu-blue-dark: #00284d;
    --psu-blue-light: #eaf2fa;
    --psu-gold: #c9a227;
    --psu-gold-light: #f2d889;
    --bg: #f3f6fb;
    --text: #1d2a38;
    --psu-font: "Prompt", sans-serif;

    /* Override Bootstrap 5 theme variables globally with PSU Identity */
    --bs-font-sans-serif: var(--psu-font);
    --bs-body-font-family: var(--psu-font);
    --bs-primary: #003C71;
    --bs-primary-rgb: 0, 60, 113;
    --bs-link-color: #003C71;
    --bs-link-color-rgb: 0, 60, 113;
    --bs-link-hover-color: #00284d;
    --bs-link-hover-color-rgb: 0, 40, 77;
    --bs-focus-ring-color: rgba(0, 60, 113, 0.25);
    --bs-dropdown-link-active-bg: #003C71;
    --bs-dropdown-link-active-color: #fff;
    --bs-dropdown-link-hover-bg: #eaf2fa;
    --bs-dropdown-link-hover-color: #00284d;
}

/* Global Bootstrap Primary Overrides for PSU Theme */
.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--psu-blue);
    --bs-btn-border-color: var(--psu-blue);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--psu-blue-dark);
    --bs-btn-hover-border-color: var(--psu-blue-dark);
    --bs-btn-focus-shadow-rgb: 0, 60, 113;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--psu-blue-dark);
    --bs-btn-active-border-color: var(--psu-blue-dark);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--psu-blue);
    --bs-btn-disabled-border-color: var(--psu-blue);
}

.btn-outline-primary {
    --bs-btn-color: var(--psu-blue);
    --bs-btn-border-color: var(--psu-blue);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--psu-blue);
    --bs-btn-hover-border-color: var(--psu-blue);
    --bs-btn-focus-shadow-rgb: 0, 60, 113;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--psu-blue-dark);
    --bs-btn-active-border-color: var(--psu-blue-dark);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--psu-blue);
    box-shadow: 0 0 0 0.25rem rgba(0, 60, 113, 0.15);
}

.form-check-input:checked {
    background-color: var(--psu-blue);
    border-color: var(--psu-blue);
}

.form-check-input:focus {
    border-color: var(--psu-blue);
    box-shadow: 0 0 0 0.25rem rgba(0, 60, 113, 0.15);
}

.dropdown-item:active {
    background-color: var(--psu-blue);
    color: #fff;
}

html,
body {
    min-height: 100%;
    overflow-x: clip;
}

body {
    font-family: var(--psu-font);
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Shared toast notifications */
.app-toast-host {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 21000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
    max-width: min(360px, calc(100vw - 24px));
}

/* แผงแชทใช้ z-index ~1082 — ให้ SweetAlert อยู่เหนือเสมอ */
body .swal2-container {
    z-index: 20000 !important;
}

.app-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    min-width: 240px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: #fff;
    box-shadow: 0 10px 28px rgba(16, 28, 42, 0.14);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .2s ease, transform .2s ease;
}

.app-toast.is-show {
    opacity: 1;
    transform: translateY(0);
}

.app-toast.is-hide {
    opacity: 0;
    transform: translateY(-6px);
}

.app-toast-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.95rem;
}

.app-toast-body {
    flex: 1 1 auto;
    min-width: 0;
    display: grid;
    gap: 2px;
    padding-top: 2px;
}

.app-toast-title {
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.3;
    color: #1d2a38;
}

.app-toast-msg {
    font-size: 0.86rem;
    line-height: 1.4;
    color: #4a5b6c;
    word-break: break-word;
}

.app-toast-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #8099ab;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.app-toast-close:hover {
    background: rgba(16, 28, 42, 0.06);
    color: #355064;
}

.app-toast.is-success {
    border-color: #cfe9d8;
    background: #f7fcf9;
}
.app-toast.is-success .app-toast-icon {
    background: #e7f6ec;
    color: #1b6b3a;
}
.app-toast.is-success .app-toast-title {
    color: #1b6b3a;
}

.app-toast.is-error {
    border-color: #f0c4c0;
    background: #fff8f7;
}
.app-toast.is-error .app-toast-icon {
    background: #fdebec;
    color: #b42318;
}
.app-toast.is-error .app-toast-title {
    color: #b42318;
}

.app-toast.is-warning {
    border-color: #efd39a;
    background: #fffaf0;
}
.app-toast.is-warning .app-toast-icon {
    background: #fff4df;
    color: #8a6d12;
}
.app-toast.is-warning .app-toast-title {
    color: #8a6d12;
}

.app-toast.is-info {
    border-color: #d6e3ef;
    background: #f7fafc;
}
.app-toast.is-info .app-toast-icon {
    background: #eef4fb;
    color: #003C71;
}
.app-toast.is-info .app-toast-title {
    color: #003C71;
}

/* อนิเมชันโยนสินค้าเข้าตะกร้า */
.cart-fly-ghost {
    position: fixed;
    z-index: 20000;
    pointer-events: none;
    border-radius: 50%;
    overflow: visible;
    background: #fff;
    box-shadow: 0 12px 30px rgba(0, 36, 72, 0.38), 0 3px 10px rgba(0, 0, 0, 0.16);
    border: 3px solid #ffffff;
    will-change: transform, opacity;
}

.cart-fly-ghost.is-from-btn {
    box-shadow: 0 14px 34px rgba(0, 60, 113, 0.45), 0 4px 12px rgba(0, 0, 0, 0.2);
    border: 2.5px solid #ffb81c;
}

.cart-fly-ghost .cart-fly-img-wrap {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-fly-ghost img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-fly-ghost i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #003C71;
    font-size: 1.4rem;
}

.cart-fly-ghost .cart-fly-qty {
    position: absolute;
    top: -5px;
    right: -7px;
    background: #c1121f;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
    line-height: 1.1;
    white-space: nowrap;
    animation: cartBadgePop 0.28s ease;
}

/* ปุ่มสถานะเมื่อเพิ่มลงตะกร้าสำเร็จ */
.btn.is-cart-success {
    background-color: #198754 !important;
    border-color: #198754 !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(25, 135, 84, 0.25) !important;
    transform: scale(0.98);
    transition: all 0.22s ease;
}

.btn.is-cart-pressed {
    animation: btnCartPress 0.25s ease;
}

@keyframes btnCartPress {
    0% { transform: scale(1); }
    45% { transform: scale(0.94); }
    100% { transform: scale(1); }
}

.shop-cart-link {
    position: relative;
}

.shop-cart-link::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(255, 184, 28, 0.55) 0%, rgba(255, 184, 28, 0) 75%);
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 0;
    pointer-events: none;
}

.shop-cart-link.is-cart-bump::after {
    animation: cartGlowRing 0.55s ease-out;
}

.shop-cart-link.is-cart-bump {
    animation: cartIconBump 0.45s ease;
}

.shop-cart-badge.is-cart-pop {
    animation: cartBadgePop 0.45s ease;
}

@keyframes cartGlowRing {
    0% {
        transform: translate(-50%, -50%) scale(0.6);
        opacity: 0.9;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.4);
        opacity: 0;
    }
}

@keyframes cartIconBump {
    0%, 100% {
        transform: scale(1);
    }
    32% {
        transform: scale(1.24);
    }
    64% {
        transform: scale(0.92);
    }
}

@keyframes cartBadgePop {
    0% {
        transform: scale(0.4);
        opacity: 0.4;
    }
    55% {
        transform: scale(1.35);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cart-fly-ghost,
    .shop-cart-link.is-cart-bump,
    .shop-cart-badge.is-cart-pop,
    .shop-cart-link.is-cart-bump::after,
    .btn.is-cart-pressed {
        animation: none !important;
    }
}

@media (max-width: 575px) {
    .app-toast-host {
        left: 12px;
        right: 12px;
        top: 12px;
        align-items: stretch;
        max-width: none;
    }
    .app-toast {
        min-width: 0;
    }
}
