/* Theme overrides for MrR00TMRR site using Bootstrap 5 */
/* Typography */
:root {
  --bs-body-font-family: 'Kanit', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --brand-accent: #00e5ff;
  --btn-bg: rgba(255,255,255,0.06);
  --btn-bg-hover: rgba(255,255,255,0.12);
  --btn-border: rgba(255,255,255,0.12);
  --brand-purple: 168, 85, 247; /* rgb tuple for glow */
  --footer-h: 64px; /* sticky footer height */
}

/* Mobile-first tuning for catalog product cards */
@media (max-width: 576px) {
  /* Ensure product cards don't require inner scrolling on small screens */
  .catalog-card { padding: .75rem; }
  .catalog-card .card-title { font-size: 1rem; margin-bottom: .35rem; }
  .catalog-card .catalog-desc {
    font-size: .9rem; line-height: 1.5; margin-bottom: .5rem;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
    line-clamp: 3; /* standard property (limited support) */
  }
  /* Clamp title to two lines to avoid vertical overflow */
  .catalog-card .card-title {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    line-clamp: 2;
  }
  /* Shrink main product image height and hide small thumbs */
  .catalog-card .pg-img { height: 150px !important; }
  .catalog-card .pg-thumb { display: none !important; }
  /* Compact action buttons */
  .catalog-card .btn { padding: .35rem .6rem; font-size: .925rem; }
  .catalog-card .btn.btn-sm { padding: .3rem .5rem; font-size: .875rem; }
  /* Price text slightly smaller and tighter */
  .catalog-card .text-success { font-size: .95rem; margin-bottom: .5rem !important; }
  /* Reduce gaps under image container */
  .catalog-card .product-gallery + .d-flex,
  .catalog-card .product-gallery + div { margin-top: .5rem !important; }
}

html, body {
  height: 100%;
}

body {
  background-color: #000; /* fallback */
  color: #e9ecef;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: var(--footer-h); /* space for fixed footer */
}

/* Global mobile safety: avoid accidental horizontal scroll and scale media */
html { overflow-x: hidden; }
body { overflow-x: hidden; }
img, video, canvas, svg, iframe { max-width: 100%; height: auto; }

/* Enforce Kanit font across body text and form controls */
body, button, input, select, textarea {
  font-family: 'Kanit', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}

/* Starfield canvas underlay */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  /* ensure it never intercepts clicks and scrolls */
  pointer-events: none;
  /* hint the browser for smoother animation */
  will-change: transform, opacity;
}

/* Layout */
.layout {
  position: relative;
  z-index: 1; /* above starfield */
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  padding: 1rem;
  flex: 1 0 auto; /* allow footer to stick bottom */
}

@media (max-width: 992px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  .layout { padding: 0.75rem; gap: 0.75rem; }
}

main.content {
  min-height: 60vh;
}

/* Generic grid helper for listings */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  align-items: stretch;
}

/* Sidebar */
.sidebar {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: .75rem;
  padding: 1rem;
  backdrop-filter: blur(6px);
}
.layout > .sidebar { align-self: start; }
.sidebar-title {
  font-weight: 600;
  font-size: 1rem;
  margin: .5rem 0 .25rem;
}
.sidebar .menu,
.sidebar .sidebar-toplinks {
  list-style: none;
  padding-left: 0;
  margin: .25rem 0 1rem;
}
.sidebar .menu li + li,
.sidebar .sidebar-toplinks li + li { margin-top: .25rem; }
.sidebar a { color: #ced4da; text-decoration: none; }
.sidebar a:hover { color: var(--brand-accent); }

/* Navbar tweaks */
.navbar {
  /* charcoal dark gray header */
  background: #0f1115 !important;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  z-index: 1200; /* keep navbar above content */
}
.navbar .brand,
.navbar .nav-link,
.navbar a { color: #f8f9fa; text-decoration: none; }
.navbar a:hover { color: var(--brand-accent); }
.navbar .nav-link { padding: .25rem .5rem; line-height: 1.2; }
.navbar .nav-link .fa, .navbar .nav-link .fas, .navbar .nav-link .far, .navbar .nav-link .fab {
  margin-right: .25rem; /* tighter icon spacing */
}

/* Better behavior for collapsed navbar on mobile */
.navbar .navbar-collapse { flex-wrap: wrap; }
@media (max-width: 991.98px) {
  .navbar .nav-link { display: block; width: 100%; padding: .6rem .75rem; font-size: .95rem; }
  .navbar .nav-link.text-nowrap { white-space: normal !important; }
  .navbar .user-info { gap: .3rem; flex-wrap: wrap; }
  /* Make brand text wrap and be readable on mobile */
  .navbar .navbar-brand {
    white-space: normal;
    font-size: 1rem;
    line-height: 1.2;
  }
}

/* Distinct colors for navbar icons */
.navbar .nav-link i.nav-home { color: #0dcaf0; }       /* info */
.navbar .nav-link i.nav-store { color: #20c997; }      /* teal */
.navbar .nav-link i.nav-blog { color: #f39c12; }       /* amber */
.navbar .nav-link i.nav-code { color: #6f42c1; }       /* purple */
.navbar .nav-link i.nav-rewards { color: #e83e8c; }    /* pink */
.navbar .nav-link i.nav-topup { color: #22c55e; }      /* green */
.navbar .nav-link i.nav-cart-icon { color: #adb5bd; }  /* gray */

/* Keep icon color on hover (do not switch to accent) */
.navbar .nav-link:hover i.nav-home { color: #0dcaf0; }
.navbar .nav-link:hover i.nav-store { color: #20c997; }
.navbar .nav-link:hover i.nav-blog { color: #f39c12; }
.navbar .nav-link:hover i.nav-code { color: #6f42c1; }
.navbar .nav-link:hover i.nav-rewards { color: #e83e8c; }
.navbar .nav-link:hover i.nav-topup { color: #22c55e; }
.navbar .nav-link:hover i.nav-cart-icon { color: #adb5bd; }

/* Logout button styling (เลือดหมู) */
.navbar .nav-link[href*="route=logout"],
.navbar .nav-link.logout {
  background-color: #8B0000; /* dark maroon */
  border: 1px solid #a3151c;
  color: #fff !important;
  border-radius: .5rem;
  padding: .25rem .5rem;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-left: .5rem;
}
.navbar .nav-link[href*="route=logout"]:hover,
.navbar .nav-link.logout:hover {
  background-color: #a3151c; /* slightly brighter on hover */
  border-color: #b11a22;
  color: #fff !important;
}
.navbar .nav-link[href*="route=logout"]:active,
.navbar .nav-link.logout:active {
  background-color: #790b12;
  border-color: #8a0f16;
}

/* Navbar user info offset (desktop only) */
.navbar .user-info.nav-user-shift { transform: translateX(-4%); }
/* compact user-info line without changing font size */
.navbar .user-info { display: inline-flex; align-items: center; gap: .35rem; flex-wrap: nowrap; }
.navbar .user-info > span { white-space: nowrap; }
/* keep level text and bar on the same line with compact bar */
.navbar .level-progress-wrap { display: inline-block; width: 90px; vertical-align: middle; margin-left: .25rem; }
.navbar .level-progress { height: .35rem; margin: 0; }
.navbar .level-progress .progress-bar { min-width: 0; }
/* Scoped compact variant for user info pills (no side effects elsewhere) */
.navbar .user-info--compact { gap: .25rem; }
.navbar .user-info--compact .user-pill { padding: .15rem .35rem; font-size: .85rem; border-radius: .45rem; }
.navbar .user-info--compact .user-pill i { font-size: .8rem; }
.navbar .user-info--compact .user-pill.level .level-progress-wrap { width: 64px; margin-left: .25rem; }
.navbar .user-info--compact .level-progress { height: .3rem; }
@media (max-width: 992px) {
  .navbar .user-info.nav-user-shift {
    transform: none; /* avoid layout issues on small screens */
  }
  /* Force a line break inside collapsed menu to push user block below links */
  .navbar .spacer { flex-basis: 100%; height: 0; }
  /* Ensure user info wraps nicely and uses full width */
  .navbar .user-info { display: flex; width: 100%; gap: .35rem; flex-wrap: wrap; margin: .25rem 0; }
  /* Slightly compact pills to fit smaller widths */
  .navbar .user-pill { padding: .2rem .4rem; font-size: .9rem; }
  /* Narrow progress bar on mobile to avoid overflow */
  .navbar .user-pill.level .level-progress-wrap { width: 68px; }
  /* Make logout button a compact pill instead of full-width bar on mobile */
  .navbar .nav-link[href*="route=logout"],
  .navbar .nav-link.logout {
    display: inline-flex;
    width: auto;
    align-self: flex-start;
    padding: .35rem .6rem;
    margin: .25rem 0 .5rem 0;
    border-radius: .5rem;
  }
}

/* Compact "pill" elements for user meta in navbar */
.navbar .user-pill {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: #f8f9fa;
  border-radius: .5rem;
  padding: .2rem .45rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  white-space: nowrap;
}
.navbar .user-pill i { opacity: .9; font-size: .9rem; }
.navbar .user-pill.level { padding-right: .4rem; }
.navbar .user-pill.level .level-progress-wrap { width: 80px; margin-left: .35rem; }

/* Colors for balance (green) and points (gold) */
.navbar .user-pill.balance .amount { color: #22c55e; font-weight: 600; }
.navbar .user-pill.points .points-value { color: #FFD700; font-weight: 600; }
/* Star icon in points pill = dark maroon (เลือดหมู) */
.navbar .user-pill.points .points-icon { color: #8B0000; }

/* Wallet icon as solid blue */
.navbar .user-pill.balance .wallet-icon { color: #0d6efd; }

/* Animated purple glow for brand */
.brand-glow {
  position: relative;
  color: #fff;
  font-weight: 700;
  /* soften direct glow on glyphs to avoid covering the text */
  -webkit-text-stroke: 0.6px rgba(0,0,0,0.45);
  text-shadow:
    0 1px 0 rgba(0,0,0,0.55),
    0 0 2px rgba(var(--brand-purple), 0.35),
    0 0 6px rgba(var(--brand-purple), 0.18);
}
.brand-glow:hover { text-decoration: none; }

/* Place animated aura BEHIND the text so text stays crisp */
.brand-glow::before {
  content: "";
  position: absolute;
  inset: -8px -14px; /* extend slightly around text */
  z-index: -1;       /* behind the text */
  pointer-events: none;
  background: radial-gradient(60% 50% at 50% 55%, rgba(var(--brand-purple), .45), rgba(var(--brand-purple), 0) 65%)
              ,radial-gradient(100% 80% at 50% -10%, rgba(var(--brand-purple), .25), rgba(var(--brand-purple), 0) 70%);
  filter: blur(6px) saturate(110%);
  opacity: .55;
  animation: brandAura 2.6s ease-in-out infinite;
}

@keyframes brandAura {
  0%, 100% {
    transform: scale(1);
    opacity: .55;
    filter: blur(6px) saturate(110%);
  }
  50% {
    transform: scale(1.04);
    opacity: .75;
    filter: blur(8px) saturate(120%);
  }
}

/* Progress bar already uses Bootstrap classes; just tune height */
.level-progress { height: .5rem; background-color: rgba(255,255,255,0.1); }
.level-progress .progress-bar { background-image: linear-gradient(90deg, #0d6efd, #20c997); }

/* Account dropdown (header) */
.account-wrap { position: relative; }
.account-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: #f8f9fa;
  border-radius: .5rem;
  min-height: 34px;
  padding: .3rem .5rem;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  text-decoration: none;
}
.account-btn:hover { border-color: rgba(255,255,255,0.22); background: var(--btn-bg-hover); }
.account-text { font-weight: 600; font-size: .85rem; letter-spacing: .3px; color: #f8f9fa; }
@media (max-width: 420px) {
  .account-text { display: none; }
}
.navbar .account-btn {
  /* Ensure pill style in navbar, overriding any circular rules elsewhere */
  height: 34px;
  padding: .28rem .6rem;
  border-radius: .65rem;
}
.navbar .account-btn svg { width: 16px; height: 16px; }
.navbar .account-btn i { font-size: 14px; line-height: 1; }

/* Color variants for header account buttons */
.account-btn--register {
  background: rgba(25, 135, 84, 0.12);
  border-color: #198754;
  color: #eafaf0;
}
.account-btn--register:hover {
  background: #198754;
  border-color: #157347;
  color: #ffffff;
}
.account-btn--login {
  background: rgba(13, 110, 253, 0.12);
  border-color: #0d6efd;
  color: #e9f2ff;
}
.account-btn--login:hover {
  background: #0d6efd;
  border-color: #0a58ca;
  color: #ffffff;
}
.navbar .account-btn + .account-btn, .navbar .account-btn + .account-wrap { margin-left: .5rem; }
.account-dropdown {
  width: 280px;
  background: #111827;
  color: #e5e7eb;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: .75rem;
  padding: .75rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
  z-index: 2000; /* ensure over cards/other content */
}
.account-form .field { margin-bottom: .5rem; }
.account-form label { font-size: .9rem; color: #aab0b6; margin-bottom: .25rem; display: block; }
.account-form input {
  width: 100%;
  background: #0b0f16;
  border: 1px solid rgba(255,255,255,0.12);
  color: #e9ecef;
  border-radius: .5rem;
  padding: .5rem .75rem;
}
.account-form .btn { width: 100%; }
.account-form .subtext {
  margin-top: .5rem;
  display: block;
  text-align: right;
  font-size: .85rem;
  color: #aab0b6;
}
.account-form .subtext a {
  color: var(--brand-accent);
  text-decoration: none;
}
.account-form .subtext a:hover { text-decoration: underline; }

/* Footer */
.footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1250;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  /* charcoal dark gray footer to match header */
  background-color: #0f1115;
  color: #adb5bd;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* Cosmic floating particles added by starfield.js */
.cosmic-particle {
  position: fixed;
  z-index: 0; /* keep under layout but above body background */
  background: rgba(255,255,255,0.35);
  border-radius: 50%;
  filter: drop-shadow(0 0 6px rgba(168,85,247,0.45));
  pointer-events: none;
  animation-name: cosmicFloat;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

@keyframes cosmicFloat {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: .55;
  }
  50% {
    transform: translate3d(10px, -30px, 0) scale(1.12);
    opacity: .9;
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: .55;
  }
}

/* Utilities */
.spacer { flex: 1 1 auto; }
.user-badge { display: inline-flex; align-items: center; gap: .2rem; padding: .1rem .3rem; border: 1px solid rgba(255,255,255,0.15); border-radius: 999px; line-height: 1; width: max-content; }
.user-icon { opacity: .9; width: 14px; height: 14px; }

/* Cart nav count */
.nav-cart { position: relative; }
#nav-cart-count { color: var(--brand-accent); font-weight: 600; }

/* Bootstrap button theming */
.btn { border-radius: .5rem; border-width: 1px; }
.btn:focus { box-shadow: 0 0 0 .25rem rgba(13,110,253,.25); }
.btn-primary {
  background-image: linear-gradient(180deg, #0d6efd, #0b5ed7);
  border-color: #0b5ed7;
}
.btn-primary:hover { background-image: linear-gradient(180deg, #0b5ed7, #0a58ca); border-color: #0a58ca; }
.btn-primary:active { background-image: linear-gradient(180deg, #0a58ca, #094db4); border-color: #094db4; }
.btn-light {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.2);
  color: #f8f9fa;
}
.btn-light:hover { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.28); color: #fff; }
.btn-outline-light { border-color: var(--btn-border); color: #ffffff; }
.btn-outline-light:hover { background: var(--btn-bg-hover); border-color: rgba(255,255,255,0.22); color: #fff; }
/* Keep text readable when disabled on dark background */
.btn-outline-light.disabled, .btn-outline-light:disabled {
  color: rgba(255,255,255,0.8) !important;
  border-color: rgba(255,255,255,0.35) !important;
  opacity: .75;
}

/* Card utilities and Sidebar fit adjustments */
.card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: .75rem;
  padding: 1rem;
  backdrop-filter: blur(6px);
  text-align: center;
}

/* Compact card padding on small devices to reduce vertical scroll */
@media (max-width: 576px) {
  .card { padding: .75rem; }
}

.card h3 { margin-top: .25rem; margin-bottom: .5rem; }
.card p { margin-bottom: .75rem; }
.card form { display: flex; justify-content: center; align-items: center; gap: .5rem; }
.card .btn { display: inline-flex; align-items: center; gap: .4rem; justify-content: center; }
.card .btn i { margin-right: .25rem; }

/* Login-to-buy row with cart at the right side */
.buy-center {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.buy-center .btn-buy { order: 1; }
.buy-center .add-to-cart { order: 2; }
@media (max-width: 420px) {
  .buy-center { flex-direction: column; }
  .buy-center .btn, .buy-center .btn-buy { width: 100%; }
}

/* Make login and add-to-cart buttons visually distinct */
/* Login to buy = blue (primary) */
.buy-center .btn-buy {
  background-image: linear-gradient(180deg, #0d6efd, #0b5ed7);
  border-color: #0b5ed7;
  color: #fff;
}
.buy-center .btn-buy:hover {
  background-image: linear-gradient(180deg, #0b5ed7, #0a58ca);
  border-color: #0a58ca;
  color: #fff;
}
.buy-center .btn-buy:active {
  background-image: linear-gradient(180deg, #0a58ca, #094db4);
  border-color: #094db4;
  color: #fff;
}

/* Add to cart = green outline that fills on hover */
.buy-center .add-to-cart {
  background: rgba(25, 135, 84, 0.08);
  border-color: #198754;
  color: #fff;
}
.buy-center .add-to-cart:hover {
  background: #198754;
  border-color: #157347;
  color: #fff;
}
.buy-center .add-to-cart:active {
  background: #157347;
  border-color: #146c43;
  color: #fff;
}

.sidebar {
  width: 100%;
  height: auto;
}
.sidebar .menu li a,
.sidebar .sidebar-toplinks li a {
  display: block;
  padding: .5rem .625rem;
  border-radius: .5rem;
  line-height: 1.3;
  /* Allow full text to be visible and wrap to the next line */
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  word-break: break-word;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .05s ease;
}
.sidebar .menu li a .icon,
.sidebar .sidebar-toplinks li a .icon {
  margin-right: .5rem;
  width: 1.125rem;
  display: inline-block;
  text-align: center;
  opacity: .95;
}
  .sidebar .menu li a:hover,
  .sidebar .sidebar-toplinks li a:hover {
    background: var(--btn-bg-hover);
    border-color: rgba(255,255,255,0.18);
  }
  .sidebar .menu li a:active,
  .sidebar .sidebar-toplinks li a:active { transform: translateY(1px); }
  .sidebar .sidebar-title { margin-top: .75rem; margin-bottom: .25rem; }

  /* Hide specific sidebar link as requested */
  body > div.layout > aside > ul:nth-child(5) > li:nth-child(6) > a {
    display: none !important;
  }

  /* Lightning text effect */
  .lightning-text {
    position: relative;
    color: #ffffff;
    /* toned-down purple glow */
    -webkit-text-stroke: 0.4px rgba(0,0,0,0.45);
    text-shadow:
      0 1px 0 rgba(0,0,0,0.55),
      0 0 2px rgba(255,255,255,0.75),
      0 0 6px rgba(var(--brand-purple), 0.28);
    /* subtle outer glow layer behind text */
    filter: saturate(105%);
    animation: lightningFlicker 3.2s ease-in-out infinite;
  }

  /* extra aura behind using pseudo element for depth */
  .lightning-text::before {
    content: "";
    position: absolute;
    inset: -6px -10px;
    z-index: -1;
    pointer-events: none;
    background:
      radial-gradient(60% 60% at 50% 50%, rgba(var(--brand-purple), 0.18), rgba(var(--brand-purple), 0) 70%),
      radial-gradient(80% 70% at 50% 40%, rgba(var(--brand-purple), 0.12), rgba(var(--brand-purple), 0) 75%);
    filter: blur(8px) saturate(110%);
    opacity: .7;
    transition: opacity .2s ease;
  }

@keyframes lightningFlicker {
  /* calm */
  0%, 6%, 100% {
    text-shadow:
      0 1px 0 rgba(0,0,0,0.5),
      0 0 2px rgba(255,255,255,0.7),
      0 0 6px rgba(var(--brand-purple), 0.26);
    filter: saturate(105%);
  }
  /* micro flicker */
  7% { text-shadow: 0 1px 0 rgba(0,0,0,.5), 0 0 2px rgba(255,255,255,.7), 0 0 6px rgba(var(--brand-purple), .26); }
  /* soft pulse instead of big strike */
  8%, 8.6% {
    text-shadow:
      0 1px 0 rgba(0,0,0,.5),
      0 0 3px rgba(255,255,255, .85),
      0 0 9px rgba(var(--brand-purple), .36);
    filter: saturate(112%);
  }
  /* gentle fade */
  10% { text-shadow: 0 1px 0 rgba(0,0,0,.5), 0 0 2px rgba(255,255,255,.75), 0 0 8px rgba(var(--brand-purple), .3); }
  /* tiny jitter */
  30% { text-shadow: 0 1px 0 rgba(0,0,0,.5), 0 0 2px rgba(255,255,255,.7), 0 0 7px rgba(var(--brand-purple), .26); }
  /* soft glow cycle midpoint */
  50% {
    text-shadow:
      0 1px 0 rgba(0,0,0,0.5),
      0 0 3px rgba(255,255,255,0.8),
      0 0 9px rgba(var(--brand-purple), 0.34);
  }
  /* final jitter */
  72% { text-shadow: 0 1px 0 rgba(0,0,0,.5), 0 0 3px rgba(255,255,255,.75), 0 0 8px rgba(var(--brand-purple), .28); }
  82%, 83% { text-shadow: 0 1px 0 rgba(0,0,0,.5), 0 0 4px rgba(255,255,255,.9), 0 0 11px rgba(var(--brand-purple), .38); }
}
