/* Base styles */
:root {
  --primary-color: #1a4d2e;
  --primary-light: #2a6d3e;
  --primary-dark: #0a3d1e;
  --secondary-color: #ff9900;
  --secondary-light: #ffad33;
  --secondary-dark: #cc7a00;
  --text-color: #333333;
  --text-light: #666666;
  --background: #ffffff;
  --background-alt: #f8f9fa;
  --light-bg: #f5f5f5;
  --header-height: 60px;
  --container-max-width: 1200px;
  --container-padding: 1rem;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
  --transition: all 0.3s ease;
}

/* Cross-browser normalization */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Enhanced touch handling */
@media (hover: none) {
  * {
    cursor: default !important;
  }
  
  a, button, [role="button"], .clickable {
    cursor: pointer !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
}

/* Legacy browser support */
@supports not (display: grid) {
  .products-grid, .services-grid {
    display: flex;
    flex-wrap: wrap;
    margin: -1rem;
  }
  
  .product-card, .service-card {
    flex: 1 1 300px;
    margin: 1rem;
    min-width: 250px;
  }
}

/* Fix for older Safari versions */
@media not all and (min-resolution:.001dpcm) { 
  @supports (-webkit-appearance:none) {
    .product-card, .service-card {
      -webkit-transform: translateZ(0);
      transform: translateZ(0);
    }
    
    .header {
      -webkit-transform: translateZ(0);
      transform: translateZ(0);
    }
  }
}

/* IE11 specific fixes */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  .products-grid, .services-grid {
    display: flex;
    flex-wrap: wrap;
  }
  
  .product-card, .service-card {
    flex: 1 1 300px;
    margin: 1rem;
  }
  
  :root {
    --header-height: 60px;
  }
  
  .header {
    height: 60px;
  }
}

/* Container utilities */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
  box-sizing: border-box;
}

/* iOS specific optimizations */
@supports (-webkit-touch-callout: none) {
  body {
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
  }
  
  .header {
    position: -webkit-sticky;
    position: sticky;
  }
  
  .product-card, .service-card {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
  }
  
  .nav-links {
    -webkit-overflow-scrolling: touch;
  }
}

body, html {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: var(--text-color);
  scroll-behavior: smooth;
  background-color: var(--background);
  line-height: 1.6;
}

/* Header and Navigation */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-sm);
  z-index: 1000;
  transition: var(--transition);
}

.header.scrolled {
  box-shadow: var(--shadow-md);
}

.nav-container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.logo {
  display: flex;
  align-items: center;
  z-index: 1001;
}

.logo h1 {
  margin: 0;
  font-size: 1.5rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.menu-toggle {
  display: none;
}

.lang-switch {
  display: flex;
  gap: 0.5rem;
  margin-left: 2rem;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-color);
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  padding: 0.5rem 0;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--primary-color);
  transition: var(--transition);
}

.nav-links a:hover::after {
  width: 100%;
}

/* Mobile Navigation */
@media screen and (max-width: 850px) {
  .menu-toggle {
    display: block;
    background: none;
    border: none;
    font-size: 24px;
    padding: 0.5rem;
    cursor: pointer;
    z-index: 1001;
    color: var(--primary-color);
    position: relative;
  }

  .nav-container {
    padding: 0 1rem;
  }

  .nav-links {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background);
    padding: 2rem;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 999;
    gap: 1.5rem;
  }

  .nav-links.active {
    transform: translateX(0);
  }

  .nav-links a {
    color: var(--text-color);
    font-size: 1.2rem;
    padding: 0.5rem;
    width: 100%;
    text-align: center;
  }

  .lang-switch {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    display: none;
  }

  body.menu-open {
    overflow: hidden;
  }

  body.menu-open::before {
    content: '';
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
  }
}

/* Main content */
main {
  padding-top: calc(var(--header-height) + 1rem);
  overflow-x: hidden;
}

/* Hero Section */
.hero {
  min-height: calc(100vh - var(--header-height));
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem var(--container-padding);
  text-align: center;
  color: white;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, rgba(0,0,0,0.4), rgba(0,0,0,0.2));
  z-index: 1;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.hero-content h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  margin-bottom: 1rem;
  line-height: 1.2;
}

.hero-content h2 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  margin-bottom: 1rem;
  line-height: 1.3;
}

.hero-content p {
  font-size: clamp(1rem, 3vw, 1.5rem);
  margin: 0;
  line-height: 1.5;
}

/* Sections */
.section {
  padding: 5rem var(--container-padding);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #ffffff;
}

.section:nth-child(even) {
  background-color: var(--background-alt);
}

.section h2 {
  text-align: center;
  color: var(--primary-color);
  margin-bottom: 3rem;
}

/* Products and Services Grid */
.products-grid, .services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2.5rem;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.product-card, .service-card {
  background: var(--background);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 350px;
  padding: 0.5rem;
}

.flip-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.flip-card-front {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  background-color: white;
  border-radius: 12px;
  padding: 1rem;
  box-sizing: border-box;
}

/* Image container */
.card-image {
  width: auto;
  min-width: fit-content;
  height: 70%;
  object-fit: contain;
  padding: 0.5rem;
  display: block;
  margin: 0 auto;
  background-color: white;
  border-radius: 15px;
  transition: transform 0.3s ease;
}

/* Add hover effect for images */
.card-image:hover {
  transform: scale(1.05);
}

/* Text styling */
.product-card h3, .service-card h3 {
  font-size: 1.2rem;
  color: var(--primary-color);
  width: auto;
  min-width: fit-content;
  height: 25%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background-color: var(--light-bg);
  border-radius: 12px;
  margin-bottom: 0.5rem;
  padding: 0.5rem 1rem;
  white-space: nowrap;
}

.products-description p, .services-description p, .about-content p {
  font-size: 1.2rem;
  line-height: 1.6;
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  text-align: justify;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .product-card, .service-card {
    height: 300px;
  }

  .card-image {
    height: 65%;
    padding: 0.5rem;
  }

  .products-grid, .services-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    padding: 0.5rem;
  }

  .section {
    padding: 3rem 1rem;
  }
}

@media (max-width: 480px) {
  .product-card, .service-card {
    height: 280px;
  }

  .card-image {
    height: 65%;
    padding: 0.25rem;
  }

  .products-grid, .services-grid {
    grid-template-columns: 1fr;
    padding: 0.5rem;
  }

  .product-card h3, .service-card h3 {
    font-size: 1.1rem;
  }

  .products-description p, .services-description p, .about-content p {
    font-size: 1.1rem;
    padding: 0 1rem;
  }
}

/* For larger screens */
@media (min-width: 1200px) {
  .card-image {
    height: 70%;
    max-height: none;
  }

  .products-grid, .services-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .card-image {
    width: 180px;
    height: 180px;
  }
}

/* Hover effects */
.product-card:hover, .service-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

/* Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  .product-card, .service-card {
    transform: translateZ(0);
  }
  
  .product-card img, .service-card img {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }
}

/* Tablet optimization */
@media (min-width: 768px) and (max-width: 1024px) {
  .section {
    padding: 4rem 1.5rem;
  }

  .hero-content h2 {
    font-size: 2.5rem;
  }

  .products-description p,
  .services-description p,
  .about-content p {
    font-size: 1.1em;
    padding: 0 1.5rem;
  }
}

/* Small screens and mobile landscape */
@media (max-width: 480px), (max-height: 500px) and (orientation: landscape) {
  .hero {
    height: auto;
    min-height: 40vh;
  }

  .hero-content {
    padding: 2rem 1rem;
  }

  .section h2 {
    font-size: 1.8rem;
    margin-bottom: 2rem;
  }

  .products-description p,
  .services-description p,
  .about-content p {
    font-size: 1.1rem;
    padding: 0 1rem;
  }
}

/* High-resolution screens */
@media (min-width: 1920px) {
  .section {
    max-width: 1400px;
  }

  .card-image {
    width: 200px;
    height: 200px;
  }

  .flip-card-front h3 {
    font-size: 1.4rem;
  }
}

/* Print styles */
@media print {
  .product-card, .service-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .hero {
    height: auto;
    background: none;
    color: black;
  }
}

/* Services Description */
.services-description {
  text-align: center;
  margin-top: 3rem;
  padding: 0 1rem;
}

.services-description p {
  font-size: 1.2em;
  color: var(--text-color);
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.6;
  text-align: justify;
}

/* Contact */
.contact-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  text-align: center;
}

/* Map Link */
.map-link {
  display: inline-flex;
  align-items: center;
  color: var(--primary-color);
  text-decoration: none;
  padding: 0.5rem 1rem;
  margin-top: 1rem;
  border: 2px solid var(--primary-color);
  border-radius: 4px;
  transition: all 0.3s ease;
}

.map-link:hover {
  background: var(--primary-color);
  color: white;
}

.map-icon {
  margin-right: 0.5rem;
  font-size: 1.2em;
}

/* Footer */
.footer {
  background: var(--primary-color);
  color: white;
  text-align: center;
  padding: 1rem;
  margin-top: 2rem;
}

/* Media Queries */
@media (max-width: 1200px) {
  .nav-links {
    gap: 1rem;
  }
}

@media (max-width: 1024px) {
  .nav-links {
    gap: 0.8rem;
  }
  .logo h1 {
    font-size: 1.3rem;
  }
  .logo-img {
    height: 35px;
  }
}

/* For landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .hero {
    height: 70vh;
  }

  .nav-container {
    padding: 0.3rem;
  }
}

/* Media queries for responsive logo */
@media (max-width: 360px) {
  .logo {
    gap: 0.5rem;
  }
  .logo-img {
    height: 25px;
  }
}

/* Services Section */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.service-card {
  background: var(--background);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.service-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.service-title {
  font-size: 1.5rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.service-description {
  color: var(--text-color);
  line-height: 1.6;
  margin-bottom: 1rem;
}

/* Media Queries for Services */
@media (max-width: 768px) {
  .services-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
  }

  .service-title {
    font-size: 1.3rem;
  }
}

@media (max-width: 480px) {
  .services-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .service-title {
    font-size: 1.3rem;
  }
}

/* Cross-browser and system optimizations */
@supports (-webkit-touch-callout: none) {
  html, body {
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
}

/* System-specific font stacks */
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 
               Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', 
               Arial, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Cross-browser smooth scrolling */
html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) var(--light-bg);
}

/* Webkit scrollbar customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--light-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

/* Cross-browser flex gap fallback */
.nav-links, .lang-switch {
  gap: 1.5rem;
  display: flex;
}
@supports not (gap: 1.5rem) {
  .nav-links > *, .lang-switch > * {
    margin-right: 1.5rem;
  }
  .nav-links > *:last-child, .lang-switch > *:last-child {
    margin-right: 0;
  }
}

/* Enhanced performance optimizations */
.header, .product-card, .service-card {
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* Cross-browser transitions */
.product-card, .service-card, .map-link {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-transition: -webkit-transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                      box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Touch device optimizations */
@media (hover: hover) and (pointer: fine) {
  .product-card:hover, .service-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  }
}

@media (hover: none) and (pointer: coarse) {
  .product-card:active, .service-card:active {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }
}

/* Enhanced mobile optimizations */
@media (max-width: 480px) {
  .product-card, .service-card {
    height: auto;
    min-height: 280px;
    max-height: 350px;
  }

  .card-image {
    height: auto;
    max-height: 65%;
    width: auto;
    max-width: 100%;
  }

  .hero-content h2 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
  }

  .hero-content p {
    font-size: clamp(1rem, 3vw, 1.5rem);
  }
}

/* Override dark mode preferences to maintain light theme */
@media (prefers-color-scheme: dark) {
  :root {
    /* Keep light mode colors */
    --primary-color: #1a4d2e;
    --primary-light: #2a6d3e;
    --primary-dark: #0a3d1e;
    --secondary-color: #ff9900;
    --secondary-light: #ffad33;
    --secondary-dark: #cc7a00;
    --text-color: #333333;
    --text-light: #666666;
    --background: #ffffff;
    --background-alt: #f8f9fa;
    --light-bg: #f5f5f5;
  }

  body {
    background-color: var(--background);
    color: var(--text-color);
  }

  .header {
    background: rgba(255, 255, 255, 0.98);
  }

  .nav-links {
    background: var(--background);
  }

  .product-card, .service-card {
    background: var(--background-alt);
    border: 1px solid rgba(0, 0, 0, 0.1);
  }

  .nav-links a {
    color: var(--text-color);
  }
}

/* Print optimization */
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .header {
    position: static;
    box-shadow: none;
  }

  .product-card, .service-card {
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none !important;
  }

  .hero {
    height: auto;
    background: none !important;
    color: var(--text-color) !important;
  }
}

/* Safari and iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  html, body {
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
    height: 100%;
    width: 100%;
    position: fixed;
    overflow-y: auto;
  }

  .header {
    position: -webkit-sticky;
    position: sticky;
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
  }

  .nav-links {
    -webkit-overflow-scrolling: touch;
  }

  .product-card, .service-card {
    -webkit-transform: translate3d(0,0,0);
    transform: translate3d(0,0,0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }

  .card-image {
    -webkit-transform: translate3d(0,0,0);
    transform: translate3d(0,0,0);
  }

  /* Fix for iOS dark mode */
  @media (prefers-color-scheme: dark) {
    .header {
      background: rgba(18, 18, 18, 0.8);
      -webkit-backdrop-filter: saturate(180%) blur(20px);
      backdrop-filter: saturate(180%) blur(20px);
    }

    .product-card, .service-card {
      -webkit-transform: translate3d(0,0,0);
      transform: translate3d(0,0,0);
    }
  }

  /* Fix for iOS scroll bounce effect */
  @supports (-webkit-touch-callout: none) {
    body {
      overscroll-behavior-y: none;
      -webkit-overflow-scrolling: touch;
    }
  }
}

/* Fix for Safari flexbox gap */
@supports not (gap: 1rem) {
  .nav-links > * {
    margin-right: 1rem;
  }
  .nav-links > *:last-child {
    margin-right: 0;
  }
  
  .products-grid, .services-grid {
    margin: -0.5rem;
  }
  
  .products-grid > *, .services-grid > * {
    margin: 0.5rem;
  }
}

/* Enhanced touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .product-card:active, .service-card:active {
    transform: translateY(-2px);
    -webkit-transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }

  .nav-links a {
    padding: 0.8rem;
    margin: 0.2rem 0;
  }

  .map-link {
    padding: 0.8rem 1.2rem;
  }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .menu-toggle {
    color: var(--text-color);
  }

  @media screen and (max-width: 850px) {
    .nav-links {
      background: rgba(18, 18, 18, 0.98);
    }
  }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  .nav-links {
    -webkit-overflow-scrolling: touch;
  }

  @media screen and (max-width: 850px) {
    .nav-links {
      padding-bottom: 4rem; /* Extra padding for iOS safe area */
    }
  }
}
