/* =============================================================================
   shop-themes.css
   Theme overrides + dark-mode readability + brand-intermission carousel
   --------------------------------------------------------------------
   ใช้ CSS variables ที่ inject จาก _Layout.cshtml :
     --shop-bg, --shop-surface, --shop-ink, --shop-sub,
     --shop-primary, --shop-secondary, --shop-border, --shop-muted,
     --shop-on-primary  (text สี contrast กับ primary — dark/light)
   --------------------------------------------------------------------
   class flow:
     body.shop-themed       = ทุก template ที่ไม่ใช่ Classic
     body.theme-<key>       = theme key (sakura, mint, charcoal, ...)
     body.theme-dark        = themes ดาร์ก (indigo, cyber, charcoal)
     body.tpl-<key>         = template key — ดู shop-templates.css
   ============================================================================= */

body.shop-themed { background: var(--shop-bg) !important; color: var(--shop-ink); }
body.shop-themed footer { background: var(--shop-surface) !important; color: var(--shop-sub); border-top: 1px solid var(--shop-border); }
body.shop-themed a { color: var(--shop-primary); }
body.shop-themed a:hover { color: var(--shop-secondary); }

/* Bootstrap button overrides */
body.shop-themed .btn-primary,
body.shop-themed .btn-success,
body.shop-themed .btn-warning {
    background: var(--shop-primary) !important;
    border-color: var(--shop-primary) !important;
    color: var(--shop-on-primary) !important;
}
body.shop-themed .btn-primary:hover,
body.shop-themed .btn-success:hover,
body.shop-themed .btn-warning:hover { background: var(--shop-secondary) !important; border-color: var(--shop-secondary) !important; }
body.shop-themed .btn-outline-primary,
body.shop-themed .btn-outline-secondary,
body.shop-themed .btn-outline-success {
    color: var(--shop-primary) !important;
    border-color: var(--shop-primary) !important;
    background: transparent !important;
}
body.shop-themed .btn-outline-primary:hover,
body.shop-themed .btn-outline-secondary:hover,
body.shop-themed .btn-outline-success:hover {
    background: var(--shop-primary) !important;
    color: var(--shop-on-primary) !important;
}

/* Cards / panels */
body.shop-themed .card,
body.shop-themed .card-body {
    background: var(--shop-surface) !important;
    border-color: var(--shop-border) !important;
    color: var(--shop-ink) !important;
}
body.shop-themed .card .text-muted,
body.shop-themed .card small,
body.shop-themed .text-muted { color: var(--shop-sub) !important; }

/* Form controls */
body.shop-themed .form-control,
body.shop-themed .form-select {
    background: var(--shop-surface);
    border-color: var(--shop-border);
    color: var(--shop-ink);
}
body.shop-themed .form-control:focus,
body.shop-themed .form-select:focus { border-color: var(--shop-primary); box-shadow: 0 0 0 .15rem rgba(0,0,0,.06); }

/* Tables */
body.shop-themed .table { color: var(--shop-ink); }
body.shop-themed .table thead th { background: var(--shop-bg); color: var(--shop-sub); border-color: var(--shop-border); }
body.shop-themed .table tbody td { border-color: var(--shop-border); }

/* Badge variants */
body.shop-themed .badge.bg-primary { background: var(--shop-primary) !important; }
body.shop-themed .badge.bg-success { background: var(--shop-secondary) !important; }

/* Top nav (.fixed-top) — keep readable on dark themes */
body.shop-themed.theme-dark nav.fixed-top { background-color: var(--shop-surface) !important; background-image: none !important; }
body.shop-themed.theme-dark nav.fixed-top a,
body.shop-themed.theme-dark nav.fixed-top span,
body.shop-themed.theme-dark nav.fixed-top div { color: var(--shop-ink) !important; }

/* === Dark theme readability overrides ===
   Index/Category/Product views มี inline-style "color:Black", "color:dimgrey",
   "color:cadetblue", "background-color:whitesmoke" ฯลฯ ที่ไม่ได้รับ CSS vars
   ใช้ attribute selector + !important บังคับให้กลับด้านบน dark themes */
body.theme-dark { color: var(--shop-ink); }
body.theme-dark #productGrid .moreBox,
body.theme-dark #productGrid .moreBox h1,
body.theme-dark #productGrid .moreBox h2,
body.theme-dark #productGrid .moreBox h3,
body.theme-dark #productGrid .moreBox h4,
body.theme-dark #productGrid .moreBox h5,
body.theme-dark #productGrid .moreBox h6,
body.theme-dark #productGrid .moreBox p,
body.theme-dark #productGrid .moreBox span,
body.theme-dark #productGrid .moreBox div,
body.theme-dark #productGrid .moreBox a,
body.theme-dark #productGrid .moreBox b,
body.theme-dark #productGrid .moreBox label { color: var(--shop-ink) !important; }
/* override inline "color:Black/black" */
body.theme-dark [style*="color:Black"],
body.theme-dark [style*="color: Black"],
body.theme-dark [style*="color:black"],
body.theme-dark [style*="color: black"],
body.theme-dark [style*="color:#000"],
body.theme-dark [style*="color: #000"] { color: var(--shop-ink) !important; }
/* override "color:dimgrey/DimGray" */
body.theme-dark [style*="color:dimgrey"],
body.theme-dark [style*="color: dimgrey"],
body.theme-dark [style*="color:DimGray"],
body.theme-dark [style*="color:DimGrey"],
body.theme-dark [style*="color:dimgray"] { color: var(--shop-sub) !important; }
/* override "color:cadetblue" → ใช้ secondary (มักเป็น lighter accent) */
body.theme-dark [style*="color:cadetblue"],
body.theme-dark [style*="color: cadetblue"],
body.theme-dark [style*="color:CadetBlue"] { color: var(--shop-secondary) !important; }
/* override "background-color:whitesmoke" บน <select> และ <input> */
body.theme-dark [style*="background-color:whitesmoke"],
body.theme-dark [style*="background: whitesmoke"],
body.theme-dark [style*="background-color:WhiteSmoke"],
body.theme-dark [style*="background:#f5f5f5"] {
    background-color: var(--shop-surface) !important;
    color: var(--shop-ink) !important;
}
/* override "background-color:white"/"#fff" บน element (ไม่เอา .moreBox เพราะ surface ตั้งไว้แล้ว) */
body.theme-dark [style*="background-color:white"]:not(.moreBox),
body.theme-dark [style*="background: white"]:not(.moreBox),
body.theme-dark [style*="background-color:#fff"]:not(.moreBox),
body.theme-dark [style*="background-color: #fff"]:not(.moreBox),
body.theme-dark [style*="background-color:#FFF"]:not(.moreBox) {
    background-color: var(--shop-surface) !important;
    color: var(--shop-ink) !important;
}
/* Bootstrap form-control / form-select บน dark theme */
body.theme-dark select,
body.theme-dark input[type=text],
body.theme-dark input[type=number],
body.theme-dark input[type=email],
body.theme-dark input[type=tel],
body.theme-dark input[type=password],
body.theme-dark input[type=search],
body.theme-dark textarea,
body.theme-dark .form-select,
body.theme-dark .form-control,
body.theme-dark .form-select-sm {
    background-color: var(--shop-surface) !important;
    color: var(--shop-ink) !important;
    border-color: var(--shop-border) !important;
}
body.theme-dark select option { background: var(--shop-surface); color: var(--shop-ink); }

/* Brand-hashtag images (พื้นหลังโปร่งใส) — ปรับ contrast ให้ดูชัดบน dark */
body.theme-dark .brand-hashtag-first .brand-hashtag,
body.theme-dark .brand-hashtag-second .brand-hashtag,
body.theme-dark .subbrand-hashtag { filter: brightness(1.05) drop-shadow(0 0 6px rgba(255,255,255,.05)); }

/* dark theme — link color สว่างขึ้น */
body.theme-dark a { color: var(--shop-secondary); }
body.theme-dark a:hover { color: var(--shop-primary); }

/* Footer dark */
body.theme-dark footer { background: var(--shop-surface) !important; color: var(--shop-sub) !important; }
body.theme-dark footer a, body.theme-dark footer span, body.theme-dark footer div { color: var(--shop-sub) !important; }

/* Brand hashtag area surface */
body.shop-themed #Brand,
body.shop-themed #SubBrand { background: transparent; }

/* ============================================================
   TILE MODE — non-Classic templates เท่านั้น
   Classic = ไม่มี class shop-themed → ทุก rule ที่นี่ไม่กระทบ
   เป้าหมาย: kill Bootstrap row gutter / negative margin · ปล่อยให้ template
   คุม gap/padding/background ของตัวเองใน shop-templates.css
   ============================================================ */
body.shop-themed #productGrid {
    --bs-gutter-x: 0 !important;
    --bs-gutter-y: 0 !important;
    margin: 0 !important;
}
body.shop-themed #productGrid > .moreBox {
    padding: 8px !important;
    margin: 0 !important;
    background: var(--shop-surface) !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: hidden;
}
/* ภาพ — bleed เต็มขอบบนของ card (ไม่มี padding) */
body.shop-themed #productGrid > .moreBox > .ratio:first-child,
body.shop-themed #productGrid > .moreBox > a:first-child > .ratio {
    margin: -8px -8px 6px -8px !important;
    padding: 0 !important;
    border-radius: 0 !important;
}
body.shop-themed #productGrid > .moreBox .ratio,
body.shop-themed #productGrid > .moreBox .image-base {
    padding: 0 !important;
    border-radius: 0 !important;
}
/* hover — primary border + soft shadow lift */
body.shop-themed #productGrid > .moreBox:hover {
    transform: none !important;
    box-shadow: inset 0 0 0 2px var(--shop-primary), 0 6px 16px -6px rgba(0,0,0,.22) !important;
    z-index: 2; position: relative;
}
/* shop-tile-banner — full bleed, ไม่มีช่องว่างเลย */
body.shop-themed .shop-tile-banner {
    grid-column: 1 / -1 !important;
    padding: 0 !important; margin: 0 !important;
    background: var(--shop-surface) !important;
    border: 0 !important;
    width: 100% !important;
}
body.shop-themed .shop-tile-banner img,
body.shop-themed .shop-tile-banner .banner-slot { display: block !important; width: 100% !important; height: auto !important; }

/* === Brand strip — non-Classic ใช้ original site.css 100% (Classic-style toggle)
   เก็บแค่ row-span สำหรับ INTERMISSION (Brand row ภายใน productGrid) เพื่อให้
   span เต็ม row ของ grid layout ไม่ใช่อยู่ใน 1 cell · TOP brand strip
   ปล่อยให้ media query เดิมของ site.css จัดการ flex↔carousel ตาม viewport === */
body.shop-themed:not(.tpl-list) #productGrid > #Brand,
body.shop-themed:not(.tpl-list) #productGrid > #SubBrand,
body.shop-themed:not(.tpl-list) #productGrid > #Brand-SubBrand_SmallDevice {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    margin: 0 !important;
    background: var(--shop-bg) !important;
}

/* tpl-list: ซ่อน intermission ทั้งหมด (list mode = ไม่มี brand แทรก) */
body.tpl-list #productGrid > #Brand-SubBrand_SmallDevice,
body.tpl-list #productGrid > #Brand,
body.tpl-list #productGrid > #SubBrand { display: none !important; }

/* Carousel indicators tinted */
body.shop-themed .carousel-indicators button { background-color: var(--shop-primary); }

/* Generic accent helpers */
body.shop-themed .text-primary { color: var(--shop-primary) !important; }
body.shop-themed .text-success { color: var(--shop-secondary) !important; }
body.shop-themed .bg-primary { background: var(--shop-primary) !important; }
body.shop-themed .bg-light { background: var(--shop-surface) !important; }
