/* Custom Styles for TruVolt Solutions - FINAL UI STABILITY VERSION */

:root {
  --primary: #0B1F3A;
  --secondary: #FFFFFF;
  --accent: #FFD54F;
  --text-dark: #111111;
  --text-muted: #333333;
  --bg-alt: #f4f6f8;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 100px;
}

body {
  font-family: 'Poppins', sans-serif;
  background-color: var(--secondary);
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 500;
  line-height: 1.6;
  overflow-x: hidden !important;
  max-width: 100vw;
}

html {
  overflow-x: hidden !important;
}

/* Force Absolute Opacity (Excluding Preloader) */
*:not(#preloader_container, #preloader_container *) {
  opacity: 1 !important;
}

/* --- FIXED HEADER --- */
nav#navbar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  z-index: 9999 !important;
}

/* --- LIGHT BACKGROUNDS (White, Gray-50) --- */
body, .bg-white, .bg-gray-50, .bg-gray-100 {
  color: var(--text-dark) !important;
}

.bg-white p, .bg-gray-50 p, .bg-gray-100 p {
  color: var(--text-muted) !important;
}

/* Light-section headings — use > so this ONLY applies to DIRECT children,
   NOT to h1/h2 inside nested dark sections like .bg-primary hero banners */
.bg-white > h1, .bg-white > h2, .bg-white > h3, .bg-white > h4,
.bg-gray-50 > h1, .bg-gray-50 > h2, .bg-gray-50 > h3, .bg-gray-50 > h4,
.bg-white > div > h1, .bg-white > div > h2, .bg-white > div > h3,
.bg-gray-50 > div > h1, .bg-gray-50 > div > h2, .bg-gray-50 > div > h3 {
  color: var(--primary) !important;
}

/* Force dark text for visibility in light sections */
.text-gray-400, .text-gray-500, .text-gray-600, .text-gray-700, .text-gray-800, .text-gray-900 {
  color: var(--text-dark) !important;
}

/* --- DARK BACKGROUNDS (Primary, Black) --- */
.bg-primary, .bg-black {
  background-color: var(--primary) !important;
  color: #FFFFFF !important;
}

/* Footer gets its own background from inline style, just force text white */
footer {
  color: #FFFFFF !important;
}

.bg-primary *, .bg-black *, footer * {
  color: #FFFFFF !important;
}

/* Force all headings on dark backgrounds to be white */
.bg-primary h1, .bg-primary h2, .bg-primary h3, .bg-primary h4,
.bg-black h1, .bg-black h2, .bg-black h3, .bg-black h4,
footer h1, footer h2, footer h3, footer h4 {
  color: #FFFFFF !important;
}

/* HIGH-SPECIFICITY: headings inside ALL dark sections must be white */
/* These selectors (0,2,1) beat the light-section rule (0,1,1) */
.bg-gray-50 .bg-primary h1, .bg-gray-50 .bg-primary h2,
.bg-gray-50 .bg-primary h3, .bg-gray-50 .bg-primary h4,
.bg-gray-50 .bg-black h1,   .bg-gray-50 .bg-black h2,
.bg-gray-50 .bg-black h3,   .bg-gray-50 .bg-black h4,
body .bg-primary h1, body .bg-primary h2,
body .bg-primary h3, body .bg-primary h4,
body .bg-black h1,   body .bg-black h2,
body .bg-black h3,   body .bg-black h4,
/* footer headings */
.bg-gray-50 footer h1, .bg-gray-50 footer h2,
.bg-gray-50 footer h3, .bg-gray-50 footer h4,
body footer h1, body footer h2,
body footer h3, body footer h4 {
  color: #FFFFFF !important;
}

/* HIGH-SPECIFICITY: paragraph text in dark sections */
body .bg-primary p, body .bg-black p, body footer p,
.bg-gray-50 .bg-primary p, .bg-gray-50 .bg-black p {
  color: rgba(255,255,255,0.90) !important;
}

/* HIGH-SPECIFICITY: spans inside dark sections */
body .bg-primary span, body .bg-black span,
.bg-gray-50 .bg-primary span, .bg-gray-50 .bg-black span {
  color: inherit;
}

/* Force paragraph text on dark backgrounds to be white */
.bg-primary p, .bg-black p, footer p {
  color: rgba(255,255,255,0.90) !important;
}

/* HIGH-SPECIFICITY: footer paragraphs must not be overridden by body .bg-gray-50 p rule */
.bg-gray-50 footer p, .bg-gray-100 footer p, body footer p {
  color: rgba(255,255,255,0.90) !important;
}

/* Footer link colors - keep gray for style, not overridden to dark */
body footer a {
  text-decoration: none;
}

.bg-primary .text-accent, .bg-black .text-accent, footer .text-accent {
  color: var(--accent) !important;
}

/* --- BUTTONS & INTERACTIVES --- */

/* Message Us / Glass Buttons Fix */
.glass {
  background: rgba(255, 255, 255, 0.95) !important;
  color: var(--primary) !important; /* Force dark text on white glass button */
  backdrop-filter: blur(4px) !important;
  border: 2px solid var(--primary) !important;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
}

.glass:hover {
  background: var(--primary) !important;
  color: #FFFFFF !important;
  transform: translateY(-2px) !important;
}

/* Force color for buttons that look white-on-white */
.btn-primary, button.bg-accent, a.bg-accent {
  color: var(--primary) !important;
  font-weight: 700 !important;
}

.bg-primary a, .bg-primary button {
  color: #FFFFFF !important;
}

/* Services Page Card Fix */
.service-card {
  border: 1px solid #e5e7eb !important;
  background: white !important;
}

.service-card * {
  color: var(--text-dark) !important;
}

.service-card h3 {
  color: var(--primary) !important;
}

/* --- SECTION SPACING --- */
section {
  padding: 100px 0 !important;
  position: relative !important;
}

/* Footer Visibility Fix */
footer {
  background-color: var(--primary) !important;
  border-top: 5px solid var(--accent) !important;
}

footer a {
  color: rgba(255, 255, 255, 0.8) !important;
}

footer a:hover {
  color: var(--accent) !important;
}

/* Floating WhatsApp Button */
.whatsapp-float {
  position: fixed;
  width: 60px;
  height: 60px;
  bottom: 40px;
  right: 40px;
  background-color: #25d366;
  color: #FFF !important;
  border-radius: 50px;
  text-align: center;
  font-size: 30px;
  box-shadow: 0 10px 25px rgba(37, 211, 102, 0.3);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- ELECTRICAL INTRO LOADER CSS --- */
#preloader_container {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background-color: var(--primary);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: containerFadeOut 0.5s 2.5s forwards ease-out;
}

@keyframes containerFadeOut {
  0% { opacity: 1; visibility: visible; }
  100% { opacity: 0; visibility: hidden; }
}

#electrical_loader_content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.brand-logo {
  opacity: 0;
  width: 6rem;
  border-radius: 0.5rem;
  background-color: white;
  padding: 0.25rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  z-index: 10;
  animation: logoFadeIn 0.5s forwards ease-out;
}

@keyframes logoFadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.energy-ring {
  position: absolute;
  width: 140px; 
  height: 140px;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-bottom-color: rgba(255, 213, 79, 0.3);
  border-radius: 50%;
  box-shadow: 0 0 15px rgba(255, 213, 79, 0.4), inset 0 0 10px rgba(255, 213, 79, 0.2);
  opacity: 0;
  animation: ringBuild 1.5s 1s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes ringBuild {
  0% { opacity: 0; transform: scale(0.8) rotate(0deg); }
  20% { opacity: 1; box-shadow: 0 0 25px rgba(255, 213, 79, 0.8), inset 0 0 15px rgba(255, 213, 79, 0.4); }
  80% { opacity: 1; transform: scale(1.1) rotate(180deg); }
  100% { opacity: 0; transform: scale(1.2) rotate(270deg); }
}

.electric-flash {
  position: fixed;
  inset: 0;
  background-color: white;
  opacity: 0;
  pointer-events: none;
  z-index: 10000;
  animation: flashEffect 0.6s 2.4s forwards ease-out;
}

@keyframes flashEffect {
  0% { opacity: 0; }
  10% { opacity: 0.85; }
  100% { opacity: 0; }
}

.spark {
  position: absolute;
  width: 3px; 
  height: 20px;
  background-color: white;
  box-shadow: 0 0 8px 2px var(--accent);
  border-radius: 50%;
  opacity: 0;
  z-index: 5;
}

.spark-1 { top: calc(50% - 60px); left: calc(50% - 30px); --rot: 45deg; animation: sparkPulse 0.4s 0.6s 2; }
.spark-2 { top: calc(50% + 40px); left: calc(50% + 20px); --rot: -45deg; animation: sparkPulse 0.3s 0.9s 2; }
.spark-3 { top: 50%; left: calc(50% - 80px); --rot: 90deg; animation: sparkPulse 0.5s 1.2s 1; }
.spark-4 { top: calc(50% - 20px); left: calc(50% + 60px); --rot: 135deg; animation: sparkPulse 0.4s 1.5s 1; }

@keyframes sparkPulse {
  0% { opacity: 0; transform: rotate(var(--rot)) scale(0.5) translateY(0); }
  50% { opacity: 1; transform: rotate(var(--rot)) scale(1.5) translateY(-15px); }
  100% { opacity: 0; transform: rotate(var(--rot)) scale(0.5) translateY(-30px); }
}

/* Hide scrollbar for Chrome, Safari and Opera */
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.hide-scrollbar {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

/* --- AUTO-SCROLL BRANDS MARQUEE --- */
.brands-track {
  display: flex;
  gap: 1rem;
  width: max-content;
  animation: brandScroll 28s linear infinite;
}

.brands-track:hover {
  animation-play-state: paused;
}

.brands-viewport {
  overflow: hidden;
  width: 100%;
  mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
}

@keyframes brandScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* === MOBILE OPTIMIZATIONS === */
@media (max-width: 767px) {
  /* Reduce section padding drastically on mobile */
  section {
    padding: 40px 0 !important;
  }

  /* Prevent any element from going outside screen */
  * {
    max-width: 100%;
  }

  /* Brands marquee: slow down and clip properly on mobile */
  .brands-viewport {
    mask-image: none !important;
    -webkit-mask-image: none !important;
  }

  .brands-track {
    animation-duration: 10s !important;
  }

  /* Override any remaining horizontal AOS animations at CSS level */
  [data-aos="fade-left"],
  [data-aos="fade-right"] {
    transform: translate3d(0, 30px, 0) !important;
  }

  [data-aos="fade-left"].aos-animate,
  [data-aos="fade-right"].aos-animate {
    transform: translate3d(0, 0, 0) !important;
  }

  /* Fix hero sections on mobile */
  .py-32 { padding-top: 5rem !important; padding-bottom: 5rem !important; }
  .py-40 { padding-top: 5rem !important; padding-bottom: 5rem !important; }
  .py-20 { padding-top: 2.5rem !important; padding-bottom: 2.5rem !important; }
  .py-16 { padding-top: 2rem !important; padding-bottom: 2rem !important; }
  .mb-16 { margin-bottom: 2rem !important; }
  .mb-12 { margin-bottom: 1.5rem !important; }
  .gap-16 { gap: 2rem !important; }
  .gap-12 { gap: 1.5rem !important; }

  /* Prevent negative margin overlap on mobile */
  .-mt-12, .-mt-16 {
    margin-top: 0 !important;
  }

  /* Fix trust indicator cards on mobile */
  .grid-cols-2 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Fix footer grid on mobile */
  footer .grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  /* Ensure images don't overflow */
  img {
    max-width: 100% !important;
    height: auto;
  }

  /* Fix the CTA section contact form on mobile */
  .lg\:flex-row {
    flex-direction: column !important;
  }

  /* ── MOBILE HEADING VISIBILITY FIX ───────────────────────────────── */
  /* Force ALL h1-h4 inside dark sections to be white on mobile too.   */
  /* Uses triple-selector specificity to beat body.bg-gray-50 h1 rule. */
  .bg-primary h1, .bg-primary h2, .bg-primary h3, .bg-primary h4,
  .bg-black h1,   .bg-black h2,   .bg-black h3,   .bg-black h4,
  section.bg-primary h1, section.bg-primary h2,
  section.bg-primary h3, section.bg-primary h4,
  body section.bg-primary h1, body section.bg-primary h2,
  body section.bg-primary h3, body section.bg-primary h4,
  body .bg-primary h1, body .bg-primary h2,
  body .bg-primary h3, body .bg-primary h4,
  body footer h1, body footer h2, body footer h3, body footer h4 {
    color: #FFFFFF !important;
  }

  /* Force paragraph text visible on mobile dark sections */
  body .bg-primary p, body section.bg-primary p,
  body .bg-black p, body footer p {
    color: rgba(255,255,255,0.90) !important;
  }

  /* Accent spans in dark sections stay yellow */
  .bg-primary .text-accent, body .bg-primary .text-accent,
  body section.bg-primary span[style*="FFD54F"] {
    color: #FFD54F !important;
  }
}

/* Services grid center fix for 7th card */
.services-grid-center {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 2rem;
}

@media (min-width: 768px) {
  .services-grid-center {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .services-grid-center {
    grid-template-columns: repeat(3, 1fr);
  }
  .services-last-row {
    grid-column: 2 / 3;
  }
}
