/* Anleitungen Frontend Styles - Based on E-Rezept Template */
.anleitung-container {
    --primary-color: #2E628E;
    --secondary-color: #107fc9;
    --accent-color: #2f3241;
    --border-color: #2E628E;
    --light-gray: #f1f1f1;
    --text-color: #000000;
    --text-light: #666666;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --border-radius: 20px;
    --step-number-color: #2E628E;
}

/* Container */
.anleitung-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif;
    line-height: 1.8;
    color: var(--text-color);
    max-width: 1080px; /* Divi default max width */
    margin: 20px auto;
    padding: 0;
}

/* Headers */
.anleitung-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    position: relative;
}

.anleitung-title,
.anleitung-main-title {
    color: var(--accent-color);
    font-size: 35px;
    font-weight: 700;
    margin: 0 0 15px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1.3em;
}

.anleitung-main-title {
    font-size: 42px;
    margin-bottom: 20px;
}

.anleitung-divider {
    width: 40px;
    height: 4px;
    background: var(--secondary-color);
    margin: 0 auto;
    position: relative;
}

.anleitung-divider::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: var(--primary-color);
}

/* Inhaltsverzeichnis */
.anleitung-inhaltsverzeichnis {
    background: var(--light-gray);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 30px;
}

.inhaltsverzeichnis-title {
    color: var(--accent-color);
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 15px 0;
    text-align: center;
}

.anleitung-beschreibung {
    text-align: center;
    font-size: 16px;
    color: var(--text-light);
    margin: 15px 0 20px 0;
}

.schritte-liste {
    list-style: none;
    padding: 0;
    margin: 0;
}

.schritte-liste li {
    margin: 8px 0;
    padding: 12px 16px;
    background: white;
    border-radius: 10px;
    border: 1px solid #ddd;
    transition: all 0.3s ease;
}

.schritte-liste li:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.schritte-liste a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
}

.schritte-liste a:hover {
    color: var(--secondary-color);
}

/* Anleitung Content */
.anleitung-content {
    margin-top: 40px;
}

.anleitung-intro {
    background: var(--light-gray);
    border: 2px dotted var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin: 30px 0;
    text-align: center;
}

.anleitung-intro p {
    font-size: 17px;
    color: var(--text-color);
    margin: 0;
}

/* Schritte */
.anleitung-schritte {
    margin-top: 40px;
}

.anleitung-schritt {
    margin: 40px 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Schritt Bilder */
.schritt-bilder {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.schritt-bild-wrapper {
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.schritt-bild-wrapper:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 20px rgba(46, 98, 142, 0.2);
}

.schritt-bild {
    width: 100%;
    height: auto;
    max-width: 400px;
    display: block;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.schritt-bild:hover {
    transform: scale(1.02);
}

/* Schritt Content */
.schritt-content {
    background: white;
    border: 2px dotted var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
    box-shadow: var(--shadow);
}

.schritt-number-wrapper {
    flex-shrink: 0;
}

.schritt-number {
    width: 60px;
    height: 60px;
    background: var(--step-number-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(46, 98, 142, 0.3);
}

.schritt-text {
    flex: 1;
}

.schritt-title {
    color: var(--accent-color);
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 10px 0;
}

.schritt-beschreibung {
    font-size: 16px;
    color: var(--text-color);
    line-height: 1.6;
}

.schritt-beschreibung p {
    margin: 0;
}

/* No Steps */
.no-steps {
    text-align: center;
    padding: 40px 20px;
    background: var(--light-gray);
    border: 2px dotted var(--border-color);
    border-radius: var(--border-radius);
    margin: 30px 0;
}

.no-steps p {
    font-size: 18px;
    color: var(--text-light);
    margin: 0;
}

/* Responsive Design */

/* Tablet Landscape (768px - 1199px) */
@media (min-width: 768px) and (max-width: 1199px) {
    .anleitung-container {
        margin: 20px;
        padding: 0;
    }
    
    .anleitung-title,
    .anleitung-main-title {
        font-size: 28px;
    }
    
    .anleitung-main-title {
        font-size: 32px;
    }
    
    .schritt-bilder {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .schritt-bild {
        max-width: 350px;
    }
    
    .schritt-content {
        flex-direction: column;
        text-align: center;
    }
    
    .schritt-number-wrapper {
        align-self: center;
    }
}

/* Tablet Portrait & Mobile (max-width: 767px) */
@media (max-width: 767px) {
    .anleitung-container {
        margin: 10px;
        padding: 0;
    }
    
    .anleitung-title,
    .anleitung-main-title {
        font-size: 24px;
    }
    
    .anleitung-main-title {
        font-size: 28px;
    }
    
    .anleitung-inhaltsverzeichnis,
    .anleitung-intro,
    .schritt-content {
        padding: 15px;
        border-radius: 15px;
    }
    
    .inhaltsverzeichnis-title {
        font-size: 20px;
    }
    
    .schritte-liste li {
        padding: 10px 12px;
    }
    
    .schritte-liste a {
        font-size: 14px;
    }
    
    .schritt-bilder {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .schritt-bild {
        max-width: 100%;
    }
    
    .schritt-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .schritt-number {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .schritt-title {
        font-size: 18px;
    }
    
    .schritt-beschreibung,
    .anleitung-intro p {
        font-size: 15px;
    }
}

/* Mobile Portrait (max-width: 480px) */
@media (max-width: 480px) {
    .anleitung-container {
        margin: 5px;
    }
    
    .anleitung-title,
    .anleitung-main-title {
        font-size: 20px;
    }
    
    .anleitung-main-title {
        font-size: 24px;
    }
    
    .anleitung-inhaltsverzeichnis,
    .anleitung-intro,
    .schritt-content {
        padding: 12px;
        border-radius: 12px;
    }
    
    .inhaltsverzeichnis-title {
        font-size: 18px;
    }
    
    .schritte-liste a {
        font-size: 13px;
    }
    
    .schritt-number {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    .schritt-title {
        font-size: 16px;
    }
    
    .schritt-beschreibung,
    .anleitung-intro p {
        font-size: 14px;
    }
}

/* ================= Grid Guide (Images 3/2/1 + explanations) ================= */
.anleitung-grid-guide .grid-guide-header {
    text-align: center;
    margin-bottom: 24px;
}

.anleitung-grid-guide .grid-guide-title {
    color: var(--accent-color);
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 10px 0;
}

.anleitung-grid-guide .grid-guide-intro {
    color: var(--text-light);
    font-size: 16px;
    margin: 0 auto;
    max-width: 900px;
}

.anleitung-group {
    margin: 32px 0 40px;
}

.anleitung-magnifier-toggle { display:flex; justify-content:flex-end; margin: 8px 0 16px; }
.anleitung-magnifier-toggle .magnifier-toggle-label { display:inline-flex; align-items:center; gap:8px; padding:8px 12px; border:1px solid #e2e8f0; border-radius:10px; background:#fff; box-shadow:0 1px 3px rgba(0,0,0,0.05); cursor:pointer; }
.anleitung-magnifier-toggle .magnifier-toggle-input { accent-color:#2E628E; }
.anleitung-magnifier-toggle .magnifier-toggle-text { color:#2f3241; font-weight:600; }

.anleitung-group .group-images-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Fallback: 3 on desktop */
    gap: 20px;
}

.anleitung-group .image-card {
    border: 2px solid #2E628E; /* Immer blau */
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    position: relative;
    transition: background 0.2s;
}

.anleitung-group .image-card img {
    width: 100%;
    height: auto;
    display: block;
}
.anleitung-container .image-card.magnifier-active img {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Magnifier (optional, lens overlay) */
.anleitung-container .image-card { position: relative; }
/* Lens overlay (global selector so it works when appended to body) */
.mag-lens {
    position: fixed;
    border: 3px solid rgba(46,98,142,0.95);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.96);
    transition: opacity .12s, transform .12s;
    box-shadow: 0 10px 28px rgba(0,0,0,0.22);
    backdrop-filter: blur(1px);
    z-index: 2147483647; /* keep in front of everything */
    overflow: hidden;
}
.anleitung-container .image-card.magnifier-arming img,
.anleitung-container .image-card.magnifier-active img {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}
.mag-lens.visible { opacity: 1; transform: none; }
/* DOM-based lens content */
.mag-lens .mag-scene { position:absolute; left:0; top:0; width:100%; height:100%; overflow:hidden; }
.mag-lens .image-card.mag-clone {
    border-radius: 20px; /* match site cards */
    overflow: hidden;
    border: 2px solid #2E628E;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.mag-lens .image-card.mag-clone img { width:100%; height:auto; display:block; }
/* Backwards compatibility if lens is still inside image-card */
.anleitung-container .image-card .mag-lens { position: absolute; z-index: 10; }
.anleitung-container .image-card .mag-lens.visible { opacity: 1; transform: none; }

.anleitung-group .image-card.placeholder {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    min-height: 20px; /* just to keep grid height consistent if needed */
}

/* Section Headings (Zwischenüberschriften) */
.anleitung-heading-block {
    text-align: center;
    margin: 44px 0 22px;
}
.anleitung-heading-block .anleitung-section-title {
    color: #2f3241;
    font-weight: 700;
    line-height: 1.3;
    margin: 0;
}
.anleitung-heading-block.level-1 .anleitung-section-title { font-size: 38px; }
.anleitung-heading-block.level-2 .anleitung-section-title { font-size: 32px; }
.anleitung-heading-block.level-3 .anleitung-section-title { font-size: 28px; }
.anleitung-section-divider {
    width: 40px;
    height: 4px;
    background: #2E628E;
    margin: 10px auto 0;
    border-radius: 2px;
}
@media (max-width: 1199px) {
    .anleitung-heading-block { margin: 36px 0 18px; }
    .anleitung-heading-block.level-1 .anleitung-section-title { font-size: 34px; }
    .anleitung-heading-block.level-2 .anleitung-section-title { font-size: 30px; }
    .anleitung-heading-block.level-3 .anleitung-section-title { font-size: 26px; }
}
@media (max-width: 767px) {
    .anleitung-heading-block { margin: 28px 0 14px; }
    .anleitung-heading-block.level-1 .anleitung-section-title { font-size: 30px; }
    .anleitung-heading-block.level-2 .anleitung-section-title { font-size: 26px; }
    .anleitung-heading-block.level-3 .anleitung-section-title { font-size: 22px; }
}



.anleitung-group .group-explanations {
    display: none;
}

.anleitung-group .step-box {
    margin-top: 14px;
    border: 2px dashed #2E628E; /* Immer blau, gestrichelt */
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(33,118,174,0.06);
    padding: 16px 12px 16px 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 60px;
    position: relative;
    transition: box-shadow 0.2s, background 0.2s;
}
.anleitung-group .step-box:hover {
    box-shadow: 0 2px 10px rgba(33,118,174,0.12);
}


.anleitung-group .explain-item + .explain-item {
    margin-top: 10px; /* einheitlicher Abstand zwischen Erklärungsmodulen */
}

.anleitung-grid-guide .grid-guide-header { display: none !important; }
/* Entferne äußere Gruppenabstände, damit nur die inneren Abstände zählen */
.anleitung-container.anleitung-grid-guide .anleitung-group { margin: 0; }
/* Einheitliche, größere Abstände zwischen Bildreihen und Erklärungen */
.anleitung-group .group-images-grid { margin-bottom: 20px; }
.anleitung-group .group-images-grid:last-child { margin-bottom: 0; }
.anleitung-group .group-steps { margin-top: 0; margin-bottom: 20px; }
/* Nur ganz am Ende der gesamten Anleitung kein Zusatzabstand */
.anleitung-container.anleitung-grid-guide .anleitung-group:last-child .group-steps:last-child { margin-bottom: 0; }
/* Innerhalb von group-steps kein zusätzlicher Top-Abstand bei der ersten Step-Box */
.anleitung-group .group-steps .step-box:first-child { margin-top: 0; }
.anleitung-group .group-steps .step-box + .step-box { margin-top: 10px; }

@media (max-width: 1199px) {
    .anleitung-group .group-steps { margin-bottom: 18px; }
    .anleitung-container.anleitung-grid-guide .anleitung-group:last-child .group-steps:last-child { margin-bottom: 0; }
}
@media (max-width: 767px) {
    .anleitung-group .group-steps { margin-bottom: 16px; }
    .anleitung-container.anleitung-grid-guide .anleitung-group:last-child .group-steps:last-child { margin-bottom: 0; }
}

/* Nummer-Badge: kleiner, ohne Rand, nur Hintergrundfarbe */
.anleitung-group .number-badge {
    min-width: 70px;
    min-height: 70px;
    width: 70px;
    height: 70px;
    background: #ff0000;
    border: none !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.3rem;
    box-shadow: none;
    margin-right: 22px;
    color: #fff;
    transition: background 0.2s;
    flex-shrink: 0;
}
.anleitung-group .number-badge.schwer {
    background: #2176ae;
    color: #fff;
}
.anleitung-group .number-badge .number-inner {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}

.anleitung-group .explain-title,
.anleitung-group .explain-text h3,
.anleitung-group .explain-text h4,
.anleitung-group .explain-text .schritt-title { display: none !important; }

.anleitung-group .explain-desc {
    color: #222;
    font-size: 18px;
    line-height: 1.8;
    margin: 0;
    display: block; /* Block, damit Floats daneben/unterlaufen arbeiten */
    text-align: left;
    height: 100%;
    /* Bessere Silbentrennung und Umbruch */
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
    overflow-wrap: anywhere;
    word-break: normal;
}

/* Tablet: 2 Spalten (Grid-Spalten werden von JS gesetzt) */
@media (max-width: 1199px) {
    /* Größere und konsistente Abstände auf Tablet */
    .anleitung-group .group-images-grid { margin-bottom: 18px; }
    .anleitung-group .group-steps { margin-bottom: 18px; }
    .anleitung-group .step-box {
        flex-direction: row;
        padding: 12px 6px 12px 6px;
    }
    .anleitung-group .number-badge {
        min-width: 56px;
        min-height: 56px;
        width: 56px;
        height: 56px;
        font-size: 1.25rem;
        margin-right: 14px;
    }
    .anleitung-group .number-badge .number-inner {
        font-size: 1.4rem;
    }
}

/* Phone: 1 Spalte (Grid-Spalten werden von JS gesetzt) */
@media (max-width: 767px) {
    .anleitung-group .group-images-grid { gap: 8px; }
    .anleitung-group .group-images-grid { margin-bottom: 16px; }
    .anleitung-group .group-steps { margin-bottom: 16px; }
    .anleitung-group .step-box { display: block; position: relative; padding: 10px 12px; min-height: 64px; }
    .anleitung-group .step-box.is-short { display: flex; align-items: center; }
    .anleitung-group .step-box.is-short .number-badge { float: none; margin: 0 12px 0 0; }
    .anleitung-group .step-box.is-short .explain-text { display: block; min-height: auto; }
    .anleitung-group .step-box::after { content: ""; display: block; clear: both; }
    .anleitung-group .number-badge { float: left; min-width: 60px; min-height: 60px; width: 60px; height: 60px; font-size: 1.15rem; margin: 2px 12px 6px 0; shape-outside: circle(50%); }
    .anleitung-group .number-badge .number-inner {
        font-size: 1.6rem; /* Ziffer größer */
    }
    .anleitung-group .step-box .explain-text { display: block; min-height: 60px; min-width: 0; width: auto; overflow: visible; }
    .anleitung-group .step-box .explain-desc { text-indent: 0; display: block; text-align: left !important; }
    .anleitung-group .explain-desc {
        font-size: 15px; /* größer auf Mobil */
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    /* Gewünscht: bei Nacht immer weißer Hintergrund mit dunklem Text */
    .anleitung-container,
    .anleitung-group .image-card,
    .anleitung-group .step-box,
    .schritt-content,
    .schritte-liste li,
    .anleitung-inhaltsverzeichnis,
    .anleitung-intro,
    .no-steps {
        background: #ffffff !important;
        color: #000000 !important;
    }
    .anleitung-group .explain-desc { color: #000000 !important; }
}

/* Print Styles */
@media print {
    .anleitung-container {
        margin: 0;
        padding: 0;
        box-shadow: none;
    }
    
    .schritt-content,
    .anleitung-inhaltsverzeichnis,
    .anleitung-intro {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
    }
    
    .schritt-bild-wrapper {
        box-shadow: none !important;
    }
    
    .schritte-liste a {
        color: #000 !important;
    }
}
