/* =============================================================================
   shop-themes.css
   Theme overrides + dark-mode readability
   --------------------------------------------------------------------
   ใช้ 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       = ทุกหน้า /shop (apply เสมอ)
     body.theme-<key>       = theme key (sakura, mint, charcoal, ...)
     body.theme-dark        = themes ดาร์ก (indigo, cyber, charcoal)
   ============================================================================= */

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; }

/* 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; }

/* =============================================================================
   Mobile readability (Shopee-like sizing สำหรับ viewport scale=1)
   --------------------------------------------------------------------
   ใช้ !important เพื่อ override inline style ใน _ProductCard.cshtml
   ============================================================================= */
/* Top nav (fixed-top) — mobile + tablet (Bootstrap < lg)
   ครอบทั้ง iPhone, iPad portrait และ desktop หน้าต่างเล็ก ≈ 600-991px */
@media (max-width: 991.98px) {
    nav.fixed-top a.nav-link[style*="font-size:small"] {
        font-size: 14px !important;
        height: 38px !important;
        padding-top: 6px !important;
        font-weight: 400 !important;
    }
    nav.fixed-top a.nav-link img#Logout,
    nav.fixed-top a.nav-link img#Favorite { height: 18px !important; }
    nav.fixed-top a.nav-link img#Cart_All { height: 20px !important; }
    nav.fixed-top .fav-badge,
    nav.fixed-top .cart-badge {
        font-size: 11px !important;
        padding: 2px 5px !important;
        min-width: 16px !important;
        top: -7px !important;
        right: -12px !important;
    }
}
@media (max-width: 575.98px) {
    /* mobile — phone portrait */
    nav.fixed-top a.nav-link[style*="font-size:small"] {
        font-size: 15px !important;
        height: 40px !important;
        padding-top: 8px !important;
    }
    nav.fixed-top a.nav-link img#Logout,
    nav.fixed-top a.nav-link img#Favorite { height: 20px !important; }
    nav.fixed-top a.nav-link img#Cart_All { height: 22px !important; }

    /* default productView */
    .moreBox h6.productView {
        font-size: 14px !important;
        line-height: 1.45 !important;
    }
    /* ชื่อสินค้า (อยู่ใน a แรกของ card) — เด่นสุด */
    .moreBox > a:first-of-type h6.productView {
        font-size: 16px !important;
        font-weight: 600 !important;
        line-height: 1.3 !important;
        padding-top: 6px !important;
    }
    /* ราคา (มี price tag icon นำหน้า) — bold เน้น */
    .moreBox .row h6.productView img[src*="PriceTag"] { height: 16px !important; }
    .moreBox .row h6.productView[style*="color:Black"] {
        font-size: 17px !important;
        font-weight: 700 !important;
    }
    /* sub info — ขายแล้ว / Stock เหลือ (สีเทา/เทาฟ้า) */
    .moreBox .row h6.productView[style*="dimgrey"],
    .moreBox .row h6.productView[style*="cadetblue"] {
        font-size: 12px !important;
        font-weight: 500 !important;
    }
    .moreBox .row h6.productView img { height: 14px !important; }
    /* qty + unit dropdown — touch-friendly */
    .moreBox .select-qty,
    .moreBox .select-unit {
        height: 38px !important;
        font-size: 14px !important;
        font-weight: 500 !important;
    }
    /* ปุ่มเพิ่มลงตะกร้า — touch-friendly + bold */
    .moreBox a[onclick*="AddToCart"] > div {
        height: 40px !important;
        padding-top: 8px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
    }
    .moreBox a[onclick*="AddToCart"] > div img { height: 20px !important; }
    /* favorite wrapper (width:36px) — ยึดความสูงเท่าปุ่ม Cart + center icon */
    .moreBox .row > div[style*="width:36px"] {
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .moreBox img.add-to-favorite { height: 26px !important; }
    /* spacing ระหว่าง row ใน card — กันแน่นเกิน */
    .moreBox .row + .row { margin-top: 4px; }
}

/* แท็บเล็ตขนาดเล็ก (576-767) — กลางๆ ระหว่าง mobile กับ desktop */
@media (min-width: 576px) and (max-width: 767.98px) {
    .moreBox h6.productView { font-size: 13px !important; line-height: 1.4 !important; }
    .moreBox > a:first-of-type h6.productView { font-size: 15px !important; font-weight: 600 !important; }
    .moreBox .row h6.productView[style*="color:Black"] { font-size: 16px !important; font-weight: 700 !important; }
    .moreBox .row h6.productView[style*="dimgrey"],
    .moreBox .row h6.productView[style*="cadetblue"] { font-size: 12px !important; }
    .moreBox .select-qty,
    .moreBox .select-unit { height: 36px !important; font-size: 13px !important; }
    .moreBox a[onclick*="AddToCart"] > div { height: 38px !important; font-size: 13px !important; font-weight: 600 !important; }
    /* favorite wrapper — center icon + ความสูงเท่าปุ่ม Cart */
    .moreBox .row > div[style*="width:36px"] {
        height: 38px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .moreBox img.add-to-favorite { height: 24px !important; }
}
