/* ============================================================
   มหาอาคม (Mahaakhom) — Theme: Gold x Old Rose x Soft Grey
   ฟอนต์: Chakra Petch (โหลดจาก Google Fonts ในไฟล์ header ไม่ต้องอัปโหลดเอง)
   ============================================================ */

:root {
    --gold: #C9A24B;
    --gold-dark: #9C7A2E;
    --gold-light: #E8D9AE;
    --old-rose: #B67B77;
    --rose-light: #F3D9D7;
    --grey-light: #F4F3F1;
    --grey: #6E6A66;
    --dark: #2B2320;
    --white: #FFFFFF;
    --radius: 16px;
    --shadow: 0 4px 16px rgba(43, 35, 32, 0.12);
    --nav-height: 64px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Chakra Petch', 'Sarabun', 'Kanit', sans-serif;
    background: linear-gradient(180deg, var(--grey-light) 0%, #fff 220px);
    color: var(--dark);
    padding-bottom: calc(var(--nav-height) + 12px);
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ---------- Top bar ---------- */
.topbar {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}
.topbar .logo-img { width: 40px; height: 40px; border-radius: 50%; background: #fff; object-fit: cover; }
.topbar .site-title {
    font-family: 'Chakra Petch', 'Sarabun', sans-serif;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: .5px;
    line-height: 1.1;
}
.topbar .slogan { font-size: 12px; opacity: .9; font-family: 'Chakra Petch', 'Sarabun', sans-serif; }

/* ใช้กับข้อความโลโก้ "มหาอาคม" ทุกจุดที่ต้องการความเป็นแบรนด์ (เช่น หน้า login, footer, hero) */
.brand-logo-text {
    font-family: 'Chakra Petch', 'Sarabun', sans-serif;
    font-weight: 600;
}

/* ---------- Bottom App-like navigation (mobile) ---------- */
.app-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: var(--nav-height);
    background: #fff;
    border-top: 1px solid var(--rose-light);
    display: flex;
    z-index: 100;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
}
.app-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--grey);
    gap: 4px;
}
.app-nav a.active { color: var(--old-rose); font-weight: 700; }
.app-nav .icon { font-size: 20px; }

@media (min-width: 900px) {
    .app-nav { display: none; }
    body { padding-bottom: 0; }
    .desktop-nav {
        display: flex; gap: 24px; margin-left: auto; font-size: 15px;
    }
    .desktop-nav a.active { border-bottom: 2px solid #fff; }
    .mobile-menu-toggle, .mobile-nav-panel { display: none; }
}
@media (max-width: 899px) {
    .desktop-nav { display: none; }
}

/* ---------- Mobile hamburger menu (ไม่กระทบเวอร์ชันเดสก์ท็อป) ---------- */
.mobile-menu-toggle {
    margin-left: auto;
    width: 40px; height: 40px;
    background: rgba(255,255,255,.15);
    border: none;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    flex-shrink: 0;
}
.mobile-menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform .2s ease, opacity .2s ease;
}
.mobile-menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-menu-toggle.open span:nth-child(2) { opacity: 0; }
.mobile-menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-nav-panel {
    display: none;
    flex-direction: column;
    background: #fff;
    border-bottom: 1px solid var(--rose-light);
    box-shadow: 0 6px 16px rgba(0,0,0,.08);
    position: sticky;
    top: 0;
    z-index: 49;
}
.mobile-nav-panel.open { display: flex; }
.mobile-nav-panel a {
    padding: 14px 20px;
    border-bottom: 1px solid var(--grey-light);
    font-size: 15px;
    color: var(--dark);
}
.mobile-nav-panel a.active { color: var(--old-rose); font-weight: 700; }
.mobile-nav-panel a:last-child { border-bottom: none; }

/* ---------- Cards ---------- */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--rose-light);
}
.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, 1fr);
    margin: 16px 0;
}
@media (min-width: 700px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.product-card .cover { aspect-ratio: 1/1; object-fit: cover; width: 100%; background: var(--grey-light); }
.product-card .body { padding: 10px 12px; }
.product-card .name { font-weight: 700; font-size: 14px; margin: 0 0 4px; }
.product-card .price { color: var(--old-rose); font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: #fff;
    border: none;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}
.btn.secondary { background: linear-gradient(135deg, var(--old-rose), #C99490); }
.btn.outline { background: none; border: 1px solid var(--gold); color: var(--gold-dark); }
.btn.block { display: block; width: 100%; text-align: center; }
.btn.small { padding: 6px 14px; font-size: 13px; }
.btn.danger { background: #B0413E; }

/* ---------- Sections ---------- */
.section-title {
    font-size: 20px;
    font-weight: 700;
    margin: 24px 0 12px;
    color: var(--gold-dark);
    border-left: 4px solid var(--old-rose);
    padding-left: 10px;
}

.hero {
    position: relative;
    text-align: center;
    padding: 32px 16px;
    background: radial-gradient(circle at top, var(--rose-light), transparent 70%);
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: min(90vw, 640px);
    aspect-ratio: 1 / 1;
    transform: translate(-50%, -50%);
    background-image: url('../images/hero-bg-dome.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.2;
    pointer-events: none;
    z-index: 0;
}
.hero > * {
    position: relative;
    z-index: 1;
}
.hero h1 {
    font-family: 'Chakra Petch', 'Sarabun', sans-serif;
    font-size: 36px;
    font-weight: 700;
    color: var(--gold-dark);
    margin: 8px 0;
}
.hero p { color: var(--grey); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--grey); font-weight: 700; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=date], input[type=number], textarea, select {
    width: 100%;
    padding: 11px 14px;
    border-radius: 12px;
    border: 1px solid #ddd;
    font-family: inherit;
    font-size: 14px;
    background: #fff;
}
textarea { min-height: 100px; resize: vertical; }
.auth-box {
    max-width: 420px; margin: 24px auto; padding: 24px;
}

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-size: 14px; }
.alert.success { background: #E4F3E7; color: #2E7D40; }
.alert.error { background: #FBE4E2; color: #B0413E; }

/* ---------- Gallery / Lightbox ---------- */
.gallery-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; }
.gallery-thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; cursor: pointer; border: 2px solid transparent; }
.gallery-thumbs img.active { border-color: var(--old-rose); }
.lightbox-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.85);
    display: none; align-items: center; justify-content: center; z-index: 999;
    touch-action: none;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img { max-width: 92vw; max-height: 80vh; transition: transform .15s ease; cursor: grab; }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.2); color: #fff; border: none; font-size: 24px; padding: 10px 14px; border-radius: 50%; cursor: pointer; }
.lightbox-nav.prev { left: 12px; } .lightbox-nav.next { right: 12px; }
.lightbox-close { position: absolute; top: 16px; right: 16px; color: #fff; font-size: 28px; background: none; border: none; cursor: pointer; }

/* ---------- Admin ---------- */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 220px; background: var(--dark); color: #eee; flex-shrink: 0;
    padding: 16px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-sidebar a { display: block; padding: 12px 20px; color: #d8cfc4; font-size: 14px; }
.admin-sidebar a.active, .admin-sidebar a:hover { background: rgba(201,162,75,.2); color: var(--gold); }
.admin-content { flex: 1; padding: 24px; background: var(--grey-light); }
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid #eee; font-size: 13px; text-align: left; }
.table th { background: var(--grey-light); color: var(--grey); }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.pending { background: #FFF3CD; color: #8A6D00; }
.badge.approved { background: #E4F3E7; color: #2E7D40; }
.badge.rejected { background: #FBE4E2; color: #B0413E; }
.badge.shipped { background: #DDEBFA; color: #2A5D8A; }

@media (max-width: 899px) {
    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; height: auto; position: static; display: flex; overflow-x: auto; }
    .admin-sidebar a { white-space: nowrap; }
}

/* ---------- Cookie consent banner ---------- */
.cookie-banner {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
    background: var(--dark);
    color: #f2ede4;
    padding: 14px 16px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 -4px 16px rgba(0,0,0,.25);
}
.cookie-banner p { margin: 0; font-size: 12.5px; line-height: 1.7; }
.cookie-banner a { color: var(--gold); text-decoration: underline; }
.cookie-banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (min-width: 900px) {
    .cookie-banner { bottom: 0; flex-direction: row; align-items: center; justify-content: space-between; gap: 20px; }
    .cookie-banner p { flex: 1; }
    .cookie-banner-actions { flex-shrink: 0; }
}

/* ---------- แถบแชร์โซเชียล (Facebook / LINE / X / Instagram / Discord) ---------- */
.share-bar {
    max-width: 1100px;
    margin: 8px auto 0;
    padding: 14px 16px 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.share-bar-label {
    font-size: 13px;
    color: var(--grey);
    margin-right: 2px;
}
.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: transform .15s ease, opacity .15s ease;
    text-decoration: none;
}
.share-btn:hover { transform: translateY(-2px); opacity: .92; }
.share-fb { background: #1877F2; }
.share-line { background: #06C755; }
.share-x { background: #000; }
.share-ig { background: radial-gradient(circle at 30% 110%, #FFDD55 0%, #FF543E 30%, #C837AB 60%, #5851DB 90%); }
.share-discord { background: #5865F2; }

.share-toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-height) + 20px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%) translateY(10px);
    background: var(--dark);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}
.share-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 900px) {
    .share-toast { bottom: 24px; }
}
