/* =====================================================================
   Theme Noel - trang khách (views/panel/layout.ejs), admin, 3 trang đăng nhập.
   Bật/tắt, từng hiệu ứng: CHRISTMAS_THEME ở lib/constants.js.
   File chỉ được nạp khi theme đang bật; mỗi hiệu ứng còn khoá thêm bằng
   class body.xmas-fx-<tên> nên tắt 1 hiệu ứng trong config là rule của nó thôi chạy.
   Quy ước: chỉ animate transform/opacity, mọi lớp trang trí pointer-events:none,
   không đổi kích thước/vị trí phần tử có sẵn (trừ position:relative cho card có tuyết).
   ===================================================================== */

body.xmas {
    --xmas-red: #DC2626;
    --xmas-green: #16A34A;
    --xmas-gold: #F4C95D;
    --xmas-navy: #101827;
    --xmas-snow: #FFFFFF;
    --xmas-gold-line: rgba(226, 184, 92, .5);
}

.xmas-page, .xmas-page *, .xmas-sb, .xmas-sb *, .xmas-hat, .xmas-sb-corner, .xmas-auth, .xmas-auth * {
    pointer-events: none;
    user-select: none;
}

/* ---------- Dây đèn mép trên ---------- */
.xmas-lights {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 22px;
    z-index: 100;
    overflow: hidden;
}
.xmas-lights > i {
    position: absolute;
    inset: 0;
    background: url(images/lights.svg) repeat-x 0 0 / auto 100%;
}
.xmas-lights > .xmas-a { background-image: url(images/lights-glow-a.svg); }
.xmas-lights > .xmas-b { background-image: url(images/lights-glow-b.svg); }
.xmas-lights > .xmas-c { background-image: url(images/lights-sparkle.svg); opacity: 0; }
body.xmas-fx-lights:not(.xmas-fx-lights-static) .xmas-lights > .xmas-a { animation: xmas-glow 3.6s ease-in-out infinite; }
body.xmas-fx-lights:not(.xmas-fx-lights-static) .xmas-lights > .xmas-b { animation: xmas-glow 3.6s ease-in-out -1.8s infinite; }
body.xmas-fx-lights:not(.xmas-fx-lights-static) .xmas-lights > .xmas-c { animation: xmas-twinkle 4.2s linear infinite; }

/* Dây đèn không vắt ngang mũ Noel: desktop bắt đầu từ mép sidebar 288px (nối từ cành thông góc
   sidebar), ≤1024 bắt đầu ngay sau nút menu đang đội mũ. */
.xmas-lights { left: 48px; }
@media (min-width: 1025px) {
    .xmas-lights { left: 288px; }
}

@keyframes xmas-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: .22; }
}
@keyframes xmas-twinkle {
    0%, 62%, 100% { opacity: 0; }
    68% { opacity: 1; }
    74% { opacity: .25; }
    80% { opacity: .9; }
    88% { opacity: 0; }
}

/* ---------- Cành thông góc trên phải màn hình ---------- */
.xmas-corner {
    position: fixed;
    top: 0;
    right: 0;
    width: 84px;
    height: auto;
    z-index: 100;
    transform-origin: 100% 0;
    filter: drop-shadow(0 2px 3px rgba(15, 23, 42, .25));
    animation: xmas-sway 7s ease-in-out infinite;
}
@keyframes xmas-sway {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-2deg); }
}

/* ---------- Tuyết rơi (bông do christmas.js tạo) ---------- */
.xmas-snow {
    position: fixed;
    inset: 0;
    z-index: 99;
    overflow: hidden;
    contain: strict;
}
.xmas-snow i {
    position: absolute;
    top: -12px;
    left: 0;
    /* Nền sáng: bông trắng chìm vào card trắng → to hơn 1.4 lần, mép xanh băng, viền mảnh + bóng đổ
       để tách khỏi nền, đậm thêm .3. Dark mode trả về cỡ/độ đậm gốc (khối Dark mode bên dưới). */
    width: calc(var(--s) * 1.4);
    height: calc(var(--s) * 1.4);
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #fff 0, #fff 30%, #d6e4f7 62%, #8fb0dc 100%);
    box-shadow: 0 0 0 .5px rgba(74, 112, 170, .45), 0 1px 4px rgba(30, 64, 120, .3);
    opacity: min(1, calc(var(--o) + .3));
    translate: var(--x) -12px;
    animation: xmas-fall var(--d) linear var(--dl) infinite,
               xmas-drift var(--sd) ease-in-out var(--dl) infinite alternate;
    will-change: transform, translate;
}
/* Blur làm bông gần nhoè mất trên nền trắng: chỉ giữ ở dark mode */
body.xmas.dark_mode .xmas-snow i.xmas-near { filter: blur(1px); }
@keyframes xmas-fall {
    from { translate: var(--x) -12px; }
    to { translate: var(--x) calc(100vh + 24px); }
}
@keyframes xmas-drift {
    from { transform: translateX(calc(var(--sw) * -1)); }
    to { transform: translateX(var(--sw)); }
}
/* Tab bị ẩn: dừng mọi animation trang trí. !important vì các rule animation ở trên
   viết shorthand (đặt lại play-state) với độ ưu tiên cao hơn rule này. */
html.xmas-paused .xmas-page *,
html.xmas-paused .xmas-sb *,
html.xmas-paused .xmas-auth * { animation-play-state: paused !important; }

/* ---------- Sidebar: lớp nền sau menu (z-index -1 trong stacking context của #kt_aside) ---------- */
.xmas-sb {
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}
.xmas-sky {
    position: absolute;
    inset: 0;
    background: url(images/sky-a.svg) repeat-y 0 0 / 288px auto;
    animation: xmas-sky 5.5s ease-in-out infinite;
}
.xmas-sky.xmas-b {
    background-image: url(images/sky-b.svg);
    background-position: 0 140px;
    animation-delay: -2.75s;
}
@keyframes xmas-sky {
    0%, 100% { opacity: 1; }
    50% { opacity: .3; }
}

/* Cây thông góc dưới sidebar, nằm SAU menu nên không che mục nào. Phần đệm cuối menu
   (#kt_aside_menu::after) để cuộn hết cỡ thì mục cuối nằm trên cây, không đè lên. */
.xmas-ground {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 172px;
    height: 18px;
    background: url(images/snow-ground.svg) no-repeat 0 0 / 100% 100%;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 40px);
    mask-image: linear-gradient(90deg, transparent, #000 40px);
}
.xmas-tree {
    position: absolute;
    right: 8px;
    bottom: 5px;
    width: 148px;
    aspect-ratio: 180 / 230;
}
.xmas-tree img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.xmas-tree > img:first-child { filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .35)); }
.xmas-tree-lights.xmas-a { animation: xmas-glow 2.8s ease-in-out infinite; }
.xmas-tree-lights.xmas-b { animation: xmas-glow 2.8s ease-in-out -1.4s infinite; }
.xmas-tree-star {
    position: absolute;
    left: 52.2%;
    top: 9.6%;
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 226, 138, .85) 0, rgba(255, 214, 102, .35) 35%, rgba(255, 214, 102, 0) 70%);
    animation: xmas-star 3.2s ease-in-out infinite;
}
@keyframes xmas-star {
    0%, 100% { opacity: .55; transform: scale(.85); }
    50% { opacity: 1; transform: scale(1.1); }
}
body.xmas-fx-christmas-tree #kt_aside_menu::after {
    content: "";
    display: block;
    height: 170px;
}

/* ---------- Mũ Noel: trên logo (vị trí do christmas.js đo) và trên nút menu mobile ---------- */
.xmas-hat {
    position: absolute;
    z-index: 2;
    left: var(--xmas-hat-x, 89px);
    top: var(--xmas-hat-y, 0px);
    width: 34px;
    height: 30px;
    background: url(images/santa-hat.svg) no-repeat center / contain;
    transform: rotate(14deg);
    transform-origin: 30% 85%;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35));
}
body.xmas-fx-santa-hat.view-user .topbar-v2 #tb-burger { position: relative; overflow: visible; }
body.xmas-fx-santa-hat.view-user .topbar-v2 #tb-burger::after {
    content: "";
    position: absolute;
    left: -8px;
    top: -10px;
    width: 28px;
    height: 24px;
    background: url(images/santa-hat.svg) no-repeat center / contain;
    transform: rotate(-22deg);
    filter: drop-shadow(0 2px 2px rgba(15, 23, 42, .25));
    pointer-events: none;
}

/* Cành thông góc trên phải sidebar (khoảng trống cạnh logo) */
.xmas-sb-corner {
    position: absolute;
    top: 0;
    right: 0;
    width: 88px;
    height: auto;
    z-index: 1;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35));
}

/* ---------- Card: tuyết đọng mép trên + viền vàng champagne ----------
   Danh sách card dò bằng script trên toàn bộ ~80 trang khách, desktop + mobile (chỉ lấy card
   ngoài cùng, card nằm trong card khác tự bị loại ở :not). Thêm position:relative không làm con
   absolute nào đổi mốc; các card này chưa dùng ::before/::after.
     /           .kt-portlet, .card chứa bản tin Quản trị viên (.feed-content)
     dịch vụ     .content-container, .pw-card (+ .pw-card--stat, cách 2)   /report .content-container
     /site       .cd-card              /prices  .prices-v2 .panel (+ .svc, cách 3)
     /profile    .profile-card, .profile-block, .profile-tab__footer
     /payment    .card-pad (+ Hướng dẫn nạp tiền, cách 3; thẻ hoá đơn chỉ tự đứng ở mobile)
     /referral   .rstat (+ .rpanel, .ref-hero, cách 3)
     /tickets    .svc-side-card        /tools/*  .card.card-body
   Cách 1 (đa số): ::before = viền vàng, ::after = mô tuyết. */
body:is(.xmas-fx-snow-accumulation, .xmas-fx-card-decoration) .hl-shell :is(.kt-portlet, .card:has(> .card-body > .feed-content), .content-container, .pw-card, .cd-card, .prices-v2 .panel, .profile-card, .profile-block, .profile-tab__footer, .card-pad, .ref-v2 .rstat, .svc-side-card, .card.card-body):not(.pw-card--stat, .prices-v2 .svc, .ref-v2 .rpanel, .ref-v2 .ref-hero, .payment-v2 #panel-bank .card-collapsible, .modal *, :is(.kt-portlet, .content-container, .pw-card, .cd-card, .prices-v2 .panel, .profile-card, .profile-block, .card-pad, .ref-v2 .rpanel) *) {
    position: relative;
}
body.xmas-fx-card-decoration .hl-shell :is(.kt-portlet, .card:has(> .card-body > .feed-content), .content-container, .pw-card, .cd-card, .prices-v2 .panel, .profile-card, .profile-block, .profile-tab__footer, .card-pad, .ref-v2 .rstat, .svc-side-card, .card.card-body):not(.pw-card--stat, .prices-v2 .svc, .ref-v2 .rpanel, .ref-v2 .ref-hero, .payment-v2 #panel-bank .card-collapsible, .modal *, :is(.kt-portlet, .content-container, .pw-card, .cd-card, .prices-v2 .panel, .profile-card, .profile-block, .card-pad, .ref-v2 .rpanel) *)::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid var(--xmas-gold-line);
    pointer-events: none;
}
/* Cách 2: thẻ Số dư / Tổng nạp ở trang dịch vụ đã dùng ::after cho sóng nền → tuyết ở ::before */
body.xmas-fx-snow-accumulation .hl-shell :is(.kt-portlet, .card:has(> .card-body > .feed-content), .content-container, .pw-card, .cd-card, .prices-v2 .panel, .profile-card, .profile-block, .profile-tab__footer, .card-pad, .ref-v2 .rstat, .svc-side-card, .card.card-body):not(.pw-card--stat, .prices-v2 .svc, .ref-v2 .rpanel, .ref-v2 .ref-hero, .payment-v2 #panel-bank .card-collapsible, .modal *, :is(.kt-portlet, .content-container, .pw-card, .cd-card, .prices-v2 .panel, .profile-card, .profile-block, .card-pad, .ref-v2 .rpanel) *)::after,
body.xmas-fx-snow-accumulation .hl-shell .pw-card--stat::before {
    content: "";
    position: absolute;
    top: -18px;
    left: -3px;
    right: -3px;
    height: 44px;
    z-index: 3;
    background:
        url(images/snow-cap-left.svg) no-repeat left top / auto 44px,
        url(images/snow-cap-right.svg) no-repeat right top / auto 44px;
    filter: var(--xmas-cap-filter);
    pointer-events: none;
}
/* Viền vàng không chiếm chỗ, bo theo border-radius: dùng outline cho card không còn pseudo trống */
body.xmas-fx-card-decoration .hl-shell :is(.pw-card--stat, .prices-v2 .svc, .ref-v2 .rpanel, .ref-v2 .ref-hero, .payment-v2 #panel-bank .card-collapsible),
body.xmas-fx-snow-accumulation .hl-shell :is(.prices-v2 .svc, .ref-v2 .rpanel, .ref-v2 .ref-hero, .payment-v2 #panel-bank .card-collapsible) {
    outline: 1px solid var(--xmas-gold-line);
    outline-offset: -1px;
}
/* Cách 3: card phải giữ overflow:hidden (panel /referral co theo cột lưới nhờ nó, banner cắt các
   đốm mờ, bảng giá + hướng dẫn nạp tiền bo góc) → mô tuyết vẽ bằng border-image + outset: phần
   nhô ra ngoài là của chính card nên overflow không cắt. Viền 1px gốc bị border-image thay chỗ,
   outline ở trên vẽ lại. Cả 4 card đều sẵn viền 1px solid nên không đổi kích thước. */
body.xmas-fx-snow-accumulation .hl-shell :is(.prices-v2 .svc, .ref-v2 .rpanel, .ref-v2 .ref-hero, .payment-v2 #panel-bank .card-collapsible) {
    border-image: url(images/snow-frame.svg) 44 130 0 60 / 44px 130px 0 60px / 18px 3px 0 3px stretch;
}
/* Bông tuyết vàng ở đầu card trang chủ (chỉ khi đầu card không có nút công cụ bên phải) */
body.xmas-fx-card-decoration .hl-shell .kt-portlet:not(.kt-portlet .kt-portlet) > .kt-portlet__head:not(:has(.kt-portlet__head-toolbar)) {
    background-image: url(images/snowflake-gold.svg);
    background-repeat: no-repeat;
    background-position: right 18px center;
    background-size: 20px 20px;
}

/* ---------- Khu admin (views/admin/layout.ejs, body.admin-page) ----------
   Dùng chung markup + hiệu ứng với trang khách, khác ở chỗ:
   - Màu menu admin nằm ở nền đục của .kt-aside-menu (custom.css) nên lớp sao/cây (z-index -1)
     bị che → chuyển màu đó sang #kt_aside, menu để trong suốt. Sáng hay tối đều #1e1e2d.
   - Sidebar rộng 320px; không có cành thông góc (góc phải màn hình đè chữ "Xin chào, Quản trị
     viên", góc phải sidebar đè nút thu menu).
   - ≤1024 cả #kt_aside cuộn (overflow:auto) nên lớp nền sẽ trôi theo menu → bỏ sao/cây.
   - Tuyết đọng đặt trên khung trắng bọc nội dung mọi trang admin, vẽ bằng border-image (cách 3)
     để khỏi đổi position của khung chứa toàn bộ trang. */
body.admin-page:is(.xmas-fx-sidebar-stars, .xmas-fx-christmas-tree) #kt_aside { background-color: #1e1e2d; }
body.admin-page:is(.xmas-fx-sidebar-stars, .xmas-fx-christmas-tree) #kt_aside_menu { background-color: transparent; }
body.admin-page .xmas-corner,
body.admin-page .xmas-sb-corner { display: none; }
@media (min-width: 1025px) {
    body.admin-page .xmas-lights { left: 320px; }
}
@media (max-width: 1024px) {
    body.admin-page .xmas-sb { display: none; }
    body.admin-page.xmas-fx-christmas-tree #kt_aside_menu::after { content: none; }
}
body.xmas-fx-santa-hat.admin-page .kt-header-mobile .toggle-sidebar-mobile { position: relative; }
body.xmas-fx-santa-hat.admin-page .kt-header-mobile .toggle-sidebar-mobile::after {
    content: "";
    position: absolute;
    left: -10px;
    top: -9px;
    width: 26px;
    height: 22px;
    background: url(images/santa-hat.svg) no-repeat center / contain;
    transform: rotate(-22deg);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35));
    pointer-events: none;
}
body.xmas-fx-snow-accumulation.admin-page #kt_content > .kt-container > .kt-portlet {
    border-style: solid;
    border-width: 0;
    border-image: url(images/snow-frame.svg) 44 130 0 60 / 44px 130px 0 60px / 18px 3px 0 3px stretch;
}
body.admin-page:is(.xmas-fx-snow-accumulation, .xmas-fx-card-decoration) #kt_content > .kt-container > .kt-portlet {
    outline: 1px solid var(--xmas-gold-line);
    outline-offset: -1px;
}

/* ---------- 3 trang đăng nhập (login / register / forgot_pass, body.desk-page) ----------
   Không có sidebar, topbar: dây đèn chạy hết bề ngang, cành thông ở cả 2 góc trên (cả mobile),
   mũ Noel đội trên logo, khung form có tuyết đọng + viền vàng, cây thông đứng cạnh mép trái
   khung form (chỉ màn rộng, màn hẹp form chiếm gần hết bề ngang). */
body.desk-page .xmas-lights { left: 0; }
/* Khung form trắng trên nền gỗ trắng: bóng mô tuyết đậm hơn panel một chút cho khỏi chìm */
body.xmas.desk-page { --xmas-cap-filter: drop-shadow(0 1px 2px rgba(71, 85, 105, .38)); }
body.desk-page .xmas-corner { width: 112px; }
.xmas-corner--left {
    right: auto;
    left: 0;
    transform-origin: 50% 0;
    transform: scaleX(-1);
    animation-name: xmas-sway-left;
}
@keyframes xmas-sway-left {
    0%, 100% { transform: scaleX(-1) rotate(0deg); }
    50% { transform: scaleX(-1) rotate(-2deg); }
}
body.xmas-fx-santa-hat.desk-page .desk-brand { position: relative; }
body.xmas-fx-santa-hat.desk-page .desk-brand::after {
    content: "";
    position: absolute;
    left: 54%;
    top: -9%;
    width: 42%;
    aspect-ratio: 34 / 30;
    background: url(images/santa-hat.svg) no-repeat center / contain;
    transform: rotate(20deg);
    transform-origin: 30% 85%;
    filter: drop-shadow(0 2px 2px rgba(15, 23, 42, .3));
    pointer-events: none;
}
body.desk-page:is(.xmas-fx-snow-accumulation, .xmas-fx-card-decoration, .xmas-fx-christmas-tree) .desk-card { position: relative; }
/* Khung form sẵn có viền 1px trắng: đổi màu chính viền đó sang vàng. Vẽ thêm ::before như card
   panel thì viền vàng nằm trong viền trắng, nhìn thành 2 viền. */
body.xmas-fx-card-decoration.desk-page .desk-card { border-color: var(--xmas-gold-line); }
body.xmas-fx-snow-accumulation.desk-page .desk-card::after {
    content: "";
    position: absolute;
    top: -18px;
    left: -3px;
    right: -3px;
    height: 44px;
    z-index: 3;
    background:
        url(images/snow-cap-left.svg) no-repeat left top / auto 44px,
        url(images/snow-cap-right.svg) no-repeat right top / auto 44px;
    filter: var(--xmas-cap-filter);
    pointer-events: none;
}
.xmas-auth {
    position: absolute;
    right: 100%;
    bottom: -2px;
    width: 176px;
    height: 214px;
    margin-right: 4px;
}
.xmas-auth .xmas-tree { right: 14px; bottom: 6px; width: 150px; }
.xmas-auth .xmas-ground { width: 176px; }
@media (max-width: 1024px) {
    .xmas-auth { display: none; }
    body.desk-page .xmas-corner { display: block; width: 72px; }
}
@media (max-width: 560px) {
    body.desk-page .xmas-corner { width: 58px; }
}

/* ---------- Dark mode: chỉ chỉnh độ sáng/tương phản, không đổi cơ chế ---------- */
body.xmas { --xmas-cap-filter: drop-shadow(0 1px 1px rgba(71, 85, 105, .2)); }
body.xmas.dark_mode {
    --xmas-gold-line: rgba(244, 201, 93, .32);
    --xmas-cap-filter: brightness(.9) drop-shadow(0 1px 2px rgba(0, 0, 0, .45));
}
body.xmas.dark_mode .xmas-snow i {
    width: var(--s);
    height: var(--s);
    background: radial-gradient(circle at 40% 35%, #fff 0, #fff 45%, rgba(226, 234, 246, .85) 100%);
    box-shadow: none;
    opacity: var(--o);
}

/* ---------- Responsive ---------- */
/* ≤1024: sidebar thành drawer (z-index 1001), topbar có nút menu */
/* Cành thông góc màn hình chỉ có ở desktop: từ 1024 trở xuống nút tài khoản sát mép phải, cành sẽ che */
@media (max-width: 1024px) {
    .xmas-tree { width: 128px; }
    .xmas-ground { width: 150px; }
    .xmas-corner { display: none; }
}
@media (max-width: 767px) {
    .xmas-lights { height: 18px; }
}
/* Màn hình thấp: cây chiếm quá nhiều chiều cao sidebar → bỏ cây và phần đệm */
@media (max-height: 620px) {
    .xmas-tree, .xmas-ground { display: none; }
    body.xmas-fx-christmas-tree #kt_aside_menu::after { content: none; }
}

/* ---------- Giảm chuyển động: tắt hẳn tuyết rơi, mọi thứ khác đứng yên ---------- */
@media (prefers-reduced-motion: reduce) {
    .xmas-snow { display: none; }
    .xmas-lights > i, .xmas-corner, .xmas-sky, .xmas-tree-lights, .xmas-tree-star { animation: none; }
}
