/* ==========================================================================
   mobile.css
   ========================================================================== */

/* ==========================================================================
   Globale Fixes für horizontales Scrollen (Overflow)
   ========================================================================== */

/* 1. Verhindert das Wischen nach links/rechts auf der gesamten Seite */
html, body {
    overflow-x: hidden !important;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* 2. Verhindert, dass Rahmen (Border) oder Innenabstände (Padding) Elemente breiter als 100% machen */
*, *::before, *::after {
    box-sizing: border-box;
}

/* 3. Stellt sicher, dass der Kalender-Iframe nicht aus dem Bildschirm bricht */
.calendar-content {
    max-width: 100%;
    width: 100%;
    border: none;
}

/* 4. Verhindert, dass extrem lange Links oder Wörter das Layout auseinanderdrücken */
p, a, h1, h2, h3, h4, h5, h6, span {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* === Smartphones & Tablets (max 768px) === */
@media (max-width: 768px) {
    /* === Body & Layout === */
    body {
        font-size: 0.95rem;
    }

    .box {
        flex-direction: column;
        gap: 1rem;
        width: 95%;
        margin: 1rem auto;
    }

    .news,
    .stufenbeitrag,
    .currentPoints {
        flex: 1 1 100%;
        width: 100%;
        padding: 1.2rem;
    }

    /* Header kleiner */
    .news h1,
    .stufenbeitrag h1,
    .currentPoints h1,
    .minus-15 h1,
    .pointSystem h1 {
        font-size: 1.2rem;
    }

    /* Minus-15 Bereich untereinander */
    .minus-15 > .minus-15-lk-container {
        flex-direction: column;
    }

    .minus-15-lk {
        flex: 1 1 100%;
        width: 100%;
    }

    .minus-15 > .minus-15-lk-container .minus-15-lk:first-child::after {
        display: none; /* Trenner entfernen */
    }

    /* Learnhelper Kurse untereinander */
    .learnhelper-courses {
        flex-direction: column;
    }

    .learnhelper-courses .course {
        width: 100%;
    }

    /* Punktesystem Tabelle scrollbar */
    .pointSystem-container {
        overflow-x: auto;
    }

    .pointSystem table {
        font-size: 0.9rem;
    }

    .pointSystem th,
    .pointSystem td {
        padding: 0.6rem;
    }

    /* Minus15 Tabellen untereinander */
    .minus15-container {
        flex-direction: column;
        gap: 1rem;
    }

    .minus15-lk {
        flex: 1 1 100%;
        width: 100%;
        padding: 1rem;
    }

    .minus15-lk table {
        font-size: 0.9rem;
    }

    /* Kalender Höhe reduzieren */
    .calendar-content {
        height: 600px;
    }

    /* Buttons etwas größer für Touch */
    .edit-btn,
    .save-btn,
    .delete-btn {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    /* Links besser klickbar */
    .news-header a,
    .minus-15-header a,
    .lk-actions a,
    .learnhelper-courses .course a {
        display: block;
        text-align: center;
        margin-top: 0.5rem;
    }
}

/* === Synchronisiert mit dem JavaScript-Breakpoint (max 900px) === */
@media (max-width: 900px) {
    .top-nav {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 0.6rem 1.2rem !important;
    }

    .top-nav-left {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important; 
        align-items: center !important;
        width: 100% !important;
        margin-bottom: 0 !important;
        flex-wrap: wrap !important;
    }

    /* Der neue Link-Container listet die Links mobil sauber untereinander auf */
    .top-nav-left-links {
        display: flex !important;
        flex-direction: column !important; /* Links untereinander */
        width: 100% !important;
        align-items: center !important;
        order: 3; /* Rutscht unter Titel und Hamburger */
    }

    .top-nav-siteTitle {
        font-size: 1.1rem !important;
        margin: 0 0 0 auto !important; 
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        order: 1;
    }

    .hamburger-btn {
        display: block !important;
        order: 2; 
        margin-left: 15px !important; 
        margin-right: auto !important; 
    }

    /* Links im geschlossenen Zustand verstecken (wird via JS gesteuert) */
    .top-nav-left-links a {
        display: none; 
        width: 100% !important; 
        text-align: center !important;
        margin: 0.2rem 0 !important;
        padding: 0.5rem !important; 
        box-sizing: border-box;
        border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    }

    .top-nav-right {
        display: none; 
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.3rem !important;
        width: 100% !important;
        text-align: center !important;
        margin-top: 0.5rem !important;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        padding-top: 0.5rem !important;
    }

    .top-nav-right-top p {
        margin: 0 0 0.2rem 0 !important;
        line-height: 1.2 !important;
        font-size: 0.85rem !important;
    }

    .top-nav-right-bottom {
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.3rem !important;
        width: 100% !important;
    }

    .top-nav-right-bottom a {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        padding: 0.5rem !important;
        font-size: 0.9rem !important;
        box-sizing: border-box;
    }
}

/* === Mittlere Bildschirme (Desktop-Menü aktiv, aber Platz ist eng) === */
@media (min-width: 901px) and (max-width: 1200px) {
    .top-nav {
        flex-wrap: nowrap !important;
        align-items: center !important;
    }

    /* Hält Titel und die Link-Box nebeneinander auf einer Linie */
    .top-nav-left {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        flex: 1;
    }

    /* Der Seitentitel bleibt starr und unbeweglich ganz links */
    .top-nav-siteTitle {
        margin: 0 !important;
        margin-right: 2rem !important; /* Abstand zum Start der Linkliste */
        flex-shrink: 0 !important; 
        white-space: nowrap;
    }

    /* NUR dieser Container bricht um, falls die Links zu breit werden */
    .top-nav-left-links {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important; /* Erlaubt die zweite Reihe */
        gap: 0.4rem 1rem !important; /* Vertikaler Abstand (0.4rem) bei Umbruch, horizontaler Abstand (1rem) */
        align-items: center !important;
    }

    /* Die Links innerhalb des Containers verhalten sich wie gewohnt */
    .top-nav-left-links a {
        display: inline-block !important;
        width: auto !important;
        margin: 0 !important;
        white-space: nowrap;
    }

    /* Die rechte Login/Logout-Sektion bleibt stabil rechts */
    .top-nav-right {
        flex-shrink: 0 !important;
        margin-left: 2rem !important;
        text-align: right !important;
    }

    .top-nav-right-top, 
    .top-nav-right-bottom {
        justify-content: flex-end !important;
    }
}