/* ============================================================
 * layout.css — เลย์เอาต์หลัก: ส่วนหัว (Topbar/Navbar) + ส่วนท้าย (Footer)
 *                  + โครงหน้ารอง (Page Banner / Main / CTA)
 * ============================================================ */

/* ---------- [1] PRELOADER (โครง + วางตำแหน่ง) ---------- */
.preloader {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 50% 40%, #131c44, var(--bg));
    transition: opacity .5s var(--ease), visibility .5s;
}
.preloader.hide { opacity: 0; visibility: hidden; }
.preloader-inner { text-align: center; }
.preloader-logo { width: 110px; margin: 0 auto 18px; }
.preloader-bar { width: 210px; height: 6px; background: rgba(255,255,255,.1); border-radius: 99px; overflow: hidden; margin: 0 auto; }
.preloader-bar span { display: block; height: 100%; width: 40%; border-radius: 99px; background: var(--grad-main); animation: preloaderSlide 1.1s ease-in-out infinite; }
.preloader p { margin-top: 12px; font-size: .85rem; color: var(--muted); letter-spacing: .08em; }

/* ---------- [2] SCROLL PROGRESS ---------- */
.scroll-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1200; background: transparent; }
.scroll-progress span { display: block; height: 100%; width: 0; background: var(--grad-main); box-shadow: 0 0 12px rgba(247,201,72,.8); transition: width .1s linear; }

/* ---------- [3] TOPBAR ---------- */
.topbar {
    position: relative; z-index: 900;
    background: linear-gradient(90deg, rgba(9,13,32,.96), rgba(20,26,60,.96));
    border-bottom: 1px solid var(--line);
    font-size: .82rem;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: var(--topbar-h); gap: 12px; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.topbar-item { color: var(--txt-2); display: inline-flex; align-items: center; gap: 7px; }
.topbar-item i { color: var(--gold); font-size: .78rem; }
.topbar-item b { color: #fff; font-weight: 600; }
.user-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 1.6s infinite; }
.topbar-right a { color: var(--txt-2); transition: color .25s, transform .25s; display: inline-flex; align-items: center; gap: 6px; }
.topbar-right a:hover { color: var(--gold); transform: translateY(-1px); }

/* ---------- [4] HEADER / NAVBAR ---------- */
.header {
    position: sticky; top: 0; z-index: 1000;
    background: rgba(8, 12, 30, .72);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
    transition: background .3s, box-shadow .3s;
}
.header.scrolled { background: rgba(8, 12, 30, .96); box-shadow: 0 10px 34px rgba(0,0,0,.5); }
.header-inner { display: flex; align-items: center; gap: 18px; min-height: var(--header-h); }

/* แบรนด์ */
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand-logo { width: 46px; height: 46px; filter: drop-shadow(0 4px 14px rgba(247,201,72,.45)); transition: transform .35s var(--ease); }
.brand:hover .brand-logo { transform: rotate(-8deg) scale(1.06); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-en); font-size: 1.06rem; font-weight: 400; color: #fff; letter-spacing: .02em; white-space: nowrap; }
.brand-name i { font-style: normal; color: var(--gold); }
.brand-sub { font-size: .6rem; letter-spacing: .28em; color: var(--muted); font-weight: 500; }

/* เมนู */
.nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.nav-link {
    position: relative; padding: 10px 13px; border-radius: 10px;
    font-size: .93rem; font-weight: 500; color: var(--txt-2);
    transition: color .25s, background .25s;
    white-space: nowrap;
}
.nav-link::after {
    content: ''; position: absolute; left: 13px; right: 13px; bottom: 4px; height: 2.5px;
    background: var(--grad-main); border-radius: 3px;
    transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease);
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-link:hover::after, .nav-link.active::after { transform: scaleX(1); }
.nav-link.active { color: var(--gold); }

/* ปุ่มฝั่งขวา */
.header-actions { display: flex; align-items: center; gap: 10px; margin-left: 12px; }

/* เมนูผู้ใช้ */
.user-menu { position: relative; }
.user-btn {
    display: flex; align-items: center; gap: 9px;
    background: rgba(255,255,255,.06); border: 1px solid var(--line-2);
    padding: 6px 14px 6px 6px; border-radius: 999px; color: #fff;
    font-weight: 500; transition: border-color .25s, background .25s;
}
.user-btn:hover { border-color: var(--gold); background: rgba(247,201,72,.1); }
.user-btn i { font-size: .7rem; color: var(--muted); }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--grad-main); color: #14203f;
    display: grid; place-items: center; font-weight: 700;
}
.user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown {
    position: absolute; top: calc(100% + 12px); right: 0; width: 230px;
    background: var(--panel-solid); border: 1px solid var(--line-2); border-radius: 14px;
    padding: 8px; box-shadow: var(--shadow);
    opacity: 0; visibility: hidden; transform: translateY(10px);
    transition: all .28s var(--ease); z-index: 100;
}
.user-menu.open .user-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.user-dropdown a, .dropdown-logout {
    display: flex; width: 100%; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 9px; font-size: .9rem; color: var(--txt-2);
    transition: background .2s, color .2s; text-align: left;
}
.user-dropdown a i, .dropdown-logout i { width: 17px; color: var(--gold); }
.user-dropdown a:hover, .dropdown-logout:hover { background: rgba(255,255,255,.07); color: #fff; }
.user-dropdown hr { margin: 6px 4px; border-color: var(--line); }
.dropdown-logout { color: var(--red); }
.dropdown-logout i { color: var(--red); }

/* ปุ่มแฮมเบอร์เกอร์ (มือถือ) */
.nav-toggle { display: none; flex-direction: column; gap: 5px; padding: 8px; }
.nav-toggle span { width: 24px; height: 2.5px; background: var(--gold); border-radius: 3px; transition: all .3s var(--ease); }
.nav-toggle.active span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

@media (max-width: 1080px) {
    .nav {
        position: fixed; top: calc(var(--topbar-h) + var(--header-h)); left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 4px;
        background: rgba(9, 13, 34, .98); backdrop-filter: blur(16px);
        border-bottom: 1px solid var(--line-2);
        padding: 14px 18px 22px; margin: 0;
        max-height: 0; overflow: hidden; padding-block: 0;
        transition: max-height .4s var(--ease), padding .3s;
        z-index: 999;
    }
    .nav.open { max-height: 70vh; overflow-y: auto; padding-block: 14px 22px; }
    .nav-link { padding: 13px 14px; font-size: 1rem; }
    .nav-link::after { display: none; }
    .nav-link.active { background: rgba(247,201,72,.12); }
    .nav-toggle { display: flex; }
    .brand-sub { display: none; }
}
@media (max-width: 560px) {
    .brand-name { font-size: .92rem; }
    .user-name { display: none; }
    .user-btn { padding-right: 6px; }
}

/* ---------- [5] FLASH MESSAGES ---------- */
.flash-wrap { position: relative; z-index: 950; padding-top: 18px; }
.flash {
    display: flex; align-items: center; gap: 12px;
    background: var(--panel-solid); border: 1px solid var(--line-2);
    border-left: 4px solid var(--cyan);
    padding: 13px 18px; border-radius: 12px; margin-bottom: 10px;
    box-shadow: var(--shadow); font-size: .93rem;
    animation: flashIn .4s var(--ease);
}
.flash i { flex-shrink: 0; }
.flash-success { border-left-color: var(--green); } .flash-success i { color: var(--green); }
.flash-error   { border-left-color: var(--red); }   .flash-error i { color: var(--red); }
.flash-warn    { border-left-color: var(--orange); } .flash-warn i { color: var(--orange); }
.flash-info    { border-left-color: var(--cyan); }   .flash-info i { color: var(--cyan); }
.flash span { flex: 1; }
.flash-close { color: var(--muted); font-size: 1.3rem; line-height: 1; padding: 0 4px; }
.flash-close:hover { color: #fff; }

/* ---------- [6] PAGE BANNER (หัวหน้ารอง) ---------- */
.page-banner {
    position: relative; overflow: hidden;
    background-size: cover; background-position: center;
    padding: 74px 0 66px;
    border-bottom: 1px solid var(--line);
}
.page-banner-overlay {
    position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(7,11,24,.82), rgba(7,11,24,.68)),
                linear-gradient(90deg, rgba(157,123,255,.20), transparent 60%);
}
.page-banner-inner { position: relative; z-index: 2; text-align: center; }
.breadcrumb { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: .87rem; color: var(--muted); margin-bottom: 14px; }
.breadcrumb a { color: var(--txt-2); transition: color .2s; }
.breadcrumb a:hover { color: var(--gold); }
.bc-sep { opacity: .5; }
.bc-current { color: var(--gold); }
.page-banner-title { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; text-shadow: 0 6px 30px rgba(0,0,0,.6); }
.page-banner-sub { margin-top: 8px; color: var(--txt-2); font-weight: 300; }

/* ---------- [7] MAIN ---------- */
.main { position: relative; z-index: 1; min-height: 50vh; display: block; }

/* ---------- [8] CTA BAND (ก่อน Footer) ---------- */
.cta-band {
    position: relative; overflow: hidden;
    background:
        linear-gradient(120deg, rgba(247,201,72,.14), rgba(157,123,255,.14)),
        var(--bg-2);
    border-block: 1px solid var(--line);
    padding: 54px 0;
}
.cta-band-inner { display: flex; align-items: center; justify-content: space-between; gap: 30px; flex-wrap: wrap; }
.cta-text h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
.cta-text p { color: var(--txt-2); margin-top: 8px; font-weight: 300; max-width: 560px; }
.cta-actions { display: flex; gap: 14px; flex-wrap: wrap; }

/* ---------- [9] FOOTER ---------- */
.footer { position: relative; background: linear-gradient(180deg, #0a1026, #070b18); }
.footer-wave { position: relative; height: 70px; margin-top: -1px; color: var(--bg-2); overflow: hidden; }
.footer-wave svg { position: absolute; bottom: -1px; width: 100%; height: 100%; }
.footer-wave::after {
    content: ''; position: absolute; inset: auto 0 0 0; height: 70px;
    background: linear-gradient(180deg, transparent, rgba(247,201,72,.05));
}
.footer-grid {
    display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.2fr; gap: 36px;
    padding: 26px 20px 44px;
}
.footer-brand .brand-logo { width: 54px; height: 54px; }
.footer-desc { color: var(--muted); font-size: .9rem; font-weight: 300; margin-top: 16px; }
.footer-social { display: flex; gap: 10px; margin-top: 18px; }
.footer-social a {
    width: 40px; height: 40px; border-radius: 12px;
    display: grid; place-items: center;
    background: rgba(255,255,255,.05); border: 1px solid var(--line);
    color: var(--txt-2); transition: all .3s var(--ease);
}
.footer-social a:hover { background: var(--grad-main); color: #14203f; transform: translateY(-5px); box-shadow: 0 10px 24px rgba(247,201,72,.35); }
.footer-title { font-size: 1.02rem; margin-bottom: 18px; color: #fff; display: flex; align-items: center; gap: 9px; }
.footer-title i { color: var(--gold); }
.footer-links li { margin-bottom: 10px; }
.footer-links a { color: var(--txt-2); font-size: .92rem; transition: all .25s; position: relative; padding-left: 0; }
.footer-links a::before { content: '▸'; position: absolute; left: -16px; opacity: 0; color: var(--gold); transition: all .25s; }
.footer-links a:hover { color: var(--gold); padding-left: 16px; }
.footer-links a:hover::before { opacity: 1; left: 0; }
.footer-info li { display: flex; gap: 11px; align-items: flex-start; color: var(--txt-2); font-size: .9rem; margin-bottom: 12px; }
.footer-info i { color: var(--gold); width: 17px; margin-top: 5px; text-align: center; }
.copyable { cursor: pointer; color: #fff; }
.copyable:hover { color: var(--gold); }
.copyable i { font-size: .8rem; }
.footer-bottom { border-top: 1px solid var(--line); padding: 18px 0; }
.footer-bottom-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .84rem; color: var(--muted); }
.footer-meta { display: flex; align-items: center; gap: 10px; }
.footer-meta a { color: var(--muted); transition: color .2s; }
.footer-meta a:hover { color: var(--gold); }

@media (max-width: 980px) {
    .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
    .footer-grid { grid-template-columns: 1fr; gap: 28px; }
    .cta-band-inner { flex-direction: column; align-items: flex-start; }
    .page-banner { padding: 52px 0 44px; }
}

/* ---------- [10] BACK TO TOP ---------- */
.back-to-top {
    position: fixed; right: 22px; bottom: 22px; z-index: 1100;
    width: 48px; height: 48px; border-radius: 14px;
    background: var(--grad-main); color: #14203f; font-size: 1.1rem;
    display: grid; place-items: center;
    box-shadow: 0 12px 30px rgba(247,201,72,.4);
    opacity: 0; visibility: hidden; transform: translateY(20px);
    transition: all .35s var(--ease);
}
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { transform: translateY(-6px) scale(1.06); }

/* ---------- [announce] แถบประกาศ (ตั้งค่าได้จากหน้าแอดมิน) ---------- */
.announce-bar { background: linear-gradient(90deg, rgba(247,201,72,.10), rgba(90,209,255,.08), rgba(247,201,72,.10)); border-bottom: 1px solid rgba(247,201,72,.28); }
.announce-bar .container { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 9px 0; }
.announce-bar i { color: var(--cyan); animation: ann-pulse 1.6s ease-in-out infinite; }
.announce-bar span { color: var(--gold-2); font-size: .87rem; font-weight: 600; text-align: center; }
@keyframes ann-pulse { 0%,100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.2); opacity: 1; } }
