/* ==========================================================================
   LAYOUT DÙNG CHUNG CHO TOÀN BỘ CÁC TRANG (layout.css)
   ========================================================================== */

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
}

/* 1. MẶC ĐỊNH TRÊN MOBILE (Điện thoại thật / Captive Wi-Fi / Màn hình <= 480px) */
body {
    display: flex;
    justify-content: center;
    align-items: flex-start !important;
    background-color: #f7faff;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Áp dụng cho cả .phone-container và .container trực tiếp thuộc body */
.phone-container,
body>.container {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    margin-left: auto !important;
    margin-right: auto !important;

    /* Cho phép cuộn mượt, không giật lag, không tràn ngang */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;

    /* Tràn viền 100% trên điện thoại */
    border-radius: 0 !important;
    box-shadow: none !important;
    position: relative;
    display: flex;
    flex-direction: column;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}

/* 2. KHI XEM TRÊN TABLET / LAPTOP / PC (Màn hình > 480px) */
@media (min-width: 481px) {
    body {
        background-color: #e2e8f0 !important;
        align-items: center !important;
        padding: 20px 16px !important;
        height: auto !important;
    }

    .phone-container,
    body>.container {
        max-width: 430px !important;
        height: min(880px, 94vh) !important;
        margin: auto !important;
        box-shadow: 0 25px 60px -15px rgba(0, 20, 60, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.06) !important;
    }
}

/* Xử lý khi .container nằm lồng bên trong .phone-container (như apple-wallet / google-wallet) */
.phone-container .container {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    min-height: auto !important;
    margin: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow-y: visible !important;
    overflow-x: visible !important;
    background-color: transparent !important;
    background-image: none !important;
    padding: 0 clamp(12px, 4vw, 16px) 16px !important;
    flex-shrink: 0 !important;
}

/* ==========================================================================
   CUSTOM SCROLLBAR (Áp dụng toàn bộ trình duyệt & thiết bị)
   ========================================================================== */
html,
body,
.phone-container,
.container {
    scrollbar-width: thin;
    scrollbar-color: rgba(25, 45, 57, 0.3) transparent;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.phone-container::-webkit-scrollbar,
.container::-webkit-scrollbar,
body::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.phone-container::-webkit-scrollbar-track,
.container::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
    background: transparent;
}

.phone-container::-webkit-scrollbar-thumb,
.container::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
    background-color: rgba(25, 45, 57, 0.28);
    border-radius: 9999px;
    transition: background-color 0.2s ease;
}

.phone-container::-webkit-scrollbar-thumb:hover,
.container::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover {
    background-color: rgba(25, 45, 57, 0.55);
}

.phone-container::-webkit-scrollbar-thumb:active,
.container::-webkit-scrollbar-thumb:active,
body::-webkit-scrollbar-thumb:active {
    background-color: #0056ed;
}

/* ==========================================================================
   TOAST NOTIFICATION
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    width: calc(100% - 32px);
    max-width: 380px;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast-message {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 18px;
    background: rgba(25, 45, 57, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #ffffff;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
    animation: toastSlideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-message.toast-error {
    background: rgba(220, 38, 38, 0.95);
    box-shadow: 0 12px 32px rgba(220, 38, 38, 0.3);
}

.toast-message.toast-success {
    background: rgba(22, 163, 74, 0.95);
    box-shadow: 0 12px 32px rgba(22, 163, 74, 0.3);
}

.toast-message.toast-warning {
    background: rgba(217, 119, 6, 0.95);
    box-shadow: 0 12px 32px rgba(217, 119, 6, 0.3);
}

.toast-message.toast-hiding {
    opacity: 0;
    transform: translateY(-12px);
}

.toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes toastSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}