/* =========================================================================
   1. GLOBAL PREMIUM STYLE, VARIABLES & BACKGROUND
   ========================================================================= */
:root {
  --primary-dark: #0f172a;    
  --accent-green: #0f172a;    
  --bg-light: #f8fafc;        
  --text-main: #334155;      
  --text-muted: #64748b;      
}

*, *::before, *::after { 
  box-sizing: border-box; 
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  background-color: #f1f5f9 !important; /* Kijivu laini cha kishua */
  color: #0f172a;
  overflow-x: hidden;
}

input, textarea, select { 
  font-size: 16px; 
}

/* =========================================================================
   2. PREMIUM HEADER & SEARCH BAR (WITH HOVER EFFECTS)
   ========================================================================= */
header {
  background-color: #111827;
  padding: 12px 4%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.logo h1 { 
  font-size: 22px; 
  font-weight: 800; 
  color: white; 
  margin: 0; 
  letter-spacing: -0.5px;
}
.logo span { 
  color: #38bdf8; 
} 

.header-buttons { 
  display: flex; 
  gap: 6px; 
  align-items: center;
}

.btn-header {
  background: #1e293b; 
  color: white; 
  border: 1px solid #334155;
  padding: 8px 14px; 
  border-radius: 20px; 
  font-weight: 700;
  cursor: pointer; 
  font-size: 12px; 
  text-transform: uppercase;
  transition: all 0.2s ease;
}
/* HOVER YA VITUFE VYA HEADER */
.btn-header:hover { 
  background: #2d3d5a !important; 
  border-color: #475569 !important;
  transform: translateY(-1px);
}

#postTriggerBtn { 
  background: var(--primary-dark); 
  border: 1px solid rgba(255, 255, 255, 0.2); 
}

.search-container { 
  display: flex; 
  justify-content: flex-end; 
}

#search, #search-input {
  padding: 7px 12px; 
  border-radius: 20px; 
  border: 1px solid #374151;
  background: #1e293b; 
  color: white; 
  outline: none; 
  font-size: 13px;
  width: 140px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
/* HOVER YA SEARCH BAR MTEJA AKITAKA KUGUSA */
#search:hover, #search-input:hover {
  border-color: #4b5563 !important;
  background: #233144 !important;
}
#search:focus, #search-input:focus {
  width: 190px;
  border-color: #38bdf8 !important;
  background: #273549;
  outline: none;
}

/* Responsive Header */
@media (max-width: 768px) {
  header { 
    justify-content: center; 
    text-align: center; 
    padding: 15px; 
  }
  .header-buttons { 
    justify-content: center; 
    width: 100%; 
  }
  .search-container { 
    width: 100%; 
    justify-content: center; 
    margin-top: 5px; 
  }
  #search, #search-input { 
    width: 92%; 
  }
  #search:focus, #search-input:focus { 
    width: 95%; 
  }
}

/* =========================================================================
   3. CLEAN BANNER AD
   ========================================================================= */
.banner-ad {
  width: 96%; 
  max-width: 800px;
  height: 140px;
  object-fit: cover;
  margin: 4px auto 0 auto !important;
  background: linear-gradient(135deg, #1f2937, #111827) !important;
  color: white; 
  padding: 12px !important;
  border-radius: 12px !important; 
  text-align: center; 
  border: none !important;
  margin-bottom: 4px;
}
.banner-ad h2 { 
  font-size: 16px; 
  font-weight: 800; 
}
.banner-badge {
  background: #1e293b; 
  color: white; 
  display: inline-block;
  padding: 4px 12px; 
  border-radius: 12px; 
  font-size: 12px; 
  margin-top: 4px;
}

/* =========================================================================
   4. CATEGORIES SECTION (ZERO GAPS)
   ========================================================================= */
#categories {
  display: flex; 
  gap: 6px; 
  padding: 6px 4% !important;
  background: #ffffff; 
  border-bottom: 1px solid #e2e8f0; 
  overflow-x: auto; 
  white-space: nowrap;
  margin: 4px 0 0 0 !important;
  scrollbar-width: none;
}
#categories::-webkit-scrollbar { 
  display: none; 
}

#categories button, .btn-cat {
  background: #f1f5f9; 
  color: #475569; 
  border: none;
  padding: 6px 14px; 
  border-radius: 15px; 
  cursor: pointer;
  font-weight: 700; 
  font-size: 12px;
  transition: all 0.2s;
}
#categories button:hover, .btn-cat:hover {
  background: #1e293b; 
  color: white;
}
#categories button.active-cat, .btn-cat.active { 
  background: #1e293b; 
  color: white; 
}

/* =========================================================================
   5. VIP / BOOSTED CONTAINER SYSTEM & DESIGN (GHOROFA MBILI & NO-GAP)
   ========================================================================= */
#vip-products {
  background-color: #777e88 !important; /* Kijivu kilichokolea cha picha kama ulivyoweka */
  border-radius: 8px;
  width: 96%;
  margin: 4px auto 0 auto !important;
  padding: 8px !important; /* Finya mapengo ya ndani ya VIP */
  
  /* LASH NAZIMISHA MFUMO WA GHOROFA MBILI KWENDA KULIA */
  display: grid !important;
  grid-template-rows: repeat(2, auto) !important;
  grid-auto-flow: column !important;
  grid-auto-columns: max-content !important; /* Inazuia kadi kusukumana au kuacha magap makubwa */
  
  /* RUHUSU SCROLL YA KWENDA KULIA KWENYE SIMU */
  overflow-x: auto !important;
  overflow-y: hidden !important;
  gap: 8px !important; /* Mapengo yamepunguzwa baina ya kadi za VIP */
  
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; /* Laini kabisa kwenye iPhones */
}

/* Inaficha kile kijiti cha scrollbar cha chini kwenye simu ili liwe nadhifu */
#vip-products::-webkit-scrollbar {
  display: none !important;
}

/* Kadi zinazoingia ndani ya VIP pekee ili zisivurugike upana wake */
#vip-products .product, 
#vip-products .product-card, 
#vip-products .pro-card {
  flex: none !important; 
  width: 160px !important; /* Upana mzuri wa kadi za VIP kioo cha simu kikae sawa */
  max-width: 160px !important;
  scroll-snap-align: start;
}


/* =========================================================================
   6. PRODUCTS GRID & CARD DESIGN SYSTEM (KADI ZA KAWAIDA NA VIP)
   ========================================================================= */
#products, .products-grid-container {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(220px, 2fr)) !important;
  gap: 4px !important; /* Mapengo yamepunguzwa kadi za kawaida chini */
  padding: 4px 1% !important;
}

/* KADI YA BIDHAA: RANGI NA AINA HAZIJABADILIKA HATA KIDOGO (ZINAFUATA ZA KWAKO) */
.product, .product-card, .pro-card {
  background: #ffffff !important;
  border-radius: 16px !important; /* Imelindwa kama picha ya mtumiaji */
  border: 1px solid #e2e8f0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  padding: 0 !important;
  margin: 0 !important;
  cursor: pointer;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
  transition: transform 0.2s ease, box-shadow 0.2s ease; /* Maandalizi ya Hover */
}

/* ANTI-SHAKING & IMAGE STYLE FOR ALL CARDS */
.pro-card img, .product img, .product-card img {
  width: 100% !important;
  height: 140px !important; /* Urefu ulionyooka kuzuia kadi kurefuka vibaya wima */
  object-fit: cover !important; /* Inazuia picha kujivuta au kukatika vibaya */
  display: block !important;
}
/* HOVER YA KADI YA BIDHAA MTU AKITAKA KUGUSA */
.product:hover, .product-card:hover, .pro-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 12px -2px rgba(0,0,0,0.06) !important;
}

/* PICHA ZOTE MBILI */
.product img, .product-card img, .pro-card img {
  width: 100% !important;
  aspect-ratio: 16 / 11 !important; /* Muundo thabiti wa picha ya viatu */
  object-fit: cover !important;
  display: block !important;
  padding: 0 !important; 
  margin: 0 !important;
}

.product-info, .pro-card-body {
  padding: 10px !important; /* Pengo safi la ndani ya maelezo */
  display: flex !important;
  flex-direction: column !important;
  gap: 2px !important;
}

.product h3, .product-card h3, .pro-card-title {
  font-size: 13px !important; 
  font-weight: 700 !important;
  color: #0f172a !important; 
  margin: 0 0 4px 0 !important;
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; /* KUZUIA MAJINA MAREFU KUREFUSHA KADI */
}

.product .price, .product-card .price, .pro-card-price {
  font-size: 13px !important; 
  color: #0f172a !important;
  font-weight: 800 !important; 
  margin: 1px 0 !important;
}

/* STAILI YA BEJI MPYA YA TRUSTED TULIYOHAMISHA KUTOKA HTML */
.safe-badge-trusted {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border: 1px solid #bfdbfe !important;
  padding: 1px 5px !important;
  border-radius: 4px !important;
  font-size: 9px !important;
  font-weight: bold !important;
  margin-left: 5px !important;
  margin-bottom: 2px !important; /* Inazuia bei na beji kukutana vibaya */
  display: inline-flex !important;
  align-items: center !important;
  gap: 2px !important;
  letter-spacing: 0.5px !important;
}
.safe-badge-trusted i {
  font-size: 10px !important;
}

/* =========================================================================
   7. MAPACHA VITUFE SYSTEM (BUTTONS)
   ========================================================================= */
.product-actions, .product-card div[style*="display: flex"] {
  display: flex !important;
  flex-direction: row !important;
  gap: 3px !important;
  padding: 0 8px 8px 8px !important;
  width: 100% !important;
  margin-top: auto !important;
}

.btn-icon-wa, .btn-icon-share {
  flex: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 30px !important;
  border-radius: 4px !important;
  border: none !important; 
  color: white !important;
  cursor: pointer !important; 
  font-size: 0 !important;
  background: #1e293b !important;
  transition: background 0.2s ease;
}
.btn-icon-wa:hover, .btn-icon-share:hover {
  background: #2a3a54 !important;
}

/* =========================================================================
   8. MODALS, TOAST & POST FORM
   ========================================================================= */
.modal, #productModal {
  display: none; 
  position: fixed !important; 
  z-index: 9999999 !important;
  left: 0 !important; 
  top: 0 !important; 
  width: 100% !important; 
  height: 100% !important;
  background-color: rgba(15, 23, 42, 0.7) !important; 
  backdrop-filter: blur(4px);
}
.modal-content {
  background-color: white; 
  margin: 12% auto; 
  padding: 30px;
  width: 90%; 
  max-width: 420px; 
  border-radius: 24px; 
  position: relative;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}
.close-modal { 
  position: absolute; 
  right: 20px; 
  top: 15px; 
  font-size: 28px; 
  cursor: pointer; 
  color: #94a3b8; 
}
.product-modal-img { 
  width: 100%; 
  border-radius: 16px; 
  margin-bottom: 15px; 
}
.product-modal-price { 
  font-size: 20px; 
  font-weight: 800; 
  color: var(--primary-dark); 
  margin: 10px 0; 
}

#postSection {
  max-width: 450px; 
  margin: 10px auto; 
  padding: 15px;
  background: white; 
  border-radius: 8px; 
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
#postSection input, #postSection select, #postSection textarea {
  width: 100%; 
  padding: 10px; 
  margin-bottom: 8px; 
  border: 1px solid #cbd5e1; 
  border-radius: 6px;
}
#submit-prod-btn {
  width: 100%; 
  background: #1e293b; 
  color: white; 
  padding: 12px; 
  border: none; 
  border-radius: 6px; 
  font-weight: 700;
}

#toast {
  display: none; 
  position: fixed; 
  bottom: 30px; 
  left: 50%; 
  transform: translateX(-50%); 
  background: #0f172a; 
  color: white; 
  padding: 10px 20px; 
  border-radius: 30px; 
  z-index: 20000; 
  font-size: 14px;
}

footer { 
  background: #0f172a; 
  color: #cbd5e1; 
  text-align: center; 
  padding: 30px 15px; 
  margin-top: 30px; 
}
footer a { 
  color: #cbd5e1; 
}
.footer-wa-btn { 
  background: #1e293b; 
  color: white; 
  padding: 10px 20px; 
  border-radius: 20px; 
  text-decoration: none; 
  font-weight: 700; 
}

/* =========================================================================
   9. REKEBISHO LA UHAKIKA: VIP 2x2 NA SLIDE YA PEMBENI (MAX-WIDTH: 600px)
   ========================================================================= */
@media (max-width: 600px) {
  /* BIDHAA ZA KAWAIDA ZA CHINI: ZINABAKI VILEVILE, MAPENGO MADOGO */
  #products { 
    grid-template-columns: repeat(2, 2fr) !important; 
    gap: 4px !important; 
    padding: 6px 1% !important;
  }

  /* =========================================================================
   👑 MPANGILIO MPYA WA VIP KWENYE SIMU (FINYA MAGAP YA PEMBENI)
   ========================================================================= */
#vip-products {
    display: grid !important;
    grid-template-rows: repeat(2, auto) !important; /* Mstari wa juu na chini pekee */
    grid-auto-flow: column !important;              /* Bidhaa zijipange kwenda kulia */
    
    /* 💥 DAWA YA MAGAP: Inalazimisha kila safu ya wima (column) iwe na upana wa kadi tu */
    grid-auto-columns: max-content !important; 
    
    overflow-x: auto !important;   
    overflow-y: hidden !important;
    gap: 4px !important; /* Nafasi ndogo na nadhifu kati ya kadi na kadi */
    padding: 6px !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

/* Kadi za VIP - Tunafuta flex na kuweka upana imara wa pixel */
#vip-products .product, 
#vip-products .product-card, 
#vip-products .pro-card {
    flex: none !important;      /* Inaua ule mfumo wa zamani uliokuwa unavuta ma-gap */
    width: 160px !important;    /* Upana thabiti ili kadi 2 zionekane vizuri kwenye kioo */
    max-width: 160px !important;
    scroll-snap-align: start;
}

/* INFICHA KILE KIJITI CHA SCROLLBAR ILI BANGO LIWE NADHFU KAMA APP YA INSTAGRAM */
#vip-products::-webkit-scrollbar {
    display: none !important;
}
}