/* ============================================
   MOBILE MENU FIX - Clean Overlay & Panel
   ============================================ */

/* === Base Overflow Prevention === */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}

/* Header full width */
.header,
.nav-container,
.hero {
  margin: 0;
  width: 100%;
  max-width: 100%;
}

/* === iOS Scroll Lock === */
html.menu-open,
body.menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* Preserve scroll position variable is set via JS */
body.menu-open {
  top: var(--scroll-position, 0);
}

/* === Mobile Menu Overlay (Backdrop) === */
@media (max-width: 968px) {
  /* Overlay as ::before pseudo-element */
  .nav.active::before {
    content: '';
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    background: rgba(0, 0, 0, 0.7);
    z-index: 1; /* Below panel content */
    pointer-events: auto;
  }

  /* Optional: backdrop-filter with fallback */
  @supports (backdrop-filter: blur(4px)) {
    .nav.active::before {
      backdrop-filter: blur(4px);
      -webkit-backdrop-filter: blur(4px);
      background: rgba(0, 0, 0, 0.6);
    }
  }

  /* === Panel Container === */
  .nav.active {
    /* Override styles.css - remove gradient, use solid bg */
    background: var(--earth-black) !important;
    background-image: none !important;
    background-blend-mode: normal !important;
  }

  /* Panel inner content wrapper (nav-list) */
  .nav.active .nav-list {
    position: relative;
    z-index: 2; /* Above overlay */
    background: var(--earth-dark);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-height: calc(100vh - 140px);
    max-height: calc(100dvh - 140px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Mobile logo above nav-list */
  .nav.active .mobile-menu-logo {
    position: relative;
    z-index: 2;
  }

  /* Close button layering */
  .menu-toggle.active {
    z-index: 2002 !important; /* Above everything */
  }

  /* === Mobile Logo größer === */
  .nav.active .mobile-menu-logo {
    margin-bottom: var(--space-8);
  }

  .nav.active .mobile-menu-logo img {
    height: 100px;
    width: auto;
  }

  /* === Mobile CTA Button Fix === */
  .nav.active .nav-list > li:last-child {
    background: transparent;
    border-bottom: none;
    padding: var(--space-4);
  }

  .nav.active .nav-list > li > a.btn-primary,
  .nav.active .nav-list .btn.btn-primary {
    display: flex;
    width: auto;
    max-width: 280px;
    margin: 0 auto;
    padding: var(--space-4) var(--space-8);
    background: var(--gold-primary);
    color: var(--earth-black) !important;
    border-radius: var(--radius-full);
    font-size: var(--fs-base);
    font-weight: 700;
    text-align: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(167, 135, 73, 0.4);
    transition: all var(--transition-base);
  }

  .nav.active .nav-list > li > a.btn-primary:hover,
  .nav.active .nav-list .btn.btn-primary:hover {
    background: var(--gold-light);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(167, 135, 73, 0.5);
  }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  .nav.active,
  .nav.active::before,
  .nav.active .nav-list {
    animation: none !important;
    transition: none !important;
  }
}

/* === Focus Visible Enhancement === */
.nav.active a:focus-visible,
.nav.active button:focus-visible {
  outline: 2px solid var(--gold-primary);
  outline-offset: 2px;
}

/* ============================================
   SERVICE NAV BAR - Redesign
   ============================================ */

/* Scroll offset for sticky header */
html {
  scroll-behavior: smooth;
}

section[id] {
  scroll-margin-top: calc(var(--header-height, 80px) + 20px);
}

/* Desktop Service Nav Bar */
.service-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-8);
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--cream-dark);
  position: sticky;
  top: calc(var(--header-height, 80px) + 10px);
  z-index: 100;
}

.service-nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.service-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: var(--cream);
  color: var(--text-primary);
  border-radius: var(--radius-full);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-fast);
  border: 2px solid transparent;
}

.service-tab:hover {
  background: var(--gold-muted);
  color: var(--gold-dark);
  border-color: var(--gold-primary);
}

.service-tab.active {
  background: var(--gold-primary);
  color: var(--earth-black);
  border-color: var(--gold-primary);
}

.service-tab.active i {
  color: var(--earth-black);
}

.service-tab:focus-visible {
  outline: none;
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px var(--gold-muted);
}

.service-tab i {
  color: var(--gold-primary);
  font-size: 0.9em;
}

.service-nav-cta-wrapper {
  flex-shrink: 0;
}

.service-nav-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-size: var(--fs-sm);
}

/* Mobile Service Nav Bar */
@media (max-width: 768px) {
  .service-nav-bar {
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-4);
    position: static;
    margin-bottom: var(--space-6);
  }

  .service-nav-tabs {
    justify-content: center;
    gap: var(--space-2);
  }

  .service-tab {
    padding: var(--space-2) var(--space-4);
    font-size: var(--fs-xs);
  }

  .service-nav-cta-wrapper {
    width: 100%;
    text-align: center;
  }

  .service-nav-cta {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }

  /* Adjust scroll offset for mobile header */
  section[id] {
    scroll-margin-top: 100px;
  }
}

/* === Leistungen Page Mobile Improvements === */
@media (max-width: 768px) {
  /* Grid columns on mobile */
  .leistungen-grid {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  /* Card spacing */
  .leistung-card {
    margin: 0;
  }

  .leistung-info {
    padding: var(--space-5);
  }

  .leistung-info h3 {
    font-size: var(--fs-lg);
  }

  .leistung-info p {
    font-size: var(--fs-sm);
  }

  /* Flex sections stack properly */
  .leistungen-flex,
  .leistungen-flex.leistungen-reverse {
    flex-direction: column;
    gap: var(--space-6);
  }

  .leistungen-img {
    max-width: 100%;
    order: -1; /* Image always on top */
  }

  .leistungen-content {
    text-align: left;
  }

  .leistungen-content h2 {
    font-size: var(--fs-xl);
  }

  .leistungen-content h2::after {
    margin: var(--space-3) 0 0;
  }

  /* Section spacing */
  .section {
    padding: var(--space-6) var(--space-4);
    margin-bottom: var(--space-6);
  }

  /* List improvements */
  .section ul,
  .section ol {
    padding-left: var(--space-5);
    text-align: left;
  }

  .section li {
    margin-bottom: var(--space-3);
    line-height: 1.6;
  }

  /* CTA section */
  .cta-section {
    padding: var(--space-8) var(--space-4);
  }

  .cta-section h2 {
    font-size: var(--fs-lg);
  }
}

/* === Button Focus States === */
.btn:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible {
  outline: 3px solid var(--gold-light);
  outline-offset: 2px;
}

/* === Images Responsive === */
.leistungen-img img,
.leistung-img img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* Lazy load placeholder */
img[loading="lazy"] {
  background: var(--cream-dark);
}

/* ============================================
   LEISTUNGEN UNTERSEITEN - Fehlende Komponenten
   ============================================ */

/* === Service Flex Layout (obstbaumschnitt, textile-kronensicherungen) === */
.service-flex {
  display: flex;
  gap: var(--space-8);
  align-items: flex-start;
  text-align: left;
  margin-bottom: var(--space-6);
}

.service-flex.reverse {
  flex-direction: row-reverse;
}

.service-img {
  flex: 1;
  max-width: 400px;
}

.service-img img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.service-text {
  flex: 2;
}

.service-text h2 {
  font-size: var(--fs-2xl);
  margin-bottom: var(--space-4);
  color: var(--earth-black);
}

.service-text h2::after {
  content: '';
  display: block;
  width: 50px;
  height: 3px;
  background: var(--gold-primary);
  margin-top: var(--space-3);
  border-radius: var(--radius-full);
}

.service-text ul,
.service-text ol {
  padding-left: var(--space-5);
  margin-top: var(--space-4);
}

.service-text li {
  margin-bottom: var(--space-3);
  line-height: 1.7;
  color: var(--text-secondary);
}

.service-text li strong {
  color: var(--text-primary);
}

/* === Leistung Detail Layout (baumkontrolle, gehoelz-landschaftspflege) === */
.leistung-detail-flex {
  display: flex;
  gap: var(--space-10);
  align-items: flex-start;
  text-align: left;
}

.leistung-detail-img {
  flex: 1;
  max-width: 400px;
}

.leistung-detail-img img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.leistung-detail-info {
  flex: 2;
}

.leistung-detail-info h2 {
  font-size: var(--fs-2xl);
  margin-bottom: var(--space-4);
  color: var(--earth-black);
}

.leistung-detail-info h2::after {
  content: '';
  display: block;
  width: 50px;
  height: 3px;
  background: var(--gold-primary);
  margin-top: var(--space-3);
  border-radius: var(--radius-full);
}

.leistung-detail-info p {
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
  line-height: 1.7;
}

.leistung-detail-info ul {
  list-style: none;
  padding: 0;
  margin-top: var(--space-4);
}

.leistung-detail-info li {
  position: relative;
  padding-left: var(--space-6);
  margin-bottom: var(--space-3);
  line-height: 1.7;
  color: var(--text-secondary);
}

.leistung-detail-info li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 8px;
  height: 8px;
  background: var(--gold-primary);
  border-radius: 50%;
}

.leistung-detail-info li strong {
  color: var(--text-primary);
}

/* === Mobile Responsiveness for Service Layouts === */
@media (max-width: 900px) {
  .service-flex,
  .service-flex.reverse {
    flex-direction: column;
    gap: var(--space-6);
  }

  .service-img {
    max-width: 100%;
    order: -1; /* Image on top */
  }

  .service-text {
    text-align: left;
  }

  .service-text h2 {
    font-size: var(--fs-xl);
  }

  .leistung-detail-flex {
    flex-direction: column;
    gap: var(--space-6);
  }

  .leistung-detail-img {
    max-width: 100%;
    order: -1;
  }

  .leistung-detail-info h2 {
    font-size: var(--fs-xl);
  }
}

/* === Section Flex Layout für kronenpflege inline styles === */
@media (max-width: 768px) {
  .section[style*="display:flex"],
  .section[style*="display: flex"] {
    flex-direction: column !important;
    gap: var(--space-6) !important;
  }

  .section[style*="display:flex"] > div,
  .section[style*="display: flex"] > div {
    min-width: unset !important;
    flex: unset !important;
    width: 100% !important;
  }

  .section[style*="display:flex"] > div:first-child,
  .section[style*="display: flex"] > div:first-child {
    order: -1;
  }

  /* Override inline font-sizes on mobile */
  .section ul[style*="font-size"],
  .section ol[style*="font-size"] {
    font-size: var(--fs-base) !important;
  }
}

/* === Hero Wave aria-hidden fix === */
.hero-wave[aria-hidden="true"],
.hero-wave:not([aria-hidden]) {
  pointer-events: none;
}

/* === CTA Buttons consistent styling === */
.cta-section .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

/* === Service Card Icons === */
.service-card i {
  font-size: 2rem;
  color: var(--gold-primary);
  margin-bottom: var(--space-3);
  display: block;
}

/* === Section Images centered and responsive === */
.section > img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto var(--space-6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
  .section > img {
    max-width: 100%;
  }
}

/* === Hero icons in h1 === */
.hero h1 i {
  margin-right: var(--space-2);
  color: var(--gold-light);
}

/* ============================================
   DATENSCHUTZ CHECKBOX - DSGVO
   ============================================ */
.form-checkbox {
  margin-top: var(--space-4);
  margin-bottom: var(--space-6);
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-custom {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 2px solid var(--cream-dark);
  border-radius: var(--radius-sm);
  background: var(--cream);
  transition: all var(--transition-fast);
  position: relative;
  margin-top: 2px;
}

.checkbox-custom::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 7px;
  width: 5px;
  height: 10px;
  border: solid var(--white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform var(--transition-fast);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
  background: var(--gold-primary);
  border-color: var(--gold-primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
  transform: rotate(45deg) scale(1);
}

.checkbox-label input[type="checkbox"]:focus-visible + .checkbox-custom {
  outline: 2px solid var(--gold-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--gold-muted);
}

.checkbox-text {
  flex: 1;
}

.checkbox-text a {
  color: var(--gold-primary);
  text-decoration: underline;
  font-weight: 600;
}

.checkbox-text a:hover {
  color: var(--gold-dark);
}

/* Validation styling */
.checkbox-label input[type="checkbox"]:invalid:not(:focus):not(:placeholder-shown) + .checkbox-custom {
  border-color: #dc3545;
}

@media (max-width: 768px) {
  .checkbox-label {
    font-size: var(--fs-xs);
  }

  .checkbox-custom {
    width: 20px;
    height: 20px;
  }
}

/* === Print styles === */
@media print {
  .menu-toggle,
  .top-bar,
  .hero-wave,
  .service-nav-bar {
    display: none !important;
  }

  .header {
    position: static;
  }

  .section {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
