/* ============================================================
   PERBAIKAN MENU & HALAMAN UTAMA - SMP Negeri 26 Surakarta
   v2.0 - Update:
   - Submenu auto-flip ke kiri jika terlalu kanan
   - Perbaikan CSS halaman utama (hero, section, footer, dll)
   ============================================================ */

/* --- RESET: Hapus style lama yang bermasalah --- */
.ftco-navbar-light .navbar-nav > .nav-item .dropdown-menu .dropdown-menu {
    left: 0 !important;
}

/* ============================================================
   1. DESKTOP DROPDOWN (min-width: 992px)
   ============================================================ */
@media (min-width: 992px) {

    /* --- Base Dropdown --- */
    .navbar-nav .nav-item.dropdown {
        position: relative;
    }

    .navbar-nav .nav-item > .dropdown-menu {
        display: block;
        opacity: 0;
        visibility: hidden;
        transform: translateY(10px);
        transition: all 0.25s ease;
        min-width: 240px;
        padding: 8px 0;
        margin-top: 0;
        border: none;
        border-radius: 6px;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
        background: #fff;
        top: 100%;
        left: 0;
    }

    .navbar-nav .nav-item:hover > .dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    /* --- Nested Submenu (Level 2+) DEFAULT: buka ke kanan --- */
    .dropdown-menu .nav-item.dropdown {
        position: relative;
    }

    .dropdown-menu .nav-item > .dropdown-menu {
        display: block;
        opacity: 0;
        visibility: hidden;
        position: absolute;
        top: -8px;
        left: 100%;
        right: auto;
        transform: translateX(10px);
        transition: all 0.25s ease;
        min-width: 240px;
        padding: 8px 0;
        margin: 0;
        border: none;
        border-radius: 6px;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
        background: #fff;
    }

    .dropdown-menu .nav-item:hover > .dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateX(0);
    }

    /* --- FLIP KE KIRI: class ditambahkan via JS jika submenu keluar layar --- */
    .dropdown-menu .nav-item.dropdown.submenu-left > .dropdown-menu {
        left: auto !important;
        right: 100% !important;
        transform: translateX(-10px);
    }

    .dropdown-menu .nav-item.dropdown.submenu-left:hover > .dropdown-menu {
        transform: translateX(0);
    }

    /* Arrow flip untuk submenu-left */
    .dropdown-menu .nav-item.dropdown.submenu-left > .nav-link::after {
        content: '\2039' !important;
        float: left !important;
        margin-left: 0 !important;
        margin-right: 8px !important;
    }

    /* --- Top-level dropdown yang terlalu kanan, flip dropdown ke kiri --- */
    .navbar-nav > .nav-item.dropdown.dropdown-left > .dropdown-menu {
        left: auto;
        right: 0;
    }

    /* --- Menu Item Styling --- */
    .dropdown-menu .nav-item {
        display: block;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .dropdown-menu .nav-item > .nav-link {
        display: block;
        padding: 8px 20px !important;
        font-size: 14px !important;
        font-weight: 400;
        color: #333 !important;
        white-space: normal;
        line-height: 1.5;
        transition: all 0.2s ease;
        border-left: 3px solid transparent;
    }

    .dropdown-menu .nav-item > .nav-link:hover {
        background-color: #f0f4ff;
        color: #05094a !important;
        border-left: 3px solid #05094a;
    }

    /* --- Arrow indicator untuk item yang punya submenu --- */
    .dropdown-menu .nav-item.dropdown > .nav-link::after {
        content: '\203A';
        float: right;
        font-size: 18px;
        font-weight: bold;
        line-height: 1;
        margin-left: 8px;
        color: #999;
        transition: transform 0.2s ease;
        border: none;
    }

    .dropdown-menu .nav-item.dropdown:hover > .nav-link::after {
        color: #05094a;
        transform: translateX(3px);
    }

    .dropdown-menu .nav-item.dropdown.submenu-left:hover > .nav-link::after {
        transform: translateX(-3px) !important;
    }

    /* Hapus default Bootstrap dropdown-toggle arrow di submenu */
    .dropdown-menu .nav-item.dropdown > .nav-link.dropdown-toggle::after {
        border: none;
        vertical-align: middle;
    }

    /* Top-level dropdown arrow (tetap pakai default) */
    .navbar-nav > .nav-item.dropdown > .nav-link.dropdown-toggle::after {
        content: "";
        display: inline-block;
        margin-left: 0.255em;
        vertical-align: 0.255em;
        border-top: 0.3em solid;
        border-right: 0.3em solid transparent;
        border-bottom: 0;
        border-left: 0.3em solid transparent;
    }

    /* Separator line */
    .dropdown-menu .nav-item + .nav-item {
        border-top: 1px solid rgba(0, 0, 0, 0.04);
    }
}

/* ============================================================
   2. MOBILE DROPDOWN (max-width: 991px)
   ============================================================ */
@media (max-width: 991.98px) {

    #ftco-nav {
        max-height: 80vh;
        overflow-y: auto;
        padding: 10px 0;
    }

    .navbar-nav .nav-item > .nav-link {
        padding: 10px 15px !important;
        font-size: 15px;
        color: rgba(255, 255, 255, 0.85) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .navbar-nav .nav-item > .nav-link:hover,
    .navbar-nav .nav-item > .nav-link:focus {
        color: #fff !important;
        background: rgba(255, 255, 255, 0.05);
    }

    .navbar-nav .dropdown-menu {
        position: static !important;
        float: none !important;
        background: rgba(255, 255, 255, 0.05) !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    .navbar-nav > .nav-item > .dropdown-menu > .nav-item > .nav-link {
        padding: 8px 15px 8px 30px !important;
        font-size: 14px !important;
        color: rgba(255, 255, 255, 0.75) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .navbar-nav > .nav-item > .dropdown-menu > .nav-item > .nav-link:hover {
        color: #fff !important;
        background: rgba(255, 255, 255, 0.08);
    }

    .dropdown-menu .dropdown-menu .nav-item > .nav-link {
        padding: 8px 15px 8px 50px !important;
        font-size: 13px !important;
        color: rgba(255, 255, 255, 0.65) !important;
    }

    .dropdown-menu .dropdown-menu .nav-item > .nav-link:hover {
        color: #fff !important;
    }

    .dropdown-menu .dropdown-menu .dropdown-menu .nav-item > .nav-link {
        padding: 8px 15px 8px 70px !important;
        font-size: 13px !important;
        color: rgba(255, 255, 255, 0.55) !important;
    }

    .dropdown-menu .nav-item.dropdown > .nav-link::after,
    .navbar-nav > .nav-item.dropdown > .nav-link.dropdown-toggle::after {
        float: right;
        margin-top: 6px;
    }

    .dropdown-menu .nav-link {
        color: rgba(255, 255, 255, 0.75) !important;
    }

    .dropdown-menu .nav-link:hover {
        color: #fff !important;
        background: transparent !important;
    }

    .navbar-nav > .nav-item > .dropdown-menu {
        border-left: 2px solid rgba(255, 255, 255, 0.15) !important;
        margin-left: 15px !important;
    }

    .dropdown-menu .dropdown-menu {
        border-left: 2px solid rgba(255, 255, 255, 0.1) !important;
        margin-left: 15px !important;
    }
}

/* ============================================================
   3. NAVBAR GENERAL
   ============================================================ */
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 20px;
}

.navbar-brand img {
    height: 60px;
    width: auto;
}

@media (max-width: 575.98px) {
    .navbar-brand img { height: 45px !important; }
    .navbar-brand { font-size: 15px !important; }
}

.ftco-navbar-light {
    transition: all 0.3s ease;
}

.ftco-navbar-light .navbar-nav > .nav-item > .nav-link {
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-left: 15px !important;
    padding-right: 15px !important;
}

.dropdown-menu .nav-item > .nav-link.active,
.dropdown-menu .nav-item.active > .nav-link {
    background-color: #f0f4ff;
    color: #05094a !important;
    font-weight: 500;
}

@media (min-width: 992px) {
    .navbar-nav .dropdown-toggle[data-toggle="dropdown"] { pointer-events: auto; }
    .navbar-nav .nav-item.dropdown > a.nav-link { pointer-events: auto; }
}

.ftco-navbar-light.scrolled .dropdown-menu { background: #fff !important; }
.ftco-navbar-light.scrolled .dropdown-menu .nav-link { color: #333 !important; }
.ftco-navbar-light.scrolled .dropdown-menu .nav-link:hover {
    color: #05094a !important;
    background-color: #f0f4ff !important;
}


/* ============================================================
   4. PERBAIKAN HALAMAN UTAMA / HOMEPAGE
   ============================================================ */

/* --- Topper Bar --- */
.topper {
    font-size: 13px;
    padding: 8px 0;
}

.topper .icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.topper .icon span { font-size: 12px; color: #fff; }

.topper .text {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    line-height: 1.4;
}

@media (max-width: 767.98px) {
    .topper .container .row > div {
        justify-content: center !important;
        text-align: center;
        margin-bottom: 4px;
    }
    .topper { padding: 6px 0; font-size: 12px; }
}

/* --- Hero Slider --- */
.hero-wrap,
.home-slider .slider-item {
    background-size: cover;
    background-position: center center;
}

.hero-wrap .overlay {
    background: linear-gradient(to bottom, rgba(5, 9, 74, 0.45), rgba(5, 9, 74, 0.65));
}

.slider-item .slider-text {
    padding: 0 15px;
}

.slider-item .slider-text h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.4);
    line-height: 1.3;
    margin-bottom: 15px;
}

.slider-item .slider-text .btn-primary {
    background: #05094a;
    border: none;
    padding: 10px 28px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 30px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.slider-item .slider-text .btn-primary:hover {
    background: #1a237e;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(5, 9, 74, 0.3);
}

@media (max-width: 991.98px) {
    .hero-wrap, .home-slider .slider-item { min-height: 350px; }
    .slider-item .slider-text h1 { font-size: 1.6rem; }
}

@media (max-width: 575.98px) {
    .hero-wrap, .home-slider .slider-item { min-height: 280px; }
    .slider-item .slider-text h1 { font-size: 1.3rem; }
    .slider-item .slider-text .btn-primary { padding: 8px 20px; font-size: 12px; }
}

/* --- OWL Carousel Controls --- */
.home-slider .owl-nav .owl-prev,
.home-slider .owl-nav .owl-next {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2) !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: #fff !important;
}

.home-slider .owl-nav .owl-prev { left: 15px; }
.home-slider .owl-nav .owl-next { right: 15px; }

.home-slider .owl-nav .owl-prev:hover,
.home-slider .owl-nav .owl-next:hover {
    background: rgba(255, 255, 255, 0.4) !important;
}

.home-slider .owl-dots {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
}

.home-slider .owl-dots .owl-dot span {
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    margin: 0 4px;
    transition: all 0.3s ease;
}

.home-slider .owl-dots .owl-dot.active span {
    background: #fff;
    width: 28px;
    border-radius: 5px;
}

/* --- Section Program Unggulan (SESUCI, Ramah Anak, dll) --- */
.ftco-section {
    padding: 60px 0;
}

.ftco-section .heading-section {
    margin-bottom: 40px;
}

.ftco-section .heading-section h2 {
    font-size: 28px;
    font-weight: 700;
    color: #05094a;
    position: relative;
    padding-bottom: 15px;
}

.ftco-section .heading-section h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: #05094a;
    border-radius: 2px;
}

/* Program cards */
.services-wrap,
.services,
.media-body {
    text-align: center;
}

.ftco-services .services,
.program-wrap {
    background: #fff;
    border-radius: 12px;
    padding: 30px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    height: 100%;
    text-align: center;
}

.ftco-services .services:hover,
.program-wrap:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.ftco-services .services img,
.program-wrap img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin: 0 auto 15px;
    display: block;
}

.ftco-services .services h3,
.program-wrap h3 {
    font-size: 18px;
    font-weight: 700;
    color: #05094a;
    margin-bottom: 10px;
}

.ftco-services .services p,
.program-wrap p {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 0;
}

/* --- Latest News / Berita --- */
.ftco-section.bg-light {
    background: #f8f9fc !important;
}

.blog-entry,
.news-entry {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    height: 100%;
}

.blog-entry:hover,
.news-entry:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.blog-entry img,
.news-entry img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.blog-entry .text,
.news-entry .text {
    padding: 20px;
}

.blog-entry .text h3,
.news-entry .text h3 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 10px;
}

.blog-entry .text h3 a,
.news-entry .text h3 a {
    color: #222;
    text-decoration: none;
    transition: color 0.2s ease;
}

.blog-entry .text h3 a:hover,
.news-entry .text h3 a:hover {
    color: #05094a;
}

.blog-entry .meta-date,
.news-entry .meta-date {
    background: #05094a;
    color: #fff;
    padding: 8px 15px;
    border-radius: 4px;
    text-align: center;
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
}

/* --- Footer --- */
.ftco-footer {
    background: #05094a;
    color: rgba(255, 255, 255, 0.8);
    padding: 60px 0 0;
    font-size: 14px;
}

.ftco-footer .ftco-footer-widget h2 {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 20px;
    position: relative;
    padding-bottom: 12px;
}

.ftco-footer .ftco-footer-widget h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 2px;
    background: rgba(255, 255, 255, 0.3);
}

.ftco-footer .ftco-footer-widget ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ftco-footer .ftco-footer-widget ul li {
    margin-bottom: 10px;
}

.ftco-footer .ftco-footer-widget ul li a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
}

.ftco-footer .ftco-footer-widget ul li a:hover {
    color: #fff;
    padding-left: 5px;
}

.ftco-footer .ftco-footer-widget .block-23 ul li .icon {
    width: 30px;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.5);
}

.ftco-footer .ftco-footer-widget .block-23 ul li .text {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    line-height: 1.5;
}

/* Social links */
.ftco-footer-social li {
    display: inline-block;
    margin-right: 8px;
}

.ftco-footer-social li a {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff !important;
    transition: all 0.3s ease;
    font-size: 16px;
}

.ftco-footer-social li a:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-3px);
}

.ftco-footer .footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px 0;
    margin-top: 30px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

@media (max-width: 767.98px) {
    .ftco-footer { padding: 40px 0 0; }
    .ftco-footer .ftco-footer-widget { margin-bottom: 30px; }
    .ftco-footer .ftco-footer-widget h2 { font-size: 16px; }
}

/* ============================================================
   5. UTILITY & GENERAL IMPROVEMENTS
   ============================================================ */
html { scroll-behavior: smooth; }

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

.ftco-section .container > .row > [class*="col-"] {
    margin-bottom: 30px;
}

.heading-section { text-align: center; }

.heading-section .subheading {
    font-size: 14px;
    font-weight: 600;
    color: #05094a;
    text-transform: uppercase;
    letter-spacing: 2px;
    display: block;
    margin-bottom: 5px;
}

@media (max-width: 767.98px) {
    .ftco-section { padding: 40px 0; }
    .ftco-section .heading-section h2 { font-size: 22px; }
}

/* Scrollbar for mobile nav */
#ftco-nav::-webkit-scrollbar { width: 4px; }
#ftco-nav::-webkit-scrollbar-track { background: transparent; }
#ftco-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 4px; }

/* Back to top */
#button-top, .back-to-top {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #05094a;
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 999;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 18px;
}

#button-top:hover, .back-to-top:hover {
    background: #1a237e;
    transform: translateY(-3px);
}

/* Print */
@media print {
    .topper, .ftco-navbar-light, .ftco-footer, .owl-nav, .owl-dots,
    #button-top, .back-to-top { display: none !important; }
    .ftco-section { padding: 20px 0; }
}
