/* Custom CSS Extensions for Green C Corp (Matbao 8079 & Toan Thang Vibe) */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --font-primary: 'Plus Jakarta Sans', sans-serif;
  --color-green-dark: #064e3b;
  --color-green-main: #059669;
  --color-green-emerald: #10b981;
  --color-green-light: #ecfdf5;
  --color-green-hover: #047857;
}

html {
  overflow-x: clip;
  width: 100%;
}

body {
  font-family: var(--font-primary);
  background-color: #f8fafc;
  color: #0f172a;
  width: 100%;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

/* Custom Scrollbar Green */
::-webkit-scrollbar {
  width: 8px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #064e3b;
}
::-webkit-scrollbar-thumb {
  background: #10b981;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #059669;
}

/* Hide scrollbar utility for mobile horizontal scroll filters */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Glassmorphism Header & Mobile Floating Bar */
.glass-nav-green {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(16, 185, 129, 0.15);
}

.glass-mobile-bar {
  background: rgba(6, 78, 59, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(16, 185, 129, 0.25);
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

/* Hero & Card Styles */
.hero-green-overlay {
  background: linear-gradient(135deg, rgba(6,78,59,0.92) 0%, rgba(5,150,105,0.85) 60%, rgba(16,185,129,0.75) 100%);
}

.bg-emerald-gradient {
  background: linear-gradient(135deg, #064e3b 0%, #059669 50%, #10b981 100%);
}

/* Card Lift & Shadows */
.card-hover-green {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.card-hover-green:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 25px -5px rgba(5, 150, 105, 0.15), 0 10px 10px -5px rgba(5, 150, 105, 0.08);
  border-color: #10b981;
}

/* Badge pulse */
.green-pulse {
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

.modal-backdrop-green {
  background: rgba(6, 78, 59, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Responsive Modal Max Heights */
.modal-backdrop-green > div {
  max-height: 90vh;
  overflow-y: auto;
}

/* Mobile Drawer Touch Scrolling */
#mobile-menu-drawer, #cart-drawer {
  -webkit-overflow-scrolling: touch;
}

/* ==================== MAIN STICKY / FIXED HEADER ==================== */
#main-header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 1000 !important;
  transition: background-color 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease, height 0.35s ease, padding 0.35s ease, transform 0.35s ease !important;
  will-change: background-color, box-shadow, height, transform;
}

/* 1. Trạng Thái Ở Đầu Trang (scrollY <= 60px): Nền 100% Trong Suốt + Chữ Trắng (Không làm mờ/tối ảnh banner) */
#main-header.header-transparent {
  background-color: transparent !important;
  background-image: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
}

#main-header.header-transparent #header-inner {
  height: 80px !important;
}

#main-header.header-transparent .header-top-link,
#main-header.header-transparent .header-main-link {
  color: #ffffff !important;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8), 0 2px 8px rgba(0, 0, 0, 0.6) !important;
  transition: all 0.3s ease !important;
}

#main-header.header-transparent .header-top-link:hover,
#main-header.header-transparent .header-main-link:hover,
#main-header.header-transparent .header-main-link.active {
  color: #34d399 !important; /* Emerald Accent */
  text-shadow: 0 0 12px rgba(52, 211, 153, 0.7) !important;
  transform: translateY(-1px);
}

#main-header.header-transparent .header-main-link.active {
  border-bottom: 2px solid #34d399 !important;
}

#main-header.header-transparent .nav-divider {
  color: rgba(255, 255, 255, 0.45) !important;
}

#main-header.header-transparent .header-search-input {
  background-color: rgba(0, 0, 0, 0.3) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.4) !important;
  backdrop-filter: blur(8px) !important;
  transition: all 0.3s ease !important;
}

#main-header.header-transparent .header-search-input::placeholder {
  color: rgba(255, 255, 255, 0.75) !important;
}

#main-header.header-transparent .fa-magnifying-glass {
  color: rgba(255, 255, 255, 0.85) !important;
}

/* 2. Trạng Thái Khi Cuộn Trang (scrollY > 60px): Nền Xanh Green Đậm (#0A7A3E) + Chữ Trắng Sắc Nét */
@keyframes headerSlideDown {
  0% {
    transform: translateY(-100%);
    opacity: 0.85;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

#main-header.header-scrolled,
#main-header.scrolled {
  background-color: #0A7A3E !important; /* Green Chủ Đạo (#0A7A3E / Emerald-800) */
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
  animation: headerSlideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#main-header.header-scrolled #header-inner,
#main-header.scrolled #header-inner {
  height: 66px !important;
}

#main-header.header-scrolled #header-logo-img,
#main-header.scrolled #header-logo-img {
  max-height: 38px !important;
}

#main-header.header-scrolled .header-top-link,
#main-header.scrolled .header-top-link {
  color: rgba(255, 255, 255, 0.9) !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4) !important;
}

#main-header.header-scrolled .header-top-link:hover,
#main-header.scrolled .header-top-link:hover {
  color: #a7f3d0 !important;
}

#main-header.header-scrolled .header-main-link,
#main-header.scrolled .header-main-link {
  color: #ffffff !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5) !important;
  transition: all 0.3s ease !important;
}

#main-header.header-scrolled .header-main-link:hover,
#main-header.scrolled .header-main-link:hover,
#main-header.header-scrolled .header-main-link.active,
#main-header.scrolled .header-main-link.active {
  color: #a7f3d0 !important; /* Mint Light Green on Hover */
  transform: translateY(-1px);
}

#main-header.header-scrolled .header-main-link.active,
#main-header.scrolled .header-main-link.active {
  border-bottom: 2px solid #a7f3d0 !important;
}

#main-header.header-scrolled .header-search-input,
#main-header.scrolled .header-search-input {
  background-color: rgba(0, 0, 0, 0.2) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  transition: all 0.3s ease !important;
}

#main-header.header-scrolled .header-search-input::placeholder,
#main-header.scrolled .header-search-input::placeholder {
  color: rgba(255, 255, 255, 0.75) !important;
}

#main-header.header-scrolled .fa-magnifying-glass,
#main-header.scrolled .fa-magnifying-glass {
  color: rgba(255, 255, 255, 0.85) !important;
}

#main-header.header-scrolled .nav-divider,
#main-header.scrolled .nav-divider {
  color: rgba(255, 255, 255, 0.35) !important;
}

/* Category Strip Sticky on Scroll */
.sticky-category-bar {
  position: sticky !important;
  top: 68px !important;
  z-index: 900 !important;
  transition: all 0.3s ease !important;
}

@media (min-width: 1024px) {
  .sticky-category-bar {
    top: 72px !important;
  }
}

body {
  padding-top: 0 !important;
}

@media (max-width: 767px) {
  body {
    padding-top: 0 !important;
    padding-bottom: 70px !important;
  }
}

/* Header Logo Integrity Protection */
#main-header a img {
  max-height: 44px !important;
  width: auto !important;
  object-fit: contain !important;
  flex-shrink: 0 !important;
}

@media (max-width: 640px) {
  #main-header a img {
    max-height: 36px !important;
    width: auto !important;
  }
}

/* Mobile Touch & Clickability Safeguards */
button, a, input, select {
  touch-action: manipulation !important;
}

#mobile-menu-btn, #open-cart-btn, .open-cart-btn, .open-auth-modal, .open-consult-modal, .add-to-cart-btn, #close-menu-btn, #close-cart-btn {
  cursor: pointer !important;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto !important;
}

/* Global Responsive & Anti-Text Drop Utilities */
h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
  word-break: keep-all;
}

p, span, a, label {
  overflow-wrap: break-word;
}

/* Navigation Link Pill Hover & Active Effects (Toàn Thắng Exact Title Case) */
.nav-link-tte {
  position: relative;
  padding: 0.4rem 0.6rem;
  font-size: clamp(0.75rem, 0.85vw, 0.875rem);
  font-weight: 700;
  text-transform: none !important; /* Title Case like Toàn Thắng screenshot */
  letter-spacing: -0.01em;
  color: #1e293b; /* slate-800 */
  white-space: nowrap;
  border-radius: 0.5rem;
  transition: all 0.2s ease-in-out;
}
.nav-link-tte:hover {
  color: #059669; /* emerald-600 */
  background-color: #ecfdf5; /* emerald-50 */
}
.nav-link-tte.active {
  color: #047857; /* emerald-700 */
  font-weight: 800;
}
.nav-link-tte.active::after {
  content: '';
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
  width: 75%;
  height: 3px;
  background-color: #059669;
  border-radius: 9999px;
}

/* Service Card Lift & Toan Thang Vibe */
.toanthang-card {
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(226, 232, 240, 0.9);
}
.toanthang-card:hover {
  transform: translateY(-6px);
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 25px 35px -10px rgba(5, 150, 105, 0.15), 0 10px 15px -5px rgba(5, 150, 105, 0.08);
}

/* Mobile Viewport Spacing (<768px) */
@media (max-width: 767px) {
  body {
    padding-top: 145px !important;
    padding-bottom: 70px !important;
  }
  
  /* Mobile Action Icons Always Accessible on Touch */
  .card-action-icons {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateX(0) !important;
  }
}

/* Desktop Viewport Spacing (>=768px) */
@media (min-width: 768px) {
  body {
    padding-top: 120px !important;
  }
}

/* Ensure drawers & overlays render above fixed header */
#menu-overlay, #cart-overlay {
  z-index: 2000 !important;
}

#mobile-menu-drawer, #cart-drawer {
  z-index: 2001 !important;
}

/* Touch device support */
@media (hover: none) {
  .card-action-icons {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateX(0) !important;
  }
}

/* Enforce Card Action Icons Hover Only on Desktop */
@media (min-width: 768px) and (hover: hover) {
  .card-action-icons {
    display: flex !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateX(12px) !important;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  .product-item:hover .card-action-icons,
  .spm-item:hover .card-action-icons,
  .product-card:hover .card-action-icons,
  .group:hover .card-action-icons {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateX(0) !important;
  }
}

/* Mobile Product Grid Layout Optimizations (<640px) */
@media (max-width: 639px) {
  .product-item, .product-card, .spm-item {
    padding: 0.85rem !important;
    border-radius: 1.25rem !important;
  }
  
  .product-item .h-48, .spm-item .h-48, .product-card .h-48 {
    height: 9.5rem !important;
  }

  /* Prevent text overflow in small grid cards */
  .product-item h4, .product-card h4, .spm-item h4 {
    font-size: 0.8125rem !important;
    line-height: 1.25 !important;
  }
}

/* Responsive Table & Image Guards */
img, iframe, video {
  max-width: 100%;
  height: auto;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Global Mobile Typography Guards - Anti Word-Dropping (<768px) */
@media (max-width: 767px) {
  h1 {
    font-size: clamp(1.25rem, 5.5vw, 1.875rem) !important;
    line-height: 1.3 !important;
    word-break: keep-all !important;
    overflow-wrap: break-word !important;
  }
  h2 {
    font-size: clamp(1.125rem, 4.8vw, 1.5rem) !important;
    line-height: 1.35 !important;
    word-break: keep-all !important;
    overflow-wrap: break-word !important;
  }
  h3 {
    font-size: clamp(1rem, 4.2vw, 1.25rem) !important;
    line-height: 1.4 !important;
    word-break: keep-all !important;
  }
  p, span, div, button, a {
    word-break: normal;
    overflow-wrap: break-word;
  }
  .brand-text, .keep-together, .inline-block-nowrap {
    white-space: nowrap !important;
    display: inline-block !important;
  }
}

/* ==================== GLOBAL PAGINATION STYLES ==================== */
.pagination {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.375rem !important;
  list-style: none !important;
  padding: 0 !important;
  margin: 1.5rem 0 !important;
}
.page-item {
  display: inline-block !important;
  margin: 0 !important;
}
.page-link {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 2.25rem !important;
  height: 2.25rem !important;
  padding: 0.25rem 0.75rem !important;
  font-size: 0.8125rem !important;
  font-weight: 700 !important;
  color: #334155 !important;
  background-color: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 0.75rem !important;
  text-decoration: none !important;
  transition: all 0.2s ease !important;
}
.page-link:hover {
  color: #0A7A3E !important;
  border-color: #10b981 !important;
  background-color: #f0fdf4 !important;
}
.page-item.active .page-link {
  color: #ffffff !important;
  background-color: #0A7A3E !important;
  border-color: #0A7A3E !important;
  box-shadow: 0 4px 6px -1px rgba(10, 122, 62, 0.25) !important;
}
.page-item.disabled .page-link {
  color: #94a3b8 !important;
  background-color: #f8fafc !important;
  border-color: #f1f5f9 !important;
  cursor: not-allowed !important;
  opacity: 0.6 !important;
}

