/* =========================================================
   TEMPLATE INSTANSI - style.css
   Replika struktur: topbar, mega menu bertingkat, hero slider,
   grid berita, galeri, survey widget, footer 4 kolom
   ========================================================= */

:root {
    --tpl-primary: #0a5c36;
    --tpl-secondary: #f2b100;
    --tpl-dark: #12251d;
    --tpl-gray-bg: #f5f7f6;
    --tpl-border: #e2e6e4;
    --tpl-radius: 8px;
    --tpl-maxw: 1200px;
    --tpl-font: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body.tpl-instansi {
    margin: 0;
    font-family: var(--tpl-font);
    color: #24312a;
    background: #fff;
    line-height: 1.55;
}

img { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }

.tpl-container {
    max-width: var(--tpl-maxw);
    margin: 0 auto;
    padding: 0 16px;
}

/* ===== TOPBAR ===== */
.tpl-topbar {
    background: var(--tpl-dark);
    color: #cfe0d7;
    font-size: 0.8rem;
}
.tpl-topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.tpl-topbar img { height: 28px; width: auto; }
.tpl-topbar-left, .tpl-topbar-right { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.tpl-topbar a { opacity: 0.9; }
.tpl-topbar a:hover { opacity: 1; text-decoration: underline; }

/* ===== HEADER / MEGA MENU ===== */
.tpl-header {
    background: #fff;
    border-bottom: 3px solid var(--tpl-primary);
    z-index: 200;
}
.tpl-header-sticky {
    position: sticky;
    top: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.tpl-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    gap: 20px;
    flex-wrap: wrap;
}
.tpl-logo { display: flex; align-items: center; gap: 10px; }
.tpl-logo img { height: 56px; width: auto; }
.tpl-logo-fallback { font-weight: 700; font-size: 1.2rem; color: var(--tpl-primary); }

.tpl-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid var(--tpl-border);
    border-radius: 6px;
    cursor: pointer;
}
.tpl-menu-toggle span {
    display: block;
    height: 2px;
    background: var(--tpl-primary);
    margin: 0 7px;
}

/* Mega menu - built from mod_menu (module class suffix .tpl-mega) */
.tpl-mega-menu { flex: 1; }
.tpl-mega-menu ul.tpl-mega {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
    gap: 2px;
}
.tpl-mega-menu ul.tpl-mega > li {
    position: relative;
}
.tpl-mega-menu ul.tpl-mega > li > a {
    display: block;
    padding: 12px 14px;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--tpl-dark);
    border-radius: 4px;
    white-space: nowrap;
}
.tpl-mega-menu ul.tpl-mega > li > a:hover,
.tpl-mega-menu ul.tpl-mega > li.active > a {
    background: var(--tpl-primary);
    color: #fff;
}
.tpl-mega-menu ul.tpl-mega > li.parent > a::after {
    content: "";
    display: inline-block;
    margin-left: 6px;
    width: 6px;
    height: 6px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    vertical-align: middle;
}

/* Level 2 dropdown */
.tpl-mega-menu ul.tpl-mega ul {
    list-style: none;
    margin: 0;
    padding: 8px 0;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 260px;
    background: #fff;
    border: 1px solid var(--tpl-border);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 12px 24px rgba(0,0,0,0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.18s ease;
    z-index: 50;
}
.tpl-mega-menu ul.tpl-mega > li:hover > ul,
.tpl-mega-menu ul.tpl-mega > li.tpl-open > ul {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.tpl-mega-menu ul.tpl-mega ul li { position: relative; }
.tpl-mega-menu ul.tpl-mega ul li a {
    display: block;
    padding: 9px 18px;
    font-size: 0.87rem;
    color: #2c3b32;
    font-weight: 500;
}
.tpl-mega-menu ul.tpl-mega ul li a:hover { background: var(--tpl-gray-bg); color: var(--tpl-primary); }

/* Level 3+ flyout to the right */
.tpl-mega-menu ul.tpl-mega ul ul {
    top: -8px;
    left: 100%;
    border-radius: 8px;
}

/* ===== HERO SLIDER ===== */
.tpl-hero-slider { position: relative; background: var(--tpl-dark); }
.tpl-hero-slider img { width: 100%; height: 420px; object-fit: cover; }

/* ===== INNOVATION QUICK CARDS ===== */
.tpl-innovation-cards { background: var(--tpl-gray-bg); padding: 24px 0; margin-top: -60px; position: relative; z-index: 5; }
.tpl-innovation-cards ul,
.tpl-innovation-cards .tpl-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    list-style: none;
    margin: 0; padding: 0;
}
.tpl-innovation-cards li,
.tpl-innovation-cards .tpl-card {
    background: #fff;
    border-radius: var(--tpl-radius);
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    padding: 18px;
    text-align: center;
    transition: transform 0.2s ease;
}
.tpl-innovation-cards li:hover { transform: translateY(-4px); }
.tpl-innovation-cards img { height: 54px; width: auto; margin: 0 auto 10px; }

/* ===== BREADCRUMBS ===== */
.tpl-breadcrumbs-wrap { padding: 14px 16px; font-size: 0.85rem; color: #667a6f; }

/* ===== MAIN GRID ===== */
.tpl-main { padding: 30px 0 10px; background: #fff; }
.tpl-main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}
.tpl-main-grid.has-sections { grid-template-columns: 1fr; }
.tpl-sidebar { }

.tpl-section-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--tpl-primary);
    border-left: 5px solid var(--tpl-secondary);
    padding-left: 12px;
    margin: 34px 0 18px;
}

/* ===== NEWS GRID (card style) ===== */
.tpl-news-grid,
.tpl-program-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}
.tpl-news-grid .card,
.tpl-program-grid .card,
.moduletable.card {
    background: #fff;
    border: 1px solid var(--tpl-border);
    border-radius: var(--tpl-radius);
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.tpl-news-grid .card:hover,
.tpl-program-grid .card:hover {
    box-shadow: 0 12px 28px rgba(0,0,0,0.12);
    transform: translateY(-3px);
}
.tpl-news-grid .card img,
.tpl-program-grid .card img { height: 160px; width: 100%; object-fit: cover; }
.tpl-news-grid .card .card-body,
.tpl-program-grid .card .card-body { padding: 14px 16px; }
.tpl-news-grid .card h4 { font-size: 0.98rem; margin: 0; line-height: 1.4; color: #17281d; }

/* ===== GALLERY SLIDER ===== */
.tpl-gallery-slider-section { margin-top: 10px; }
.tpl-gallery-slider-section img {
    height: 150px; width: 220px; object-fit: cover;
    border-radius: 6px; display: inline-block; margin-right: 10px;
}

/* ===== SURVEY WIDGET ===== */
.tpl-survey-widget {
    background: var(--tpl-gray-bg);
    border-radius: var(--tpl-radius);
    padding: 24px;
    margin-top: 30px;
}
.tpl-survey-widget .survey-options {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 14px;
}
.tpl-survey-widget button,
.tpl-survey-widget .btn-survey {
    background: var(--tpl-primary);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

/* ===== PARTNER LOGOS ===== */
.tpl-partner-logos {
    padding: 26px 0;
    border-top: 1px solid var(--tpl-border);
    border-bottom: 1px solid var(--tpl-border);
}
.tpl-partner-logos .tpl-logos-row,
.tpl-partner-logos ul {
    display: flex;
    gap: 26px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    list-style: none;
    margin: 0; padding: 0;
}
.tpl-partner-logos img { height: 55px; width: auto; filter: grayscale(20%); opacity: 0.85; }
.tpl-partner-logos img:hover { opacity: 1; filter: none; }

/* ===== SOCIAL WIDGET ===== */
.tpl-social-widget { padding: 18px 0; text-align: center; }
.tpl-social-widget a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 10px;
    font-weight: 600;
    color: var(--tpl-primary);
}

/* ===== FOOTER ===== */
.tpl-footer {
    background: var(--tpl-dark);
    color: #cfe0d7;
    padding: 40px 0 20px;
    margin-top: 30px;
}
.tpl-footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 28px;
}
.tpl-footer-col h3 {
    color: #fff;
    font-size: 1.05rem;
    margin-top: 0;
    margin-bottom: 14px;
    border-bottom: 2px solid var(--tpl-secondary);
    display: inline-block;
    padding-bottom: 6px;
}
.tpl-footer-col ul { list-style: none; margin: 0; padding: 0; }
.tpl-footer-col li { margin-bottom: 8px; }
.tpl-footer-col a { opacity: 0.85; }
.tpl-footer-col a:hover { opacity: 1; text-decoration: underline; }

/* ===== COPYRIGHT BAR ===== */
.tpl-copyright-bar { background: #0c1e14; color: #9fb4a7; font-size: 0.82rem; padding: 12px 0; }
.tpl-copyright-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.tpl-bottom-menu ul { list-style: none; display: flex; gap: 16px; margin: 0; padding: 0; }

/* ===== BACK TO TOP ===== */
.tpl-back-to-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--tpl-primary);
    color: #fff;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    z-index: 300;
}
.tpl-back-to-top.show { opacity: 1; visibility: visible; }

/* ===== ERROR PAGE ===== */
.tpl-error-wrap { text-align: center; padding: 100px 20px; }
.tpl-error-wrap h1 { font-size: 4rem; color: var(--tpl-primary); margin: 0; }
.tpl-btn {
    display: inline-block;
    margin-top: 16px;
    background: var(--tpl-primary);
    color: #fff;
    padding: 10px 22px;
    border-radius: 6px;
}

/* ===== RESPONSIVE ===== */
@media (min-width: 992px) {
    .tpl-main-grid.has-sections { grid-template-columns: 1fr; }
    .tpl-main-grid:has(.tpl-sidebar-left):has(.tpl-sidebar-right) { grid-template-columns: 220px 1fr 220px; }
    .tpl-main-grid:has(.tpl-sidebar-left):not(:has(.tpl-sidebar-right)) { grid-template-columns: 220px 1fr; }
    .tpl-main-grid:has(.tpl-sidebar-right):not(:has(.tpl-sidebar-left)) { grid-template-columns: 1fr 260px; }
}

@media (max-width: 991px) {
    .tpl-menu-toggle { display: flex; }
    .tpl-mega-menu {
        display: none;
        width: 100%;
        order: 3;
    }
    .tpl-mega-menu.tpl-open { display: block; }
    .tpl-mega-menu ul.tpl-mega { flex-direction: column; }
    .tpl-mega-menu ul.tpl-mega ul {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        border-left: 3px solid var(--tpl-primary);
        display: none;
        transform: none;
    }
    .tpl-mega-menu ul.tpl-mega li.tpl-open > ul { display: block; }
    .tpl-innovation-cards { margin-top: 16px; }
    .tpl-hero-slider img { height: 240px; }
}
