/* =====================================================================
   Theme Tết Nguyên Đán - trang khách (body.view-user), admin + boss (body.view-admin), landing,
   trang đăng nhập / đăng ký / quên mật khẩu. Markup: views/panel/components/tet.ejs.
   Bật/tắt: Cài đặt → Giao diện Tết (domain.data.tet); từng hiệu ứng: TET_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.tet-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ó trang trí).
   Hoạ tiết mây vàng nằm sẵn trong peach-corner.svg / apricot-corner.svg, không có lớp riêng.
   ===================================================================== */

body.tet {
    --tet-red: #C81D25;
    --tet-deep-red: #9F1720;
    --tet-gold: #E9AC35;
    --tet-light-gold: #F8D98B;
    --tet-peach: #F3A3B5;
    --tet-apricot: #F5C542;
    --tet-gold-line: rgba(233, 172, 53, .5);
}

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

/* ---------- Dây đèn lồng mép trên ---------- */
.tet-garland {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    z-index: 100;
}
.tet-cord {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 13px;
    background: url(images/cord.svg) repeat-x 0 0 / 120px 13px;
}
.tet-lantern {
    position: absolute;
    top: 7px;
    /* Cỡ 50% so với bản đầu (30x48) để không che nội dung header */
    width: 15px;
    height: 24px;
    transform-origin: 50% -6px;
}
.tet-lantern img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 3px rgba(159, 23, 32, .3));
}
/* Mỗi đèn 1 vị trí + nhịp đung đưa riêng để không lắc đồng loạt */
.tet-lantern:nth-of-type(1) { left: 4%; }
.tet-lantern:nth-of-type(2) { left: 19%; top: 11px; }
.tet-lantern:nth-of-type(3) { left: 34%; }
.tet-lantern:nth-of-type(4) { left: 49%; top: 10px; }
.tet-lantern:nth-of-type(5) { left: 64%; }
.tet-lantern:nth-of-type(6) { left: 78%; top: 11px; }
.tet-lantern:nth-of-type(7) { left: 92%; }
body.tet-fx-lanterns:not(.tet-fx-lanterns-static) .tet-lantern { animation: tet-swing 5s ease-in-out infinite alternate; }
body.tet-fx-lanterns:not(.tet-fx-lanterns-static) .tet-lantern:nth-of-type(2n) { animation-duration: 6.2s; animation-delay: -2.1s; }
body.tet-fx-lanterns:not(.tet-fx-lanterns-static) .tet-lantern:nth-of-type(3n) { animation-duration: 7s; animation-delay: -3.4s; }
body.tet-fx-lanterns:not(.tet-fx-lanterns-static) .tet-lantern:nth-of-type(3n+1) { animation-delay: -1.2s; }
@keyframes tet-swing {
    from { transform: rotate(4deg); }
    to { transform: rotate(-4deg); }
}

/* Trang có sidebar: dây đèn nhường chỗ cho logo / nút menu như dây đèn Noel.
   Landing / đăng nhập không có sidebar: chạy hết bề ngang. */
body.view-user .tet-garland { left: 48px; }
body.view-admin .tet-garland { left: 56px; }
@media (min-width: 1025px) {
    body:is(.view-user, .view-admin) .tet-garland { left: 288px; }
}

/* ---------- Cành mai góc trên phải, cành đào góc trên trái màn hình ---------- */
.tet-corner {
    position: fixed;
    top: 0;
    right: 0;
    width: 165px;
    height: auto;
    z-index: 100;
    transform-origin: 100% 0;
    filter: drop-shadow(0 2px 3px rgba(122, 74, 43, .25));
    animation: tet-sway 7s ease-in-out infinite;
}
@keyframes tet-sway {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-1.6deg); }
}
/* Cành đào góc trái: chỉ trang không có sidebar, góc đó ở trang khách / admin là logo */
.tet-corner--left {
    right: auto;
    left: 0;
    transform-origin: 0 0;
    animation-name: tet-sway-left;
}
@keyframes tet-sway-left {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(1.6deg); }
}
body:is(.view-user, .view-admin) .tet-corner--left { display: none; }

/* ---------- Lấp lánh vàng (vài điểm sáng cố định) ---------- */
.tet-sparkles i {
    position: fixed;
    width: 7px;
    height: 7px;
    z-index: 99;
    background: radial-gradient(circle, #FFE9B3 0, rgba(245, 197, 66, .8) 40%, rgba(245, 197, 66, 0) 75%);
    border-radius: 50%;
    animation: tet-twinkle 4.6s ease-in-out infinite;
}
.tet-sparkles i:nth-child(1) { top: 14%; right: 12%; }
.tet-sparkles i:nth-child(2) { top: 8%; right: 30%; animation-delay: -1.1s; }
.tet-sparkles i:nth-child(3) { top: 22%; right: 4%; animation-delay: -2.3s; }
.tet-sparkles i:nth-child(4) { top: 10%; left: 36%; animation-delay: -3.2s; }
.tet-sparkles i:nth-child(5) { top: 26%; left: 46%; animation-delay: -1.8s; }
.tet-sparkles i:nth-child(6) { top: 6%; right: 44%; animation-delay: -3.9s; }
@keyframes tet-twinkle {
    0%, 100% { opacity: .15; transform: scale(.7); }
    50% { opacity: 1; transform: scale(1.25); }
}

/* ---------- Hoa đào / hoa mai rơi (cánh do tet.js tạo) ---------- */
.tet-petals {
    position: fixed;
    inset: 0;
    z-index: 99;
    overflow: hidden;
    contain: strict;
}
.tet-petals i {
    position: absolute;
    top: -16px;
    left: 0;
    width: var(--s);
    height: calc(var(--s) * 1.25);
    /* Hình cánh hoa: 2 góc đối bo tròn hết cỡ */
    border-radius: 100% 8% 100% 8%;
    background: linear-gradient(135deg, #F8C7D4 0, var(--tet-peach) 60%, #E98BA2 100%);
    box-shadow: 0 0 0 .5px rgba(201, 90, 120, .25);
    opacity: var(--o);
    rotate: var(--r);
    translate: var(--x) -16px;
    animation: tet-fall var(--d) linear var(--dl) infinite,
               tet-drift var(--sd) ease-in-out var(--dl) infinite alternate,
               tet-spin calc(var(--sd) * 2) linear var(--dl) infinite;
    will-change: transform, translate, rotate;
}
.tet-petals i.tet-gold {
    background: linear-gradient(135deg, #FBE29B 0, var(--tet-apricot) 60%, #E3A818 100%);
    box-shadow: 0 0 0 .5px rgba(199, 127, 19, .3);
}
@keyframes tet-fall {
    from { translate: var(--x) -16px; }
    to { translate: var(--x) calc(100vh + 28px); }
}
@keyframes tet-drift {
    from { transform: translateX(calc(var(--sw) * -1)); }
    to { transform: translateX(var(--sw)); }
}
@keyframes tet-spin {
    from { rotate: var(--r); }
    to { rotate: calc(var(--r) + 360deg); }
}
/* 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.tet-paused .tet-page *,
html.tet-paused .tet-sb * { animation-play-state: paused !important; }

/* ---------- Sidebar: lớp nền sau menu (z-index -1 trong stacking context của #kt_aside) ---------- */
.tet-sb {
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}
/* Quầng sáng ấm cuối sidebar làm nền cho cây quất */
.tet-sb-glow {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 300px;
    background: radial-gradient(130% 75% at 62% 100%, rgba(233, 172, 53, .22) 0, rgba(200, 29, 37, .08) 45%, rgba(233, 172, 53, 0) 75%);
    animation: tet-glow 6s ease-in-out infinite;
}
@keyframes tet-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: .55; }
}

/* Cây quất 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. */
.tet-kumquat {
    position: absolute;
    right: 8px;
    bottom: 2px;
    width: 148px;
    /* Mờ bớt để mục menu cuối cuộn qua vẫn đọc rõ chữ */
    opacity: .5;
}
.tet-kumquat img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .35));
}
/* Bao lì xì + đồng xu cạnh gốc quất */
.tet-envelopes {
    position: absolute;
    left: 4px;
    bottom: 2px;
    width: 92px;
    height: auto;
    opacity: .5;
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .35));
}
body.tet-fx-kumquat-tree #kt_aside_menu::after {
    content: "";
    display: block;
    height: 175px;
}

/* Cành đào góc trên phải sidebar (khoảng trống cạnh logo), lật ngang để bám mép phải */
.tet-sb-corner {
    position: absolute;
    top: 0;
    right: 0;
    width: 104px;
    height: auto;
    z-index: 1;
    transform: scaleX(-1);
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35));
}

/* ---------- Hoa đào nhỏ trên nút menu mobile (chỗ mũ Noel của theme Noel) ---------- */
body.tet-fx-blossoms.view-user .topbar-v2 #tb-burger,
body.tet-fx-blossoms.view-admin #admBurger { position: relative; overflow: visible; }
body.tet-fx-blossoms.view-user .topbar-v2 #tb-burger::after,
body.tet-fx-blossoms.view-admin #admBurger::after {
    content: "";
    position: absolute;
    right: -9px;
    top: -9px;
    width: 26px;
    height: 26px;
    background: url(images/blossom-mini.svg) no-repeat center / contain;
    filter: drop-shadow(0 1px 2px rgba(15, 23, 42, .25));
    pointer-events: none;
}

/* ---------- Card: viền vàng kim + hoa mai góc trên phải + sóng vàng đáy ----------
   Danh sách card lấy nguyên từ theme Noel (assets/christmas/christmas.css, đã dò trên ~84 trang
   khách, chỉ lấy card ngoài cùng, card nằm trong card khác tự bị loại ở :not).
   Cách 1 (đa số): ::before = viền vàng, ::after = lớp phủ inset:0 chỉ vẽ hoạ tiết ở góc
   (bo theo border-radius của card, pointer-events none nên không chặn thao tác).
   Card đã dùng hết pseudo hoặc overflow:hidden (cách 2/3 của Noel): chỉ viền vàng bằng outline. */
body:is(.tet-fx-card-decoration, .tet-fx-golden-waves) .hl-shell :is(.hl-home .card, .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, .card.has-shadow):not(.pw-card--stat, .hl-home .acc-card, .prices-v2 .svc, .ref-v2 .rpanel, .ref-v2 .ref-hero, .payment-v2 #panel-bank .card-collapsible, .modal *, :is(.hl-home .card, .content-container, .pw-card, .cd-card, .prices-v2 .panel, .profile-card, .profile-block, .card-pad, .ref-v2 .rpanel) *) {
    position: relative;
}
body.tet-fx-card-decoration .hl-shell :is(.hl-home .card, .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, .card.has-shadow):not(.pw-card--stat, .hl-home .acc-card, .prices-v2 .svc, .ref-v2 .rpanel, .ref-v2 .ref-hero, .payment-v2 #panel-bank .card-collapsible, .modal *, :is(.hl-home .card, .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(--tet-gold-line);
    box-shadow: 0 0 10px rgba(233, 172, 53, .08);
    pointer-events: none;
}
body.tet-fx-golden-waves .hl-shell :is(.hl-home .card, .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, .card.has-shadow):not(.pw-card--stat, .hl-home .acc-card, .prices-v2 .svc, .ref-v2 .rpanel, .ref-v2 .ref-hero, .payment-v2 #panel-bank .card-collapsible, .modal *, :is(.hl-home .card, .content-container, .pw-card, .cd-card, .prices-v2 .panel, .profile-card, .profile-block, .card-pad, .ref-v2 .rpanel) *)::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    border-radius: inherit;
    background:
        url(images/apricot-corner.svg) no-repeat right -26px top -16px / 118px auto,
        url(images/gold-waves.svg) no-repeat right 10px bottom -4px / 190px auto;
    opacity: var(--tet-card-opacity, .95);
    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:is(.tet-fx-card-decoration, .tet-fx-golden-waves) .hl-shell :is(.pw-card--stat, .hl-home .acc-card, .prices-v2 .svc, .ref-v2 .rpanel, .ref-v2 .ref-hero, .payment-v2 #panel-bank .card-collapsible) {
    outline: 1px solid var(--tet-gold-line);
    outline-offset: -1px;
}

/* ---------- Admin + boss (views/admin/layout.ejs, views/boss/layout.ejs, body.view-admin) ----------
   Cùng khung sidebar với trang khách nên dùng chung mọi lớp, chỉ khác:
   - Nút menu mobile là #admBurger (hoa đào ở rule #tb-burger phía trên).
   - Không có .hl-shell: viền vàng + hoạ tiết đặt trên khung trắng ngoài cùng của từng trang
     (.content-container con trực tiếp của #kt_content > .kt-container), như cách 1. */
body.view-admin:is(.tet-fx-card-decoration, .tet-fx-golden-waves) #kt_content > .kt-container > .content-container { position: relative; }
body.tet-fx-card-decoration.view-admin #kt_content > .kt-container > .content-container::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid var(--tet-gold-line);
    pointer-events: none;
}
body.tet-fx-golden-waves.view-admin #kt_content > .kt-container > .content-container::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    border-radius: inherit;
    background:
        url(images/apricot-corner.svg) no-repeat right -26px top -16px / 118px auto,
        url(images/gold-waves.svg) no-repeat right 10px bottom -4px / 190px auto;
    opacity: var(--tet-card-opacity, .95);
    pointer-events: none;
}

/* ---------- Landing + trang đăng nhập / đăng ký / quên mật khẩu ----------
   Không có sidebar: dây đèn chạy hết bề ngang, cành mai / đào ở cả 2 góc trên.
   - Hoa đào nhỏ cài lên logo .au-brand của các mẫu đăng nhập (kit chung, .au-brand đều static).
   - Khung đăng nhập cũ (.wrap-login100, overflow:hidden): chỉ viền vàng bằng outline,
     không vẽ hoạ tiết vì mỗi mẫu có nền riêng. */
body.tet-fx-blossoms.au .au-brand { position: relative; }
body.tet-fx-blossoms.au .au-brand::after {
    content: "";
    position: absolute;
    left: 24px;
    top: -14px;
    width: 30px;
    height: 30px;
    background: url(images/blossom-mini.svg) no-repeat center / contain;
    filter: drop-shadow(0 1px 2px rgba(15, 23, 42, .3));
    pointer-events: none;
}
body.auth-page:is(.tet-fx-card-decoration, .tet-fx-golden-waves) .wrap-login100 {
    outline: 1px solid var(--tet-gold-line);
    outline-offset: -1px;
}

/* ---------- Dark mode: chỉ chỉnh độ sáng/tương phản, không đổi cơ chế ---------- */
body.tet.dark_mode {
    --tet-gold-line: rgba(245, 197, 66, .32);
    --tet-card-opacity: .75;
}
body.tet.dark_mode .tet-sb-glow { opacity: .7; }

/* ---------- Responsive ---------- */
/* ≤1024: sidebar thành drawer (z-index 1001), topbar có nút menu */
/* Cành hoa 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) {
    .tet-corner { display: none; }
    .tet-kumquat { width: 132px; }
    .tet-envelopes { width: 80px; }
    .tet-sparkles i:nth-child(n+4) { display: none; }
}
@media (max-width: 767px) {
    .tet-garland { height: 28px; }
    .tet-cord { height: 8px; background-size: 80px 8px; }
    /* Đèn nhỏ 50% để không che icon / chữ trên header mobile */
    .tet-lantern { width: 11px; height: 18px; top: 4px; }
    .tet-lantern:nth-of-type(2), .tet-lantern:nth-of-type(4), .tet-lantern:nth-of-type(6) { top: 6px; }
    .tet-lantern:nth-of-type(7) { display: none; }
    body.tet-fx-golden-waves .hl-shell :is(.hl-home .card, .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, .card.has-shadow)::after,
    body.tet-fx-golden-waves.view-admin #kt_content > .kt-container > .content-container::after {
        background-size: 92px auto, 150px auto;
    }
}
/* Màn hình thấp: cây chiếm quá nhiều chiều cao sidebar → bỏ cây, lì xì và phần đệm */
@media (max-height: 620px) {
    .tet-kumquat, .tet-envelopes, .tet-sb-glow { display: none; }
    body.tet-fx-kumquat-tree #kt_aside_menu::after { content: none; }
}

/* ---------- Giảm chuyển động: tắt hẳn hoa rơi, mọi thứ khác đứng yên ---------- */
@media (prefers-reduced-motion: reduce) {
    .tet-petals { display: none; }
    .tet-lantern, .tet-corner, .tet-sparkles i, .tet-sb-glow { animation: none; }
}
