/* ============================================================
   TAJUKRAKYAT.COM — COMPREHENSIVE RESPONSIVE FIX
   Covers: Desktop (1024px+), Tablet (768-1023px), Mobile (max 767px)
   ============================================================ */

/* === BASE FIXES === */
*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: hidden; }
body { overflow-x: hidden; max-width: 100vw; }
img { max-width: 100%; height: auto; display: block; }

/* Prevent text overflow breaking layout */
h1, h2, h3, h4, h5, h6, p, a, span {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* === CONTAINER === */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
}
@media (min-width: 768px) { .container { padding: 0 24px; } }
@media (min-width: 1280px) { .container { padding: 0 32px; } }

/* === TOPBAR === */
.topbar { width: 100%; overflow: hidden; }
.topbar .container { overflow: hidden; }

/* === HEADER === */
.header { width: 100%; }
.header__inner { 
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    gap: 12px;
    flex-wrap: nowrap;
}
.header__logo { flex-shrink: 0; }
.header__ticker { 
    flex: 1; 
    min-width: 0;
    overflow: hidden;
}

/* === NAVIGATION === */
.nav { width: 100%; overflow: visible; }
.nav__inner { 
    display: flex; 
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.nav__inner::-webkit-scrollbar { display: none; }
.nav__menu { flex-shrink: 0; }

/* === BREAKING NEWS === */
.breaking-news { width: 100%; overflow: hidden; }
.breaking-news__inner { overflow: hidden; }
.breaking-news__ticker { 
    flex: 1; 
    min-width: 0; 
    overflow: hidden; 
}

/* === HERO SECTION === */
.hero {
    width: 100%;
    overflow: hidden;
}

/* Desktop hero */
@media (min-width: 1024px) {
    .hero {
        display: grid !important;
        grid-template-columns: 1.65fr 1fr !important;
        grid-template-rows: 1fr 1fr !important;
        gap: 4px !important;
        min-height: 480px;
    }
    .hero__main {
        grid-row: 1 / 3 !important;
        min-height: 480px !important;
    }
    .hero__sidebar { display: contents !important; }
    .hero__side-item { min-height: 236px !important; }
    .hero__main .hero__overlay-title { font-size: 26px !important; }
}

/* Tablet hero */
@media (min-width: 768px) and (max-width: 1023px) {
    .hero {
        display: grid !important;
        grid-template-columns: 1.5fr 1fr !important;
        grid-template-rows: 1fr 1fr !important;
        gap: 4px !important;
        min-height: 380px;
    }
    .hero__main {
        grid-row: 1 / 3 !important;
        min-height: 380px !important;
    }
    .hero__sidebar { display: contents !important; }
    .hero__side-item { min-height: 186px !important; }
    .hero__main .hero__overlay-title { font-size: 22px !important; }
}

/* Mobile hero */
@media (max-width: 767px) {
    .hero {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 4px !important;
        padding: 8px 16px !important;
    }
    .hero__main { min-height: 220px !important; }
    .hero__sidebar {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 4px !important;
    }
    .hero__side-item { min-height: 130px !important; }
    .hero__overlay-title { font-size: 13px !important; -webkit-line-clamp: 2 !important; }
    .hero__main .hero__overlay-title { font-size: 17px !important; -webkit-line-clamp: 3 !important; }
    .hero__overlay { padding: 14px !important; }
}

/* === MAIN CONTENT LAYOUT === */
.content-wrap {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: 16px;
}

/* Tablet: sidebar narrower */
@media (min-width: 768px) and (max-width: 1023px) {
    .content-wrap {
        grid-template-columns: 1fr 260px !important;
        gap: 20px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .content-wrap {
        grid-template-columns: 1fr 300px !important;
        gap: 28px;
    }
}
@media (min-width: 1280px) {
    .content-wrap {
        grid-template-columns: 1fr 320px !important;
        gap: 32px;
    }
}

/* Sidebar sticky */
.sidebar {
    position: sticky;
    top: 70px;
    align-self: start;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }

@media (max-width: 767px) {
    .sidebar {
        position: static;
        max-height: none;
        overflow-y: visible;
    }
}

/* === ARTICLE LIST === */
.article-list__item {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--color-border);
    align-items: flex-start;
    text-decoration: none;
    transition: background var(--transition);
}
.article-list__img-wrap {
    flex-shrink: 0;
    width: 140px;
    height: 94px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-surface);
}
@media (min-width: 768px) and (max-width: 1023px) {
    .article-list__img-wrap { width: 160px; height: 107px; }
    .article-list__title { font-size: 15px !important; }
}
@media (min-width: 1024px) {
    .article-list__img-wrap { width: 180px; height: 120px; }
    .article-list__title { font-size: 16px !important; }
    .article-list__excerpt { display: -webkit-box !important; }
}
@media (max-width: 767px) {
    .article-list__item { gap: 10px; }
    .article-list__img-wrap { width: 100px; height: 68px; }
    .article-list__title { font-size: 13px !important; -webkit-line-clamp: 2 !important; }
    .article-list__excerpt { display: none !important; }
    .article-list__date { font-size: 10px !important; }
}

/* === CATEGORY GRID === */
.category-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 24px;
}
@media (min-width: 768px) and (max-width: 1023px) {
    .category-grid { grid-template-columns: 1fr !important; gap: 16px; }
}
@media (min-width: 1024px) {
    .category-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 20px; }
}

.category-grid__item {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    overflow: hidden;
}
.category-grid__featured-img {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-surface);
    margin-bottom: 10px;
}
.category-grid__featured-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.category-grid__list-img {
    width: 72px;
    height: 52px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-surface);
}
.category-grid__list-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* === SIDEBAR WIDGETS === */
.sidebar__widget {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
    overflow: hidden;
}
.sidebar__title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--color-border);
    position: relative;
}
.sidebar__title::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 40px;
    height: 2px;
    background: var(--color-primary);
}

/* Sidebar popular posts */
.widget-popular__item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
    text-decoration: none;
    color: inherit;
    transition: color var(--transition);
}
.widget-popular__item:last-child { border-bottom: none; padding-bottom: 0; }
.widget-popular__num {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 800;
    color: var(--color-text-muted);
}
.widget-popular__item:nth-child(1) .widget-popular__num { background: var(--color-secondary); color: #fff; }
.widget-popular__item:nth-child(2) .widget-popular__num { background: var(--color-primary); color: #fff; }
.widget-popular__item:nth-child(3) .widget-popular__num { background: var(--color-accent); color: #000; }
.widget-popular__title { font-size: 13px; font-weight: 500; line-height: 1.4; color: var(--color-text); }
.widget-popular__item:hover .widget-popular__title { color: var(--color-primary); }

/* Sidebar list (with image) */
.widget-list__item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
    text-decoration: none;
}
.widget-list__item:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.widget-list__img-wrap { 
    flex-shrink: 0; 
    width: 80px; 
    height: 56px; 
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-surface);
}
.widget-list__img { width: 100%; height: 100%; object-fit: cover; }
.widget-list__title { font-size: 12px; font-weight: 600; line-height: 1.4; color: var(--color-text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.widget-list__item:hover .widget-list__title { color: var(--color-primary); }
.widget-list__date { font-size: 10px; color: var(--color-text-muted); margin-top: 3px; display: block; }

/* Topics widget */
.widget-topik__grid { display: flex; flex-wrap: wrap; gap: 8px; }
.widget-topik__item {
    padding: 5px 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}
.widget-topik__item:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* === ARTICLE PAGE === */
@media (min-width: 1024px) {
    .article__title { font-size: 34px !important; line-height: 1.25 !important; }
    .article__content { font-size: 16px !important; line-height: 1.8 !important; }
}
@media (min-width: 768px) and (max-width: 1023px) {
    .article__title { font-size: 26px !important; }
    .article__content { font-size: 15px !important; }
}
@media (max-width: 767px) {
    .article__title { font-size: 20px !important; line-height: 1.3 !important; }
    .article__content { font-size: 15px !important; line-height: 1.7 !important; }
    .article__meta { font-size: 11px !important; gap: 8px !important; }
    .article__featured-img { border-radius: var(--radius-md) !important; }
}

/* Article content images */
.article__content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 16px auto;
    display: block;
}

/* === SECTION HEADER === */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border);
}
.section-header__title {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    padding-left: 12px;
    border-left: 4px solid var(--color-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
}
@media (max-width: 767px) {
    .section-header__title { font-size: 15px !important; padding-left: 10px !important; }
}

/* === RELATED POSTS === */
@media (min-width: 1024px) {
    .widget-related__grid { grid-template-columns: repeat(3, 1fr) !important; gap: 16px !important; }
    .widget-related__item { flex-direction: column !important; }
    .widget-related__img-wrap { width: 100% !important; height: 140px !important; }
}
@media (min-width: 768px) and (max-width: 1023px) {
    .widget-related__grid { grid-template-columns: repeat(2, 1fr) !important; gap: 12px !important; }
    .widget-related__item { flex-direction: column !important; }
    .widget-related__img-wrap { width: 100% !important; height: 120px !important; }
}
@media (max-width: 767px) {
    .widget-related__grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    .widget-related__item { flex-direction: column !important; }
    .widget-related__img-wrap { width: 100% !important; height: 90px !important; }
    .widget-related__title { font-size: 12px !important; -webkit-line-clamp: 2 !important; }
}

/* === FOOTER === */
@media (min-width: 1024px) {
    .footer__grid { grid-template-columns: 1.8fr 1fr 1fr 1fr !important; }
}
@media (min-width: 768px) and (max-width: 1023px) {
    .footer__grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 767px) {
    .footer__grid { grid-template-columns: 1fr !important; gap: 24px !important; }
    .footer { padding-bottom: 70px; }
}

/* === PAGINATION === */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 24px; flex-wrap: wrap; }
.pagination__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-bg-card);
    color: var(--color-text-secondary);
    font-size: 13px;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}
.pagination__btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.pagination__btn--active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.pagination__btn--disabled { opacity: 0.4; pointer-events: none; }

/* === BOTTOM NAV (Mobile only) === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-bg-card);
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 6px 0 env(safe-area-inset-bottom, 6px);
    z-index: 200;
    box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    color: var(--color-text-muted);
    padding: 4px 12px;
    text-decoration: none;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
}
.bottom-nav__item i { font-size: 18px; }
.bottom-nav__item--active { color: var(--color-primary); }

@media (min-width: 768px) {
    .bottom-nav { display: none !important; }
    body { padding-bottom: 0 !important; }
}
@media (max-width: 767px) {
    body { padding-bottom: 60px; }
}

/* === SEARCH EXPAND === */
.search-expand {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: var(--color-bg);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
}
.search-expand--open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* === LOAD MORE BUTTON === */
.load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 28px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}
.load-more-btn:hover { background: var(--color-primary-dark); transform: translateY(-1px); }
.load-more-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
@media (max-width: 767px) {
    .load-more-btn { width: 100%; justify-content: center; padding: 12px; }
}

/* === SHARE BUTTONS === */
@media (max-width: 767px) {
    .share-buttons__btn span { display: none; }
    .share-buttons__btn { padding: 8px 12px !important; }
}

/* === WIDGET TOPIK MOBILE FIX === */
@media (max-width: 767px) {
    .widget-topik__item { font-size: 11px !important; padding: 4px 10px !important; }
}

/* === PRINT MEDIA (keep isolated) === */
@media print {
    .topbar, .nav, .bottom-nav, .sidebar, .ad-slot, .ad-banner,
    .share-buttons, .comments, .widget-related, .next-article,
    .article__toc, .reading-progress, .search-expand, .footer,
    .breaking-news { display: none !important; }
    .content-wrap { grid-template-columns: 1fr !important; }
    body { background: #fff !important; color: #000 !important; }
}

/* === DARK MODE FIXES === */
html.dark .sidebar__widget { background: var(--color-bg-card); border-color: var(--color-border); }
html.dark .category-grid__item { background: var(--color-bg-card); border-color: var(--color-border); }
html.dark .widget-popular__item { border-color: var(--color-border); }
html.dark .widget-list__item { border-color: var(--color-border); }
html.dark .article-list__item:hover { background: var(--color-surface); }
html.dark .bottom-nav { background: var(--color-bg-card); border-color: var(--color-border); }

/* === LIGHTBOX IMAGE PREVIEW === */
#imgLightbox{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.92);z-index:99999;align-items:center;justify-content:center;cursor:zoom-out}
#imgLightbox.active{display:flex !important}
#imgLightbox img{max-width:92vw;max-height:85vh;object-fit:contain;border-radius:8px;box-shadow:0 20px 60px rgba(0,0,0,.5);cursor:default;animation:lbZoom .2s ease}
@keyframes lbZoom{from{transform:scale(.85);opacity:0}to{transform:scale(1);opacity:1}}
#imgLightbox .lb-close{position:fixed;top:16px;right:20px;color:#fff;font-size:28px;cursor:pointer;width:44px;height:44px;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,.12);border-radius:50%;z-index:1;transition:background .2s;line-height:1}
#imgLightbox .lb-close:hover{background:rgba(255,255,255,.25)}
#imgLightbox .lb-caption{position:fixed;bottom:0;left:0;right:0;text-align:center;color:rgba(255,255,255,.75);font-size:13px;padding:14px 20px 20px;background:linear-gradient(to top,rgba(0,0,0,.6),transparent);pointer-events:none}
#imgLightbox .lb-counter{position:fixed;top:18px;left:50%;transform:translateX(-50%);color:rgba(255,255,255,.65);font-size:12px;background:rgba(0,0,0,.45);padding:4px 14px;border-radius:20px;pointer-events:none}
#imgLightbox .lb-nav{position:fixed;top:50%;transform:translateY(-50%);color:#fff;font-size:28px;cursor:pointer;width:48px;height:48px;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,.12);border-radius:50%;transition:background .2s;user-select:none;line-height:1}
#imgLightbox .lb-nav:hover{background:rgba(255,255,255,.28)}
#imgLightbox .lb-prev{left:16px}
#imgLightbox .lb-next{right:16px}
@media(max-width:767px){#imgLightbox .lb-prev{left:8px}#imgLightbox .lb-next{right:8px}#imgLightbox .lb-nav{width:40px;height:40px}}
.article__content img,.article__featured-img{cursor:zoom-in}
