/* ==========================================================================
   Top Navigation Mega Menu — Tirto.id Clone (REVISED PIXEL-PERFECT)
   ========================================================================== */

/* Mega Menu Overlay (Hidden by Default) */
.megamenu-overlay {
    position: fixed;
    top: 60px; /* Adjust according to header height */
    left: 0;
    width: 100%;
    height: calc(100% - 60px);
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Roboto', Arial, sans-serif;
    letter-spacing: -0.1px;
}

/* When Menu is Open */
.megamenu-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* Mega Menu Panel */
.megamenu-panel {
    background: #ffffff;
    width: calc(100% - 48px);
    max-width: 1280px; /* Lebar maksimal */
    margin: 0 auto;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    border: 1px solid #e8e8e8;
    transform: translateY(8px);
    transition: transform 0.25s ease;
    overflow-y: auto;
    min-height: 520px;
    height: auto;
    max-height: calc(100vh - 80px); /* Prevent cutoff */
    /* Custom Scrollbar for inner panel */
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.megamenu-overlay.is-active .megamenu-panel {
    transform: translateY(0);
}

.megamenu-panel::-webkit-scrollbar {
    width: 6px;
}
.megamenu-panel::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 10px;
}

/* Grid Layout */
.megamenu-grid {
    display: grid;
    /* Kolom kiri sisanya, kolom kanan FIX 320px sesuai referensi Tirto */
    grid-template-columns: 1fr 320px;
    column-gap: 24px;
    width: 100%;
    box-sizing: border-box;
}

/* ==========================================================================
   LEFT COLUMN: Categories & Tags
   ========================================================================== */
.megamenu-column-left {
    padding: 18px 20px;
}

.megamenu-nav-container {
    display: flex;
    flex-direction: column;
}

/* Jarak antar section */
.megamenu-category-block {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid #ececec;
}
.megamenu-category-block:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.megamenu-heading {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
}

.megamenu-heading a {
    color: #111111;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

.megamenu-heading a:hover {
    color: #0d47a1;
}

.megamenu-heading svg {
    opacity: 0.6;
    margin-top: 1px;
}

/* Susunan tag (jarak atas bawah 6px, kiri kanan 8px) */
.megamenu-tags {
    display: flex;
    flex-wrap: wrap;
    column-gap: 8px;
    row-gap: 6px;
}

.megamenu-tag {
    background: #f5f5f5;
    color: #333333;
    padding: 7px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    line-height: 1.55;
}

.megamenu-tag:hover {
    background: #ededed;
    color: #111111;
}

/* ==========================================================================
   RIGHT COLUMN: Login & Toggles
   ========================================================================== */
.megamenu-column-right {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    background: #fafafa;
    border-left: 1px solid #ececec;
    width: 320px;
    box-sizing: border-box;
}

/* Login Google Box */
.megamenu-login-box {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid #ececec;
}

.megamenu-btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 48px;
    width: 100%;
    background: #ffffff;
    border: 1px solid #dadce0;
    border-radius: 6px;
    color: #3c4043;
    font-weight: 600;
    font-size: 16px;
    text-decoration: none;
    transition: box-shadow 0.25s, background 0.25s;
    margin-bottom: 12px;
}

.megamenu-btn-google:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
    background: #f8f9fa;
}

.megamenu-icon-google {
    width: 20px;
    height: 20px;
}

.megamenu-login-desc {
    margin: 0;
    font-size: 14px;
    color: #444;
    line-height: 1.55;
}

/* Toggles (Dark Mode & Large Font) */
.megamenu-toggles {
    display: flex;
    flex-direction: column;
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid #ececec;
}

.megamenu-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
}
/* Hapus padding atas untuk yang pertama */
.megamenu-toggle-row:first-child {
    padding-top: 0;
}
/* Hapus padding bawah untuk yang terakhir */
.megamenu-toggle-row:last-child {
    padding-bottom: 0;
}

.megamenu-toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    color: #555;
    font-weight: 500;
}

.megamenu-toggle-label svg {
    color: #888;
    width: 16px;
    height: 16px;
}

/* Switch UI - Switch Kecil 42x24 */
.megamenu-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
}

.megamenu-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.megamenu-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.megamenu-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .megamenu-slider {
    background-color: #0d47a1;
}

input:checked + .megamenu-slider:before {
    transform: translateX(18px);
}

/* Privacy Info */
.megamenu-privacy {
    margin-top: 0;
}

.megamenu-privacy p {
    margin: 0;
    font-size: 14px;
    color: #777;
    line-height: 1.55;
}

.megamenu-privacy a {
    color: #0d47a1;
    text-decoration: none;
}
.megamenu-privacy a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   LARGE FONT MODE OVERRIDE (Zoom Technique)
   ========================================================================== */
html.large-font-mode {
    zoom: 1.1;
}

/* ==========================================================================
   DARK MODE OVERRIDES (CSS Variables)
   ========================================================================== */
html[data-theme="dark"] .megamenu-panel {
    background: #1a1a1a;
    border-color: #333;
}
html[data-theme="dark"] .megamenu-column-left,
html[data-theme="dark"] .megamenu-column-right {
    border-color: #333;
}
html[data-theme="dark"] .megamenu-category-block,
html[data-theme="dark"] .megamenu-login-box,
html[data-theme="dark"] .megamenu-toggles {
    border-color: #333;
}
html[data-theme="dark"] .megamenu-heading a {
    color: #f1f1f1;
}
html[data-theme="dark"] .megamenu-tag {
    background: #2a2a2a;
    color: #e0e0e0;
}
html[data-theme="dark"] .megamenu-tag:hover {
    background: #3a3a3a;
    color: #fff;
}
html[data-theme="dark"] .megamenu-column-right {
    background: #111;
}
html[data-theme="dark"] .megamenu-btn-google {
    background: #222;
    border-color: #444;
    color: #ddd;
}
html[data-theme="dark"] .megamenu-btn-google:hover {
    background: #333;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
html[data-theme="dark"] .megamenu-login-desc,
html[data-theme="dark"] .megamenu-toggle-label,
html[data-theme="dark"] .megamenu-privacy p {
    color: #bbb;
}
html[data-theme="dark"] .megamenu-privacy a {
    color: #64b5f6;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1024px) {
    .megamenu-grid {
        /* Tablet: Kolom kanan tetap 320px, kiri ambil sisa */
        grid-template-columns: 1fr 320px;
    }
}

@media (max-width: 768px) {
    .megamenu-panel {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        height: 100vh;
        max-height: calc(100vh - 60px);
    }
    .megamenu-grid {
        grid-template-columns: 1fr;
    }
    .megamenu-column-right {
        width: 100%;
        border-left: none;
        border-top: 1px solid #ececec;
    }
    html[data-theme="dark"] .megamenu-column-right {
        border-top-color: #333;
    }
}
