/* ============================================
   RESPONSIVE FIX — 3Lensa
   Memperbaiki masalah tampilan di HP, tablet, iOS
   ============================================ */

/* ============ GLOBAL FIX ============ */
html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  max-width: 100vw;
  position: relative;
}

/* Cegah semua elemen overflow keluar viewport */
* {
  max-width: 100%;
}

img, video, iframe, canvas, svg {
  max-width: 100%;
  height: auto;
}

/* Fix iOS zoom saat fokus input */
input, textarea, select, button {
  font-size: 16px;
}
@media (min-width: 768px) {
  input, textarea, select {
    font-size: 14px;
  }
}

/* ============ MOBILE MENU FIX ============ */
/* Menu utama di HP — jadi slide-in dari kanan */
@media (max-width: 640px) {

  /* Nav default */
  .nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: #fff;
    flex-direction: column;
    align-items: stretch;
    padding: 80px 20px 30px;
    overflow-y: auto;
    box-shadow: -10px 0 30px rgba(0,0,0,0.15);
    transition: right 0.3s ease;
    z-index: 999;
    gap: 0;
    display: flex !important;
  }

  .nav.mobile-open {
    right: 0;
  }

  /* Overlay gelap saat menu terbuka */
  body.menu-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
    animation: fadeIn 0.3s ease;
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  /* Tombol close menu (X) */
  .nav-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
  }

  /* Semua link menu */
  .nav > a,
  .nav .dropdown > a {
    display: block;
    padding: 15px 0;
    border-bottom: 1px solid #f0f0f0;
    border-left: none;
    border-right: none;
    font-size: 15px;
    color: #333;
    font-weight: 600;
  }

  /* Dropdown di mobile — selalu tampil (expand) */
  .nav .dropdown {
    position: static;
    width: 100%;
  }

  .nav .dropdown > a {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .nav .dropdown > a::after {
    content: '▼';
    font-size: 10px;
    color: #999;
    transition: transform 0.2s;
  }

  .nav .dropdown.open > a::after {
    transform: rotate(180deg);
  }

  .nav .dropdown-menu {
    position: static !important;
    display: none;
    box-shadow: none;
    border: none;
    border-left: 3px solid #c8102e;
    margin-left: 15px;
    padding-left: 15px;
    background: #fafafa;
    border-radius: 0;
    min-width: 0;
  }

  .nav .dropdown.open .dropdown-menu {
    display: block !important;
  }

  .nav .dropdown-menu a {
    padding: 12px 15px;
    font-size: 13px;
    border-bottom: 1px solid #f0f0f0;
    color: #555;
  }

  .nav .dropdown-menu a:last-child {
    border-bottom: none;
  }

  /* Header action button */
  .header-actions {
    gap: 5px;
  }

  .icon-btn,
  .menu-toggle,
  #dark-toggle {
    width: 38px;
    height: 38px;
  }

  /* Logo lebih kecil di HP */
  .logo img {
    height: 60px !important;
  }

  /* Topbar — sembunyikan beberapa link */
  .topbar-inner {
    flex-direction: column;
    gap: 5px;
    text-align: center;
  }

  .topbar-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  .topbar-links a {
    margin: 0 !important;
    font-size: 12px;
  }

  /* Breaking news */
  .breaking-inner {
    padding: 8px 12px;
    gap: 10px;
  }

  .badge {
    font-size: 10px;
    padding: 3px 8px;
    flex-shrink: 0;
  }

  .ticker-track {
    font-size: 12px;
  }
}

/* ============ TABLET ============ */
@media (max-width: 768px) {
  .container {
    padding: 0 15px;
  }
}

/* ============ HOME — HERO ============ */
@media (max-width: 768px) {
  .hero {
    display: block !important;
  }
  
  .hero-main {
    min-height: 300px !important;
    margin-bottom: 20px;
  }
  
  .hero-overlay {
    padding: 20px !important;
  }
  
  .hero-overlay h1 {
    font-size: 20px !important;
    line-height: 1.3;
  }
  
  .hero-overlay p {
    font-size: 14px !important;
  }
  
  .hero-side {
    flex-direction: column !important;
    overflow-x: visible !important;
  }
  
  .side-card {
    min-width: auto !important;
    display: grid !important;
    grid-template-columns: 100px 1fr !important;
  }
  
  .side-card img {
    width: 100px !important;
    height: 75px !important;
  }
}

/* ============ GRID BERITA ============ */
@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  
  .card img {
    height: 200px !important;
  }
  
  .section-title {
    font-size: 20px !important;
  }
  
  .editor-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ============ ARTIKEL / BERITA.PHP ============ */
@media (max-width: 900px) {
  .layout-with-sidebar {
    display: block !important;
  }
  
  .layout-with-sidebar > aside {
    margin-top: 40px;
  }
  
  .sticky-sidebar {
    position: static !important;
  }
}

@media (max-width: 640px) {
  .artikel-isi,
  article div[style*="font-size:17px"] {
    font-size: 16px !important;
    line-height: 1.7 !important;
  }
  
  article h1,
  .artikel h1 {
    font-size: 24px !important;
    line-height: 1.3 !important;
  }
  
  .artikel-isi img {
    border-radius: 8px !important;
  }
  
  /* Font control di kiri — bikin lebih kecil dan tidak ganggu */
  #font-controls {
    left: 5px !important;
    padding: 3px 2px !important;
  }
  
  #font-controls button {
    width: 28px !important;
    height: 28px !important;
    font-size: 11px !important;
  }
  
  /* Comment form */
  .comment-form-grid,
  form div[style*="grid-template-columns:1fr 1fr"] {
    display: block !important;
  }
  
  form div[style*="grid-template-columns:1fr 1fr"] > * {
    margin-bottom: 10px;
  }
}

/* ============ CSIRT RESPONSIVE ============ */
@media (max-width: 900px) {
  /* Hero CSIRT */
  .csirt-hero {
    padding: 50px 15px 40px !important;
  }
  
  .csirt-hero-inner {
    grid-template-columns: 1fr !important;
    text-align: center !important;
    gap: 20px !important;
  }
  
  .csirt-logo-box {
    max-width: 140px !important;
    margin: 0 auto !important;
    padding: 15px !important;
  }
  
  .csirt-hero-text h1 {
    font-size: 32px !important;
  }
  
  /* Nav CSIRT — horizontal scroll */
  .csirt-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .csirt-nav-inner {
    padding: 0 10px;
  }
  
  .csirt-nav a {
    padding: 15px 12px !important;
    font-size: 12px !important;
  }
  
  /* Content padding */
  .csirt-content {
    padding: 40px 15px !important;
  }
  
  /* Section title */
  .csirt-section-title {
    font-size: 20px !important;
    flex-wrap: wrap;
  }
  
  .csirt-section-title small {
    display: block !important;
    width: 100%;
    margin-left: 0 !important;
    margin-top: 5px;
    font-size: 12px;
  }
}

@media (max-width: 640px) {
  .csirt-page {
    margin: -20px -15px 0 !important;
  }
  
  .csirt-hero {
    padding: 40px 15px 30px !important;
  }
  
  .csirt-hero-text h1 {
    font-size: 26px !important;
  }
  
  .csirt-status {
    font-size: 11px !important;
    padding: 6px 12px !important;
  }
  
  /* Grid event & HOF */
  .csirt-event-grid,
  .hof-grid {
    grid-template-columns: 1fr !important;
    gap: 15px !important;
  }
  
  /* VDP grid jadi 1 kolom */
  .vdp-info-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  
  .vdp-box {
    padding: 20px !important;
  }
  
  .vdp-box pre {
    font-size: 11px !important;
    padding: 12px !important;
  }
  
  /* Statistik */
  .csirt-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  .stat-box .value {
    font-size: 24px !important;
  }
  
  /* Verify box */
  .verify-box {
    padding: 25px 15px !important;
  }
  
  .verify-input {
    font-size: 14px !important;
    padding: 12px 15px !important;
    letter-spacing: 1px !important;
  }
  
  .verify-btn {
    padding: 12px 30px !important;
    font-size: 14px !important;
  }
  
  /* Kontak darurat — grid 1 kolom */
  .csirt-content div[style*="grid-template-columns:repeat(auto-fit,minmax(200px,1fr))"] {
    grid-template-columns: 1fr !important;
  }
  
  /* Section about — grid 1 kolom */
  .csirt-content div[style*="grid-template-columns:repeat(auto-fit,minmax(240px,1fr))"] {
    grid-template-columns: 1fr !important;
  }
}

/* ============ FLOATING BUTTONS ============ */
@media (max-width: 640px) {
  #back-to-top {
    bottom: 20px !important;
    right: 15px !important;
    width: 42px !important;
    height: 42px !important;
    font-size: 18px !important;
  }
  
  #wa-floating {
    bottom: 72px !important;
    right: 15px !important;
    width: 46px !important;
    height: 46px !important;
  }
  
  #wa-floating svg {
    width: 24px !important;
    height: 24px !important;
  }
  
  #reading-progress {
    height: 3px !important;
  }
}

/* ============ FOOTER ============ */
@media (max-width: 640px) {
  .footer {
    padding: 40px 0 0 !important;
  }
  
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 25px !important;
  }
  
  .footer h4 {
    font-size: 14px !important;
  }
  
  .copyright {
    padding: 15px !important;
    font-size: 11px !important;
    text-align: center;
  }
  
  /* Cookie banner */
  #cookieBanner > div {
    flex-direction: column !important;
    gap: 15px !important;
  }
  
  #cookieBanner button {
    flex: 1;
  }
}

/* ============ FIX KATEGORI DI HP ============ */
@media (max-width: 640px) {
  /* Halaman kategori */
  .page-content h1 {
    font-size: 24px !important;
  }
  
  /* Grid card di kategori */
  .grid .card img {
    height: 180px !important;
  }
  
  /* Pagination */
  .pagination,
  div[style*="justify-content:center"][style*="gap:8px"] {
    flex-wrap: wrap !important;
  }
  
  .pagination a,
  div[style*="justify-content:center"] a {
    padding: 6px 12px !important;
    font-size: 13px !important;
  }
}

/* ============ FIX TABEL ============ */
@media (max-width: 768px) {
  /* Tabel di CSIRT bisa di-scroll horizontal */
  .csirt-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  
  /* Tabel admin */
  .tabel {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============ SUPPORT LANDSCAPE ============ */
@media (max-height: 500px) and (orientation: landscape) {
  .nav {
    padding-top: 60px !important;
  }
  
  .nav > a,
  .nav .dropdown > a {
    padding: 10px 0 !important;
  }
}

/* ============ SUPPORT iOS SAFARI ============ */
@supports (-webkit-touch-callout: none) {
  /* iOS-specific fixes */
  body {
    -webkit-overflow-scrolling: touch;
  }
  
  input, textarea, select {
    border-radius: 8px;
    -webkit-appearance: none;
  }
}

/* ============ SUPPORT SMART TV / LARGE SCREEN ============ */
@media (min-width: 1920px) {
  .container {
    max-width: 1440px;
  }
  
  body {
    font-size: 17px;
  }
}