/* ===== SERVICES PAGE STYLES ===== */

/* ===== BODY OVERFLOW CONTROL ===== */
body.template-main {
    overflow: hidden;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
}

html.template-main {
    overflow: hidden;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
}

/* ===== DESKTOP SERVICES LAYOUT ===== */
.desktop-services-layout {
    position: relative;
    width: 100%;
    height: 100vh;
    background: #EBEBEB;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* ===== MOBILE SERVICES CONTENT ===== */
#mobile-services-header-container,
.mobile-services-header {
    display: none; /* Hidden by default, shown on mobile */
}

.mobile-services-content {
    display: none; /* Hidden by default, shown on mobile */
}

/* ===== TEMPLATE BACKGROUND ===== */
.template-background {
    position: absolute;
    bottom: 0; /* Position at bottom instead of top */
    left: 0;
    width: 100%;
    height: 200px; /* Fixed height of 200px */
    z-index: 1;
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.65s ease;
}

.template-background .bg-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 1;
    transition: opacity 0.65s ease;
}

.template-background .bg-image-crossfade {
    z-index: 1;
    opacity: 0;
}

.bg-overlay {
    position: absolute;
    bottom: 0; /* Position at bottom */
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0); /* No overlay - same as kompetenzen */
    z-index: 2;
}

/* Override responsive.css background positioning for services */
.template-main .template-background {
    position: absolute;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 200px !important;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.65s ease;
}

.template-main .template-background .bg-image {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    object-position: center;
}

.template-main .bg-overlay {
    position: absolute;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.4) !important;
    z-index: 2;
}

/* ===== SUB-NAVIGATION CONTAINER STYLES ===== */
.sub-nav-container {
    --sub-nav-indicator-top: 0px;
    --sub-nav-indicator-height: 28px;
    --sub-nav-line-top: 28px;
    --sub-nav-line-height: calc(100% - 28px);
    position: absolute;
    top: 160px;
    left: calc(40px + 20vw);
    transform: translateX(-50%);
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.sub-nav-indicator {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 36px;
    width: 5px;
    pointer-events: none;
    z-index: 100;
}

.sub-nav-indicator-rectangle {
    position: absolute;
    top: var(--sub-nav-indicator-top);
    left: 1px;
    width: 4px;
    height: var(--sub-nav-indicator-height);
    background: var(--duller-grey, #6A6A6A);
    transition: top 0.35s ease, height 0.35s ease;
}

.sub-nav-indicator-line {
    position: absolute;
    top: var(--sub-nav-line-top);
    left: 0;
    width: 1px;
    height: var(--sub-nav-line-height);
    background: var(--duller-grey, #6A6A6A);
    transition: top 0.35s ease, height 0.35s ease;
}

/* ===== DESKTOP RESPONSIVE BREAKPOINTS ===== */
@media (min-width: 1440px) {
    .desktop-services-layout .sub-nav-container {
        left: calc(40px + 20vw);
    }
}

@media (max-width: 1439px) and (min-width: 1025px) {
    .desktop-services-layout .sub-nav-container {
        left: calc(40px + 20vw);
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    .desktop-services-layout .sub-nav-container {
        left: calc(40px + 20vw);
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    .desktop-services-layout .sub-nav-container {
        left: 4%;
        top: 90px;
        transform: none;
    }

    .desktop-services-layout .sub-nav-row-link.active .sub-nav-item,
    .desktop-services-layout .sub-nav-row-link.active .sub-nav-title {
        font-size: 16px;
    }
}

/* ===== SUB-NAVIGATION STYLES ===== */
.sub-nav-row-link {
    display: block;
    width: 100%;
    height: 28px;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.3s ease;
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 101;
}

.sub-nav-row-link:hover {
    opacity: 0.8;
}

.sub-nav-row-link.active .sub-nav-item {
    opacity: 1;
}

.sub-nav-row-link.active .sub-nav-title {
    opacity: 1;
    font-weight: 500;
}

.sub-nav-item-container {
    display: grid;
    grid-template-columns: 24px 12px 5px 10px minmax(0, 1fr);
    align-items: center;
    height: 28px;
}

.sub-nav-item {
    grid-column: 1;
    width: 24px;
    font-family: 'Roboto', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.4;
    letter-spacing: 2%;
    color: #4D4D4D;
    opacity: 0.6;
    text-align: center;
    transition: opacity 0.3s ease, font-weight 0.3s ease;
}

.sub-nav-title {
    grid-column: 5;
    font-family: 'Roboto', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.4;
    letter-spacing: 2%;
    color: #6A6A6A;
    opacity: 0.6;
    transition: opacity 0.3s ease, font-weight 0.3s ease;
    white-space: nowrap;
}

/* ===== CONTENT CONTAINER STYLES ===== */
/* Base content container - will be overridden by .template-main .content-container */
.content-container {
    /* Base styles removed to prevent conflicts */
}

/* ===== PAGE TRANSITION STYLES ===== */
/* Smooth fade transitions between pages */
#page-content,
#mobile-page-content {
    transition: opacity 0.15s ease-in-out;
}

.content-grid {
    display: flex; /* Changed to flex like kompetenzen */
    flex-direction: column;
    width: 100%;
    z-index: 3;
    flex: none; /* Don't expand like kompetenzen */
    overflow: visible;
}

.right-column {
    width: 100%; /* Take full width like kompetenzen */
    max-width: 700px; /* Same max-width as kompetenzen */
}

.main-text-content {
    display: flex;
    flex-direction: column;
    gap: 40px;
    width: 100%;
    max-width: 700px;
}

.text-paragraph p {
    font-family: 'Roboto', sans-serif;
    font-weight: 400;
    font-size: 16px; /* Same size as kompetenzen */
    line-height: 1.4;
    letter-spacing: 2%;
    color: #6A6A6A;
    margin: 0;
    width: 100%;
}

/* ===== NEXT BUTTON STYLES ===== */
.next-button {
    position: relative; /* Same as kompetenzen */
    margin-top: 24px; /* Same spacing as kompetenzen */
    display: flex;
    align-items: center;
    gap: 12px; /* Same gap as kompetenzen */
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 3;
    align-self: flex-start; /* Align button to the left side of the text column */
    margin-left: 0;
    flex-shrink: 0;
}

.next-link {
    position: relative;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 3px 6px 3px 0;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    pointer-events: auto;
}

.next-link:hover {
    opacity: 0.8;
}

.next-link:hover .next-text {
    font-weight: 700; /* Make text bold on hover */
}

.next-text {
    font-family: 'Roboto', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.4;
    letter-spacing: 2%;
    color: #6A6A6A; /* Changed from #FFFFFF to duller grey */
    pointer-events: none;
}

.next-arrow {
    width: 20px;
    height: 10px;
    stroke: #6A6A6A !important; /* Changed from #FFFFFF to duller grey */
    fill: none;
    pointer-events: none;
}

/* Ensure SVG path is duller grey */
.next-arrow path {
    stroke: #6A6A6A !important; /* Changed from #FFFFFF to duller grey */
    fill: none;
}

/* ===== MOBILE BREAKPOINT ===== */
@media (max-width: 480px) {
    :root {
        --mobile-services-header-height: 172px;
        --mobile-services-bottom-image-height: clamp(150px, 24dvh, 200px);
    }

    html.template-main,
    body.template-main {
        overflow: hidden !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
    }

    .sticky-header,
    .left-sidebar {
        display: none !important;
    }

    #mobile-services-header-container,
    .mobile-services-header {
        display: block !important;
    }

    .mobile-services-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: var(--mobile-services-header-height);
        background: #EBEBEB;
        z-index: 10000;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .mobile-header-content {
        position: relative;
        padding: 14px;
        display: flex;
        flex-direction: column;
        gap: 20px;
        z-index: 1000;
    }

    .mobile-header-top-row {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        min-height: 24px;
        position: relative;
    }

    .mobile-back-button-container,
    .mobile-logo-container {
        display: flex;
        align-items: center;
        height: 100%;
    }

    .mobile-back-button {
        color: #6A6A6A !important;
        text-decoration: none;
        font-family: 'Roboto', sans-serif;
        font-size: 16px;
        font-weight: 700;
        padding: 0;
        line-height: 1;
        display: flex;
        align-items: center;
        position: static !important;
        top: auto !important;
        left: auto !important;
        z-index: auto !important;
        background: none !important;
        border: none !important;
        cursor: pointer;
    }

    .mobile-services-header .mobile-current-section-title {
        display: flex;
        color: #6A6A6A !important;
        font-family: 'Inter', sans-serif;
        font-size: 16px;
        font-weight: 700 !important;
        line-height: 1;
    }

    .mobile-logo {
        height: 20px;
        width: auto;
        min-width: 27px;
        filter: brightness(0) saturate(100%) invert(42%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(94%) contrast(92%) !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .mobile-logo-link {
        display: block;
        text-decoration: none;
    }

    .mobile-services-back {
        color: #6A6A6A;
        text-decoration: none;
        font-family: 'Roboto', sans-serif;
        font-size: 16px;
        font-weight: 400;
        line-height: 1.171875em;
        letter-spacing: 2%;
        text-align: center;
        writing-mode: vertical-rl;
        text-orientation: mixed;
        transform: rotate(180deg);
        transition: opacity 0.3s ease;
        width: 19px;
        height: auto;
        flex-shrink: 0;
        align-self: start;
        padding: 0;
    }

    .mobile-services-back:hover {
        opacity: 0.8;
    }

    .mobile-indicator {
        --sub-nav-indicator-top: 8px;
        --sub-nav-indicator-height: 17px;
        --sub-nav-line-top: 27px;
        --sub-nav-line-height: calc(100% - 27px);
        width: 5px;
        height: 100%;
        display: flex;
        flex-direction: column;
        position: relative;
        transition: transform 0.3s ease;
        flex-shrink: 0;
        align-self: stretch;
        padding: 6px 0;
    }

    .mobile-indicator-rectangle {
        width: 4px;
        height: var(--sub-nav-indicator-height);
        background: #6A6A6A;
        margin-left: 1px;
        position: absolute;
        top: var(--sub-nav-indicator-top);
        transition: top 0.35s ease, height 0.35s ease;
    }

    .mobile-indicator-line {
        width: 1px;
        height: var(--sub-nav-line-height);
        background: #6A6A6A;
        margin: 0;
        position: absolute;
        top: var(--sub-nav-line-top);
        left: 0;
        transition: top 0.35s ease, height 0.35s ease;
    }

    .desktop-services-layout {
        display: none !important;
    }
    
    .mobile-services-content {
        display: block !important;
        position: fixed;
        top: var(--mobile-services-header-height);
        right: 0;
        bottom: var(--mobile-services-bottom-image-height);
        left: 0;
        padding: 20px;
        margin-top: 0;
        background: #EBEBEB;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        z-index: 3;
        box-sizing: border-box;
        -webkit-overflow-scrolling: touch;
    }
    
    .mobile-content {
        margin-bottom: 12px; /* Same as kompetenzen */
    }
    
    .mobile-text-paragraph p {
        font-family: 'Roboto', sans-serif;
        font-weight: 400;
        font-size: 16px; /* Same size as kompetenzen */
        line-height: 1.4;
        letter-spacing: 2%;
        color: #6A6A6A; /* Same color as kompetenzen */
        margin: 0; /* Same margin as kompetenzen */
    }
    
    .mobile-next-button {
        margin-top: 12px; /* Same as kompetenzen */
    }

    .mobile-services-bottom-image {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100vw;
        height: var(--mobile-services-bottom-image-height);
        margin: 0;
        overflow: hidden;
        z-index: 1;
        pointer-events: none;
    }

    .mobile-services-bottom-image .mobile-bg-image {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center bottom;
        transition: opacity 0.65s ease;
    }

    .mobile-services-bottom-image .mobile-bg-image-crossfade,
    .mobile-services-bottom-image .bg-image-crossfade {
        z-index: 1;
        opacity: 0;
    }

    .mobile-services-bottom-image .mobile-bg-overlay {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0);
        z-index: 2;
        pointer-events: none;
    }
    
    .mobile-next-link {
        position: relative;
        z-index: 4;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        min-height: 34px;
        padding: 3px 6px 3px 0;
        text-decoration: none;
        color: inherit;
        transition: all 0.3s ease;
        pointer-events: auto;
    }
    
    .mobile-next-link:hover {
        opacity: 0.8;
    }
    
    .mobile-next-text {
        font-family: 'Roboto', sans-serif;
        font-weight: 400;
        font-size: 16px;
        line-height: 1.4;
        letter-spacing: 2%;
        color: #6A6A6A; /* Same color as kompetenzen */
        pointer-events: none;
    }
    
    .mobile-next-arrow {
        width: 20px;
        height: 10px;
        stroke: #6A6A6A; /* Same color as kompetenzen */
        fill: none;
        pointer-events: none;
    }
}

/* ===== MOBILE SUB-NAVIGATION STYLES ===== */
/* These styles are needed to work with responsive.css */
.mobile-sub-nav-container {
    display: none; /* Hidden by default, shown on mobile */
}

@media (max-width: 480px) {
    .mobile-sub-nav-container {
        position: relative;
        z-index: 10;
        padding: 0;
        display: block !important;
        width: 100%;
    }

    .mobile-services-back {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 2;
    }

    .mobile-sub-nav-menu {
        display: grid;
        grid-template-columns: 24px 12px 5px 10px max-content;
        align-items: start;
        width: fit-content;
        max-width: 100%;
        margin-inline: auto;
    }

    .mobile-indicator {
        grid-column: 3;
        grid-row: 1;
        align-self: stretch;
    }
    
    .mobile-sub-nav-links {
        display: flex !important;
        flex-direction: column !important;
        grid-column: 1 / 6;
        grid-row: 1;
        gap: 2px;
        flex: 1;
        width: max-content;
        align-items: stretch;
        flex-wrap: nowrap;
        align-self: stretch;
    }
    
    .mobile-sub-nav-row-link {
        display: block !important;
        text-decoration: none;
        color: inherit;
        padding: 0;
        width: max-content;
        flex-shrink: 0;
        box-sizing: border-box;
        transition: all 0.3s ease;
    }
    
    .mobile-sub-nav-row-link:hover {
        opacity: 0.8;
    }
    
    .mobile-sub-nav-item-container {
        display: grid !important;
        grid-template-columns: 24px 12px 5px 10px max-content;
        align-items: center;
        min-height: 24px;
        width: max-content;
    }
    
    .mobile-sub-nav-item {
        grid-column: 1;
        font-family: 'Roboto', sans-serif;
        font-weight: 400;
        font-size: 16px;
        color: #6A6A6A;
        opacity: 0.6;
    }
    
    .mobile-sub-nav-title {
        grid-column: 5;
        font-family: 'Roboto', sans-serif;
        font-weight: 400;
        font-size: 16px;
        color: #6A6A6A;
        opacity: 0.8;
        white-space: nowrap;
    }
    
    .mobile-sub-nav-row-link.active .mobile-sub-nav-item,
    .mobile-sub-nav-row-link.active .mobile-sub-nav-title {
        opacity: 1;
        font-weight: 700;
        color: #6A6A6A;
    }
}

/* ===== CRITICAL OVERRIDES FOR RESPONSIVE.CSS ===== */
/* Ensure services page works with responsive.css structure */

/* Prevent any page-level overflow */
.template-main {
    overflow: hidden !important;
    width: 100% !important;
    height: 100vh !important;
}

/* ===== ENGINEERING EVOLUTION TEXT STYLING ===== */
.template-main .bottom-tagline {
    color: #6A6A6A !important; /* Darker grey text for all services subpages */
}

/* ===== FOOTER STYLING ===== */
/* Make footer elements use the new grey color for services page */
.template-main .footer-language-switcher {
    color: #AFAFAF !important; /* New grey color for services page */
}

.template-main .footer-language-switcher .lang-active,
.template-main .footer-language-switcher .lang-separator,
.template-main .footer-language-switcher .lang-option {
    color: #AFAFAF !important; /* New grey color for services page */
}

/* ===== PAGE 4 BACKGROUND STYLING ===== */
/* Fade background image out for page 4 (Innovation/ TRIZ) */
.template-main[data-page="innovation-triz"] .template-background {
    opacity: 0 !important;
    pointer-events: none;
}

@media (max-width: 480px) {
    .template-main[data-page="innovation-triz"] .mobile-services-bottom-image {
        display: none !important;
    }

    .template-main[data-page="innovation-triz"] .mobile-services-content {
        bottom: 0 !important;
    }

    .template-main[data-page="innovation-triz"] #mobile-background-image {
        display: none !important;
    }
}

/* ===== PAGE 4 SVG STYLING ===== */
/* Ensure SVG displays properly on page 4 */
.template-main[data-page="innovation-triz"] .text-paragraph img,
.template-main[data-page="innovation-triz"] .mobile-text-paragraph img {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
    margin: 0 auto !important;
    /* No border-radius or box-shadow for clean SVG display */
}

/* ===== PAGE 4 LAYOUT STYLING ===== */
.template-main[data-page="innovation-triz"] .svg-content {
    position: fixed !important; /* Use fixed positioning to ensure it's positioned relative to viewport */
    left: calc(40px + 20vw - 130px) !important; /* Align with sub-nav left edge */
    bottom: calc(100vh - var(--services-main-nav-bottom, 704px)) !important;
    width: 545px !important; /* 10% larger than previous 495px */
    z-index: 5 !important;
    /* Ensure SVG is positioned relative to the viewport, not the content container */
    transform: none !important;
    opacity: 0;
    animation: trizGraphicFadeIn 0.65s ease 0.15s forwards;
}

@keyframes trizGraphicFadeIn {
    to {
        opacity: 1;
    }
}

.template-main[data-page="innovation-triz"] .svg-content img {
    width: 100% !important;
    height: auto !important;
    display: block !important;
}

/* Ensure text content is properly positioned */
.template-main[data-page="innovation-triz"] .text-content {
    position: relative !important;
    z-index: 3 !important;
}

/* Mobile-specific SVG styling for page 4 */
@media (max-width: 480px) {
    .template-main[data-page="innovation-triz"] .mobile-text-paragraph img {
        margin: 32px auto !important;
        max-width: 90% !important;
    }
    
    /* Mobile SVG positioning */
    .template-main[data-page="innovation-triz"] .svg-content {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        bottom: auto !important;
        width: 100% !important;
        margin: 32px 0 !important;
    }
}

/* Responsive SVG positioning for different screen sizes - match sub-nav exactly */
@media (max-width: 1439px) and (min-width: 1025px) {
    .template-main[data-page="innovation-triz"] .svg-content {
        left: calc(40px + 20vw - 130px) !important;
        bottom: calc(100vh - var(--services-main-nav-bottom, 704px)) !important;
        width: 545px !important; /* 10% larger than previous 495px */
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    .template-main[data-page="innovation-triz"] .svg-content {
        left: calc(40px + 20vw - 130px) !important;
        bottom: calc(100vh - var(--services-main-nav-bottom, 704px)) !important;
        width: 545px !important; /* 10% larger than previous 495px */
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    .template-main[data-page="innovation-triz"] .svg-content {
        left: 4% !important; /* Match sub-nav left: 4% */
        bottom: calc(100vh - var(--services-main-nav-bottom, 704px)) !important;
        width: 454px !important; /* 10% larger than previous 413px */
    }
}

/* ===== HEADER ELEMENT STYLING ===== */
/* Make header elements use the new grey color for services page */
.template-main #header-container *,
.template-main #nav-container * {
    color: #AFAFAF !important; /* New grey color for services page */
}

/* Ensure specific header elements use the new grey color */
.template-main .header-logo,
.template-main .header-logotype,
.template-main .nav-links a,
.template-main .nav-links button,
.template-main .header-actions button,
.template-main .header-actions a {
    color: #AFAFAF !important; /* New grey color for services page */
}

/* ===== HEADER LOGO STYLING ===== */
/* Make both header logos use the new grey color for services page */
.template-main .header-logo {
    filter: brightness(0) saturate(100%) invert(69%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(1.1) contrast(1) !important; /* #AFAFAF - new grey color */
}

.template-main .header-logotype {
    filter: brightness(0) saturate(100%) invert(69%) sepia(0%) hue-rotate(0deg) brightness(1.1) contrast(1) !important; /* #AFAFAF - new grey color */
}

/* ===== MAIN NAVIGATION STYLING ===== */
/* Note: All navigation styling is now handled by the nuclear option overrides below */

/* Maximum specificity override for language switcher elements */
html body.template-main .language-switcher,
html body.template-main .lang-active,
html body.template-main .lang-separator,
html body.template-main .lang-option {
    color: #8F8F8F !important; /* Lighter grey - same as main page sections 3,4,5 */
}

/* ===== NUCLEAR OPTION OVERRIDES FOR NAVIGATION ===== */
/* Override ALL navigation colors with maximum specificity */
html body.template-main .left-sidebar .nav-item,
html body.template-main .left-sidebar .nav-item:not(.active),
html body.template-main .left-sidebar .nav-item:hover {
    color: #AFAFAF !important; /* New grey color for non-active navigation */
}

/* Active navigation element uses duller grey */
html body.template-main .left-sidebar .nav-item.active {
    color: #8F8F8F !important; /* Active navigation grey */
}

/* Override indicator and separator colors */
html body.template-main .left-sidebar .indicator-line {
    background: #AFAFAF !important; /* New grey color for services page */
}

html body.template-main .left-sidebar .nav-separator {
    background: #AFAFAF !important; /* New grey color for services page */
}

/* Override language switcher colors with maximum specificity */
html body.template-main .left-sidebar .language-switcher,
html body.template-main .left-sidebar .lang-active,
html body.template-main .left-sidebar .lang-separator,
html body.template-main .left-sidebar .lang-option {
    color: #AFAFAF !important; /* New grey color for services page */
}

/* ===== SECTION 5 POSITIONING FIXES ===== */
/* Ensure section 5 content is properly positioned when navigating from sub-pages */
.template-main #uber-uns .uber-uns-bottom-section {
    position: fixed !important;
    left: var(--content-left-margin) !important;
    bottom: 160px !important;
    width: calc(100vw - var(--content-left-margin) - var(--content-right-margin)) !important;
    z-index: 10 !important;
}

/* Force proper positioning for section 5 content */
.template-main #uber-uns .uber-uns-content {
    position: absolute !important;
    top: 166px !important;
    left: var(--content-left-margin) !important;
    width: calc(100vw - var(--content-left-margin) - 40px) !important;
    z-index: 4 !important;
}

/* Override sub-nav positioning for services */
.template-main .sub-nav-container {
    position: absolute !important;
    top: 160px !important;
    z-index: 100 !important;
}

/* ===== OVERRIDE CONFLICTING STYLESHEET RULES ===== */
/* Override the conflicting left: 20% rule from responsive.css */
.template-main .sub-nav-container {
    left: calc(40px + 20vw) !important;
    transform: translateX(-50%) !important;
}

/* Ensure our breakpoint rules override the conflicting stylesheet */
@media (min-width: 1440px) {
    .template-main .sub-nav-container {
        left: calc(40px + 20vw) !important;
    }
}

/* Maximum specificity override for sub-nav positioning */
html body.template-main .sub-nav-container {
    left: calc(40px + 20vw) !important;
    transform: translateX(-50%) !important;
}

/* Ensure background images are positioned at bottom for services */
.template-main .template-background {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 200px !important;
    z-index: 1 !important;
}

.template-main .template-background .bg-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
}

.template-main .bg-overlay {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0) !important; /* No overlay - same as kompetenzen */
    z-index: 2 !important;
}

/* Override responsive.css mobile styles for services */
@media (max-width: 480px) {
    /* Ensure mobile doesn't cause overflow */
    html.template-main,
    body.template-main,
    .template-main {
        overflow: hidden !important;
        width: 100% !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
    }
    
    .template-main .content-container {
        position: relative !important;
        right: 20px !important; /* Right-align on mobile with smaller margin */
        left: auto !important;
        width: calc(100% - 40px) !important; /* Full width minus margins */
        max-width: none !important;
        margin-top: 20px !important;
        margin-bottom: 20px !important; /* Same as kompetenzen */
        transform: none !important;
        overflow: visible !important; /* Allow content to flow on mobile */
    }
    
    .template-main .sub-nav-container {
        position: sticky !important;
        top: 60px !important;
        left: 5% !important;
        right: 5% !important;
        width: 90% !important;
    }
    
    /* Ensure mobile content doesn't overflow */
    .mobile-services-content {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .template-main .mobile-services-header .mobile-sub-nav-container {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        left: auto !important;
        width: 100% !important;
        display: block !important;
        padding: 0;
        background: transparent;
        margin: 0;
        z-index: 10 !important;
    }

    .template-main #footer-container {
        display: block !important;
        visibility: visible !important;
        position: fixed !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        z-index: 10001 !important;
        pointer-events: none;
    }

    .template-main .main-footer {
        position: relative !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 14px 14px !important;
        box-sizing: border-box !important;
        z-index: 10001 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        pointer-events: auto;
    }

    .template-main .main-footer .footer-language-switcher,
    .template-main .main-footer .bottom-tagline {
        color: #6A6A6A !important;
    }

    .template-main .main-footer .footer-language-switcher .lang-active,
    .template-main .main-footer .footer-language-switcher .lang-separator,
    .template-main .main-footer .footer-language-switcher .lang-option {
        color: #6A6A6A !important;
    }

    .template-main[data-page="innovation-triz"] #footer-container {
        position: relative !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;
        width: 100% !important;
        margin: 8px 0 0 !important;
        z-index: 4 !important;
        pointer-events: auto;
    }

    .template-main[data-page="innovation-triz"] .main-footer {
        position: relative !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        z-index: 4 !important;
    }

    .template-main[data-page="innovation-triz"] .mobile-services-content {
        padding-bottom: 8px !important;
    }
}

/* ===== RESPONSIVE STABILIZATION OVERRIDES ===== */
body.template-main {
    --desktop-subpage-nav-top: 160px;
    --desktop-subpage-subnav-width: 260px;
    --desktop-subpage-subnav-left: clamp(128px, calc(40px + 20vw - 130px), 260px);
    --desktop-subpage-content-left: max(
        calc(var(--desktop-subpage-subnav-left) + var(--desktop-subpage-subnav-width) + 48px),
        calc(60vw + 18px)
    );
    --desktop-subpage-content-right: 40px;
    --desktop-subpage-content-width: calc(100vw - var(--desktop-subpage-content-left) - var(--desktop-subpage-content-right));
    --desktop-services-text-top: calc(var(--desktop-subpage-nav-top) + 176px);
    --desktop-services-text-width: min(568px, calc(var(--desktop-subpage-content-left) - var(--desktop-subpage-subnav-left) + 8px));
}

@media (min-width: 481px) {
    body.template-main,
    html.template-main {
        overflow: hidden;
        height: 100vh;
    }

    .template-main .desktop-services-layout {
        height: 100vh;
        overflow: hidden;
    }

    .template-main .desktop-services-layout .sub-nav-container,
    html body.template-main .desktop-services-layout .sub-nav-container {
        position: absolute !important;
        top: var(--desktop-subpage-nav-top) !important;
        left: var(--desktop-subpage-subnav-left) !important;
        width: var(--desktop-subpage-subnav-width) !important;
        transform: none !important;
        z-index: 100;
    }

    .template-main .desktop-services-layout .content-container,
    html body.template-main .desktop-services-layout .content-container {
        position: absolute !important;
        top: var(--desktop-services-text-top) !important;
        left: var(--desktop-subpage-subnav-left) !important;
        right: auto !important;
        width: var(--desktop-services-text-width) !important;
        max-width: var(--desktop-services-text-width) !important;
        z-index: 10;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        overflow: visible;
    }

    .template-main .content-grid,
    .template-main .right-column,
    .template-main .main-text-content {
        width: 100%;
        max-width: 100%;
    }

    .template-main[data-page="innovation-triz"] .svg-content,
    html body.template-main[data-page="innovation-triz"] .svg-content {
        position: fixed !important;
        top: var(--desktop-services-text-top) !important;
        left: var(--desktop-subpage-content-left) !important;
        bottom: auto !important;
        width: min(545px, var(--desktop-subpage-content-width)) !important;
        max-width: var(--desktop-subpage-content-width) !important;
        z-index: 5 !important;
        transform: none !important;
        margin: 0 !important;
    }

    .template-main[data-page="innovation-triz"] .text-content {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 1280px) and (min-width: 769px) {
    body.template-main {
        --desktop-subpage-subnav-left: clamp(116px, calc(40px + 20vw - 130px), 188px);
        --desktop-subpage-content-left: max(
            calc(var(--desktop-subpage-subnav-left) + var(--desktop-subpage-subnav-width) + 40px),
            58vw
        );
        --desktop-services-text-width: min(508px, calc(var(--desktop-subpage-content-left) - var(--desktop-subpage-subnav-left) + 12px));
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    body.template-main {
        --desktop-subpage-subnav-left: 4%;
        --desktop-subpage-content-left: 46%;
        --desktop-subpage-content-right: 24px;
        --desktop-services-text-top: 248px;
        --desktop-services-text-width: min(44vw, 408px);
    }
}

@media (max-width: 480px) {
    html.template-main,
    body.template-main,
    body.template-main .template-main {
        height: auto !important;
        min-height: 100dvh !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    .desktop-services-layout {
        display: none !important;
    }

    .mobile-services-header {
        position: fixed;
    }

    body.template-main:not([data-page="innovation-triz"]) .mobile-services-content {
        display: block !important;
        position: fixed !important;
        top: var(--mobile-services-header-height) !important;
        right: 0 !important;
        bottom: var(--mobile-services-bottom-image-height) !important;
        left: 0 !important;
        width: 100% !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 20px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        background: #EBEBEB !important;
        box-sizing: border-box;
    }

    body.template-main:not([data-page="innovation-triz"]) .mobile-services-bottom-image {
        position: fixed !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: var(--mobile-services-bottom-image-height) !important;
        margin: 0 !important;
        transform: none !important;
        z-index: 1 !important;
    }

    body.template-main:not([data-page="innovation-triz"]) #footer-container {
        position: fixed !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        z-index: 10001 !important;
        pointer-events: none;
    }

    body.template-main:not([data-page="innovation-triz"]) .main-footer {
        position: relative !important;
        width: 100% !important;
        padding: 0 14px 14px !important;
        margin: 0 !important;
        z-index: 10001 !important;
        pointer-events: auto;
    }

    .template-main[data-page="innovation-triz"] .mobile-services-content {
        padding-bottom: 0 !important;
    }
}
