/* ================================ RESPONSIVE CSS ================================ */

/* ================================ TABLET LAYOUT (768px - 1199px) ================================ */
@media screen and (max-width: 1199px) and (min-width: 768px) {
    /* Základní kontejner */
    #center {
        width: 100%;
        max-width: 1199px;
        padding: 0 20px;
        box-sizing: border-box;
    }

    #telo {
        width: 100%;
    }

    #zahlavi a {
        max-width: calc(100% - 235px);
        border-radius: 24px;
    }

    #obsah {
        width: 100%;
    }

    #includovanyObsah {
        width: calc(100% - 235px);
    }

    #pravyPanel {
        width: 200px;
        margin-left: 0;
    }

    /* Skrytí desktop menu a zobrazení tablet expandovatelného menu */
    .desktop-only {
        display: none !important;
    }

    .tablet-expandable-menu {
        display: block !important;
        width: 215px;
        float: left;
        margin-right: 20px;

        /* Expandovatelné menu pro tablet */
        & .mobile-menu-toggle {
            display: block;
            background: #598DD1;
            border: none;
            padding: 10px;
            cursor: pointer;
            width: 100%;
            text-align: left;
            border-radius: 14px 14px 0 0;
            box-shadow: 0 4px 4px rgba(0, 0, 0, 0.15);

            & img {
                width: 24px;
                height: 24px;
                vertical-align: middle;
                margin-right: 10px;
                filter: brightness(0) invert(1);
            }

            & span {
                color: white;
                font-weight: bold;
                font-size: 16px;
                vertical-align: middle;
            }
        }
    }

    .tablet-expandable-menu .mobile-menu-content {
        display: none;
        background: white;
        border: 1px solid #ddd;
        border-top: none;
        border-radius: 0 0 5px 5px;
    }

    .tablet-expandable-menu .mobile-menu-content.active {
        display: block;
    }

    /* Tablet bannery */
    .tablet-banners {
        margin-top: 20px;

        & .banner {
            width: 215px;
            margin-bottom: 20px;

            &:not(:nth-child(-n+3)){
                border: 1px solid #bdbdbd;
                border-radius: 15px 15px 0 15px;
                box-shadow:0 4px 4px rgba(0, 0, 0, 0.15);
                margin-bottom: 30px;

                & img {
                    max-width: 160px;
                    height: auto;
                    margin: 5px;
                }
            }
        }
    }

    /* Patička úpravy */

    #banner img {
        max-width: 100%;
        height: auto;
    }

    /* Mobilní menu na 100% šířky */

    #menu {
        width: 215px !important;
        margin: 0 0 20px 0;
        padding: 0;
        line-height:0;
        text-align: left;
        font-size: 0;
        background-image: url(/img/zs20/menu_1px.gif);
        background-size: cover;
        background-position: left top;
        background-repeat: repeat-y;
        order: 3;

        & ul, & ul li, & ul li a {
            width: 215px;
            padding: 3px 0;
            text-indent: 10px;
        }

        & ul {
            padding-top: 0;
            background-image: none;
        }

        & ul li.prvni {
            padding-top: 8px;
        }

        & ul li.posledni {
            padding-bottom: 8px;
        }
    }
}

/* ================================ MOBILE LAYOUT (do 767px) ================================ */
@media screen and (max-width: 767px) {
    /* Základní reset */
    #center {
        width: 100%;
        box-sizing: border-box;
    }

    #telo {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    #levaCastTela {
        width: 100%;
        order: 1;
        overflow: hidden;
        max-width: 100%;
    }

    /* Mobilní header s vyhledáváním a přihlášením */
    .mobile-header-controls {
        display: flex;
        justify-content: space-between;
        align-items: stretch;
        margin-bottom: 15px;
        padding: 10px 0;
        background: linear-gradient(135deg, #5b8514, #94cd32);
        border-radius: 0;
    }

    .mobile-search {
        flex: 1;
        margin-right: 15px;

        & form {
            display: flex;
            gap: 20px;
            align-items: baseline;
        }
    }

    .mobile-search input[type="text"] {
        width: 100%;
        padding: 8px;
        margin-left: 8px;
        border: 1px solid #ccc;
        border-radius: 3px;
        box-sizing: border-box;
    }

    .mobile-search input[type="submit"] {
        margin-top: 5px;
        padding: 6px 12px;
        background: #598DD1;
        color: white;
        border-radius: 3px;
        cursor: pointer;
        border: none;
    }

    .mobile-login-icons {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
        padding: 12px 8px 5px 8px;
    }

    .mobile-login-icons img {
        max-width: 145px;
        height: auto;
        margin: 3px;
        border: 3px solid white;
        border-radius: 16px;
        padding: 0;
    }

    /* Mobilní menu na 100% šířky */

    #menu {
        width: 100% !important;
        margin: 0 0 20px 0;
        padding: 0;
        line-height:0;
        text-align: left;
        font-size: 0;
        background-image: url(/img/zs20/menu_1px.gif);
        background-size: cover;
        background-position: left top;
        background-repeat: repeat-y;

        & ul, & ul li, & ul li a {
            width: 100%;
        }
        & ul {
            padding-top: 0;
            background-image: none;
        }
        & ul li.prvni {
            padding-top: 8px;
        }
        & ul li.posledni {
            padding-bottom: 8px;
        }
    }

    .mobile-menu-wrapper {
        width: 100%;
        margin-bottom: 10px;
    }

    .mobile-menu-toggle {
        display: block;
        background: #598DD1;
        border: none;
        padding: 15px;
        cursor: pointer;
        width: 100%;
        text-align: right;
        border-radius: 0;
        border-bottom: 1px solid #9cbfec;
        margin-bottom: 3px;
    }

    .mobile-menu-toggle img {
        width: 24px;
        height: 24px;
        vertical-align: middle;
        margin-right: 10px;
        filter: brightness(0) invert(1);
    }

    .mobile-menu-toggle span {
        color: white;
        font-weight: bold;
        font-size: 18px;
        vertical-align: middle;
    }

    .mobile-menu-content {
        display: none;
        background: white;
        border: 1px solid #ddd;
        border-top: none;
        border-radius: 0 0 5px 5px;
    }

    .mobile-menu-content.active {
        display: block;
    }

    /* Obsah na 100% šířky */
    #obsah {
        width: 100%;
        margin-top: 0;
    }

    #levyPanel {
        display: none; /* Skryjeme v mobilní verzi, obsah bude v mobile-menu */
    }

    #includovanyObsah {
        width: 100%;
        float: none;
    }

    /* Pravý panel pod obsahem */
    #pravyPanel {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        float: none;
        gap: 10px;
        justify-content: center;
        order: 5;
        padding-left: 0;
        width: 100%;
        margin-top: 24px;

        & #pravyBlok {
            display: none;
        }

        & .banner {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-evenly;
            align-items: center;

            &:has(img[alt="Prezentace školy"]){
                position: relative;
                display: inline-block;
                padding-top: 40px;
            }

            &:last-child {
                width: 100%;
            }

            & img[title="Instagram_icon"] {
                max-width: 85px !important;
                max-height: auto !important;
            }

            & a img {
                display: flex;
                flex-direction: row;
                flex-wrap: wrap;
                max-width: 150px !important;
                height: auto;
                max-height: 75px !important;
            }
        }
    }

    .banner:has(img[alt="Prezentace školy"])::before {
        content: "Prezentace školy"; /* ← Tady uprav text pruhu */
        position: absolute;
        top: 0;
        left: 5px;
        right: 200px;
        width: 150px;
        background: #528bcc;
        color: white;
        padding: 16px;
        text-align: left;
        text-indent: 3px;
        box-sizing: border-box;
        font-size: 0.8rem;
        font-weight: bold;
        pointer-events: none; /* volitelně: aby neblokoval kliknutí */
        border-radius: 15px 15px 0 0;
    }

    #vyhledavani {
        display: none; /* Přesunuto do mobile-header-controls */
    }

    /* Levý panel obsah pod hlavním obsahem */
    .mobile-left-content {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        margin-top: 20px;
        order: 6;
    }

    .mobile-left-content .banner {
        width: 170px;
        text-align: center;
        margin: 8px;
        align-content: center;

        &:not(:nth-child(-n+3)){
            border: 1px solid #bdbdbd;
            border-radius: 15px 15px 0 15px;
            box-shadow:0 4px 4px rgba(0, 0, 0, 0.15);
            margin-bottom: 30px;

            & img {
                max-width: 140px !important;
                padding: 8px
            }
        }
    }

    .mobile-left-content .banner img {
        max-width: 100%;
        height: auto;
    }

    /* Patička úpravy */
    #zapati {
        width: 100%;
        order: 7;
        margin-top: 30px;
    }

    #banner {
        text-align: center;

        & img {
            width: 100% !important;
            height: auto !important;
            max-width: 100% !important;
            padding: 5px 0 !important;
        }
    }

    #menuZapati {
        float: none;
        width: 100%;
        margin: 30px 0;

        & ul {
            text-align: left;
        }
    }

    #menuZapati ul li {
        display: block;
        margin: 5px 0;
        padding: 5px 0;
        border-left: none;
        border-bottom: 1px solid #445253;

        &.prvni {
            border-bottom: 1px solid #445253;
        }

        &:last-child {
            border-bottom: none;
        }
    }

    /* Utility třídy */
    .mobile-only {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
    }

    .desktop-only {
        display: none;
    }
}

/* ================================ DESKTOP ONLY ================================ */
@media screen and (min-width: 768px) {
    .mobile-only {
        display: none;
    }

    .desktop-only {
        display: block;
    }

    .mobile-menu-toggle {
        display: none;
    }

    .mobile-header-controls {
        display: none;
    }

    .mobile-menu-wrapper {
        display: none;
    }

    .mobile-left-content {
        display: none;
    }
}

/* ================================ HLAVICKA NARROW LAYOUT ================================ */
@media screen and (max-width: 576px) {

    #zahlavi {
        display: block;
        & a {
            max-width: 100%;
            border-radius: 0;
        }

        & IMG:first-child {
            width: 100% !important;
            height: auto !important;
            border-radius: 0;
        }
    }

    .slideshow {
        display: none;
    }
}

/* ================================ TABLET ONLY ================================ */
@media screen and (max-width: 1199px) and (min-width: 768px) {
    .mobile-header-controls {
        display: none;
    }

    .mobile-menu-wrapper {
        display: none;
    }

    .mobile-left-content {
        display: none;
    }
}
