/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2d5016;
    --secondary-color: #8B4513;
    --accent-color: #FF6B35;
    --text-color: #0f0f0f;
    --text-light: #4a4a4a;
    --bg-color: #fff;
    --bg-alt: #f8f9fa;
    --border-color: #e0e0e0;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --font-primary: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition: all 0.3s ease;
}

body {
    font-family: var(--font-primary);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    /* iOS specific fixes */
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px; /* Account for fixed header on mobile (60px + 20px buffer) */
}

@media (min-width: 768px) {
    html {
        scroll-padding-top: 100px; /* Account for fixed header on desktop (80px + 20px buffer) */
    }
}

/* Navigation Styles - Mobile First */
.main-nav {
    background: var(--bg-color);
    box-shadow: var(--shadow);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.main-nav .nav-menu {
    background: var(--primary-color) !important;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    gap: 1rem;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    transition: var(--transition);
}

.nav-logo:hover {
    color: var(--accent-color);
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--primary-color);
    transition: var(--transition);
}

svg.logo-icon {
    width: 32px;
    height: 32px;
}

.nav-logo:hover .logo-icon {
    transform: scale(1.1);
}

/* Direct SVG element targeting for hover */
.logo-icon:hover .logo-sawblade,
img.logo-icon:hover + svg .logo-sawblade,
.nav-logo:hover img.logo-icon .logo-sawblade {
    fill: var(--accent-color) !important;
}

/* Special SVG hover effect for sawblade */
.nav-logo:hover .logo-icon .logo-sawblade {
    fill: var(--accent-color) !important;
    transition: fill 0.3s ease;
}

.nav-logo .logo-icon .logo-sawblade {
    transition: fill 0.3s ease;
}

.nav-logo .logo-icon .logo-handle {
    fill: var(--primary-color) !important;
    transition: fill 0.3s ease;
}

.nav-logo:hover .logo-icon .logo-handle {
    fill: var(--primary-color) !important;
}

@media (max-width: 768px) {
    .logo-icon {
        width: 28px;
        height: 28px;
    }
    
    svg.logo-icon {
        width: 28px;
        height: 28px;
    }
    
    .nav-logo {
        font-size: 1.3rem;
    }
}

.nav-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* iOS touch optimizations */
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    align-items: center;
}

.hamburger {
    width: 25px;
    height: 3px;
    background: var(--primary-color);
    transition: var(--transition);
}

.nav-toggle[aria-expanded="true"] .hamburger:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.nav-toggle[aria-expanded="true"] .hamburger:nth-child(2) {
    opacity: 0;
}

.nav-toggle[aria-expanded="true"] .hamburger:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--primary-color);
    box-shadow: var(--shadow);
    list-style: none;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
}

.nav-menu.active {
    display: block;
}

.nav-item {
    border-top: 1px solid rgba(255,255,255,0.2);
}

.nav-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    text-decoration: none;
    color: white;
    font-weight: 500;
    transition: var(--transition);
    /* iOS touch optimizations */
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    touch-action: manipulation;
    min-height: 44px;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.dropdown-arrow {
    font-size: 0.8rem;
    transition: var(--transition);
}


.nav-dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* Mobile-only navigation links */
.mobile-only {
    display: none;
}

@media (max-width: 991px) {
    .mobile-only {
        display: block;
    }
    
    .mobile-only .nav-sublink {
        background: var(--bg-alt);
        font-weight: 600;
        color: var(--primary-color);
        border-bottom: 1px solid var(--border-color);
    }
    
    .mobile-only .nav-sublink:hover {
        background: var(--primary-color);
        color: white;
    }
}

.nav-submenu {
    display: none;
    background: var(--bg-alt);
    list-style: none;
}

.nav-submenu.active {
    display: block;
}

/* Neue Menü-Styling */
.nav-submenu-header {
    font-weight: bold;
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-color);
    border-left: 3px solid var(--primary-color);
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

.nav-sublink {
    display: block;
    padding: 0.75rem 2rem;
    text-decoration: none;
    color: var(--text-light);
    transition: var(--transition);
    /* iOS touch optimizations */
    -webkit-tap-highlight-color: rgba(45, 80, 22, 0.1);
    touch-action: manipulation;
    min-height: 44px;
}

.nav-sublink:hover {
    background: var(--border-color);
    color: var(--primary-color);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.nav-phone {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 500;
    font-size: 0.9rem;
}

.phone-text {
    display: none; /* Hide phone text on mobile */
    margin-left: 0.3rem;
}

.nav-cta {
    background: var(--accent-color);
    color: white;
    padding: 0.75rem 1.25rem;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Improved contrast - ensure sufficient color difference */
    background: #d63520;
    border: 2px solid transparent;
}

.nav-cta:hover {
    background: #8B4513;
    transform: translateY(-1px);
    border-color: white;
}

/* Sticky Bottom Bar - Mobile */
.sticky-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--primary-color);
    display: flex;
    z-index: 999;
}

.sticky-phone,
.sticky-cta {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-decoration: none;
    color: white;
    font-weight: bold;
    transition: var(--transition);
}

.sticky-phone {
    background: var(--secondary-color);
}

.sticky-cta {
    background: #d63520;
    min-height: 60px;
}

.sticky-phone:hover,
.sticky-cta:hover {
    opacity: 0.9;
}

.phone-icon {
    margin-right: 0.5rem;
}

/* Main Content */
main {
    margin-top: 60px;
    margin-bottom: 80px;
    min-height: calc(100vh - 140px);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.section {
    padding: 2rem 0;
}

.hero {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 2rem 1rem;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    position: relative;
}

.hero h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #d63520;
    color: white;
    padding: 1rem 2rem;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    margin-top: 1rem;
    transition: var(--transition);
    min-height: 48px;
    min-width: 120px;
    border: 2px solid transparent;
    font-size: 1rem;
}

.cta-button:hover {
    background: #8B4513;
    border-color: white;
    transform: translateY(-1px);
    color: white;
}

.card {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.card h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.price {
    font-size: 1.5rem;
    font-weight: bold;
    color: #d63520;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

/* Desktop Styles */
@media (min-width: 768px) {
    .main-nav {
        background: var(--bg-color);
    }
    
    .nav-header {
        height: 80px;
        background: var(--bg-color);
    }
    
    .nav-toggle {
        display: none;
    }
    
    .nav-menu {
        display: flex;
        position: static;
        background: var(--primary-color) !important;
        box-shadow: none;
        align-items: center;
        flex: 1;
        justify-content: center;
        border-radius: 0;
        margin: 0;
        width: 100vw;
        margin-left: calc(-50vw + 50%);
    }
    
    .nav-item {
        border: none;
        position: relative;
    }
    
    .nav-item:not(:last-child) {
        border-right: 1px solid rgba(255,255,255,0.2);
    }
    
    .nav-link {
        padding: 1rem 1.5rem;
        white-space: nowrap;
        color: white;
    }
    
    .nav-link:hover {
        background: rgba(255,255,255,0.1);
        color: white;
    }
    
    .nav-submenu {
        display: block;
        position: absolute;
        top: 100%;
        left: 0;
        min-width: 280px;
        background: var(--bg-color);
        box-shadow: var(--shadow);
        border-radius: 8px;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: var(--transition);
        z-index: 1001;
    }
    
    /* Desktop Submenu Header Styling */
    @media (min-width: 992px) {
        .nav-submenu-header {
            background: var(--primary-color);
            color: white;
            font-size: 0.75rem;
            padding: 0.4rem 1rem;
            margin: 0;
            border-left: none;
        }
        
        .nav-submenu .nav-divider {
            margin: 0.3rem 0;
            background: var(--border-color);
        }
        
        .nav-sublink {
            padding: 0.6rem 1.5rem;
            font-size: 0.95rem;
        }
        
        .nav-sublink:hover {
            background: var(--bg-alt);
            padding-left: 2rem;
        }
    }
    
    /* Desktop hover states */
    .nav-dropdown:hover .nav-submenu,
    .nav-dropdown.hover .nav-submenu,
    .nav-submenu:hover {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(0) !important;
        display: block !important;
    }
    
    /* Desktop-specific nav-actions styling */
    .nav-actions {
        gap: 1rem;
    }
    
    .nav-phone {
        font-size: 1rem;
    }
    
    .phone-text {
        display: inline; /* Show phone text on desktop */
        margin-left: 0.5rem;
    }
    
    .nav-cta {
        background: #d63520;
        color: white;
        padding: 0.75rem 1.5rem;
        text-decoration: none;
        border-radius: 5px;
        font-weight: bold;
        transition: var(--transition);
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 2px solid transparent;
    }
    
    .nav-cta:hover {
        background: #8B4513;
        border-color: white;
    }
    
    .sticky-bottom-bar {
        display: none;
    }
    
    main {
        margin-top: 80px;
        margin-bottom: 0;
    }
    
    .hero h1 {
        font-size: 3rem;
    }
    
    .hero p {
        font-size: 1.2rem;
    }
}

@media (min-width: 1024px) {
    .nav-container {
        padding: 0 2rem;
    }
    
    .container {
        padding: 0 2rem;
    }
    
    .section {
        padding: 3rem 0;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.grid {
    display: grid;
    gap: 1rem;
}

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

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus States - Improved visibility */
.nav-link:focus,
.nav-sublink:focus,
.nav-toggle:focus,
.cta-button:focus,
.nav-cta:focus {
    outline: 3px solid #0066cc;
    outline-offset: 3px;
    box-shadow: 0 0 0 1px white, 0 0 0 4px #0066cc;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .cta-button, .nav-cta, .sticky-cta {
        background: #000000;
        border: 2px solid #ffffff;
    }
    
    .price {
        color: #000000;
        background: #ffffff;
        padding: 0.2rem 0.4rem;
        border-radius: 3px;
    }
}

/* iOS-specific optimizations */
.ios-device .nav-dropdown > .nav-link {
    /* Prevent iOS from treating dropdown toggles as regular links */
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.ios-device .nav-menu {
    /* Better scrolling on iOS */
    -webkit-overflow-scrolling: touch;
}

.ios-device .nav-sublink {
    /* Ensure proper touch targets on iOS */
    position: relative;
}

.ios-device .nav-sublink::before {
    /* Increase touch area for better accessibility */
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 44px;
}

/* Image Optimization */
img {
    max-width: 100%;
    height: auto;
    transition: var(--transition);
}

img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Service and Product Images */
.service-image,
.product-image,
.tech-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 1rem;
    background: var(--bg-alt);
    position: relative;
}

.service-image img,
.product-image img,
.tech-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.service-image img:hover,
.product-image img:hover,
.tech-image img:hover {
    transform: scale(1.05);
}

/* Loading placeholder */
.service-image::before,
.product-image::before,
.tech-image::before {
    content: "Lädt...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Technology showcase */
.technology-showcase {
    background: var(--bg-alt);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.tech-image {
    height: 250px;
}

/* Enhanced Touch Targets */
a, button, input, select, textarea {
    min-height: 44px;
    min-width: 44px;
}

/* Ensure adequate spacing between interactive elements */
.cta-button + .cta-button {
    margin-left: 0.5rem;
}

/* Card link improvements */
.card h3 a, .card a {
    padding: 0.5rem;
    margin: -0.25rem;
    border-radius: 3px;
    transition: var(--transition);
    display: inline-block;
    min-height: 44px;
    min-width: 44px;
    line-height: 1.4;
}

.card h3 a:focus, .card a:focus {
    background: rgba(45, 80, 22, 0.1);
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Specific styling for arrow links in lists */
li a[href*="wissen.php"],
li a[href*="faq.php"],
li a[href*="umrechnungen.php"],
li a[href*="heizkostenvergleich.php"],
li a[href*="brennholz-"] {
    padding: 0.75rem 0.5rem;
    margin: -0.5rem -0.25rem;
    display: block;
    min-height: 44px;
    line-height: 1.4;
    border-radius: 4px;
}

li a[href*="wissen.php"]:hover,
li a[href*="faq.php"]:hover,
li a[href*="umrechnungen.php"]:hover,
li a[href*="heizkostenvergleich.php"]:hover,
li a[href*="brennholz-"]:hover {
    background: rgba(45, 80, 22, 0.1);
    color: var(--primary-color);
    text-decoration: none;
}

/* Better color contrast for footer text */
.footer {
    background: #1a1a1a;
}

.footer h5 {
    color: #FF9F1C;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.9);
}

.footer-links a:hover {
    color: #FF9F1C;
}

/* Print Styles */
@media print {
    .main-nav,
    .sticky-bottom-bar {
        display: none;
    }
    
    main {
        margin: 0;
    }
    
    .service-image,
    .product-image,
    .tech-image {
        height: auto;
        page-break-inside: avoid;
    }
}