/* ============================================================
   RESPONSIF — KKN INSIMA v5
   ============================================================ */

/* ---- Sidebar desktop ---- */
.portal { display: flex; min-height: 100vh; }
.sidebar {
  flex: none;
  width: 220px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.portal-main { flex: 1; min-width: 0; padding: 28px 32px; }

/* ---- Sidebar nav items ---- */
.side-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
}

/* ---- Dropdown grup sidebar ---- */
.side-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 4px 16px; /* FIX: padding kiri 16px */
  cursor: pointer;
  user-select: none;
}
.side-group-header span:first-child {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  font-weight: 600;
}
.side-group-header .arrow {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform .2s;
}
.side-group-header.collapsed .arrow { transform: rotate(-90deg); }
.side-group-body { overflow: hidden; transition: max-height .25s ease; }
.side-group-body.collapsed { max-height: 0 !important; }

.side-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  padding: 12px 16px 4px 16px; /* FIX: konsisten 16px */
  font-weight: 600;
}
.side-link {
  display: block !important;
  width: 100% !important;
  padding: 8px 16px; /* FIX: padding kiri 16px */
  font-size: 14px;
  color: var(--text);
  border-left: 3px solid transparent;
  text-decoration: none;
  transition: background .12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.side-link:hover { background: var(--bg-soft); color: var(--text); }
.side-link.active {
  color: var(--primary);
  border-left-color: var(--primary);
  background: var(--primary-light);
  font-weight: 500;
}

/* ---- Burger ---- */
.burger {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 149;
}

/* ---- Komponen ---- */
.portal-head { margin-bottom: 22px; }
.portal-head h1 { font-size: 24px; }
.panel { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card-foto { width: 100%; height: 180px; object-fit: cover; border-radius: var(--radius) var(--radius) 0 0; display: block; }
.card-foto-placeholder { width: 100%; height: 180px; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 40px; border-radius: var(--radius) var(--radius) 0 0; }
.map-popup-img { width: 180px; height: 110px; object-fit: cover; border-radius: 8px; margin-bottom: 6px; display: block; }

/* ---- Footer peta: kecil ~80px ---- */
.footer-maps iframe {
  width: 100%;
  height: 80px; /* ~2cm */
  border: 0;
  border-radius: 6px;
  display: block;
}

/* ============================================================
   MOBILE (< 768px)
   ============================================================ */
@media (max-width: 767px) {
  .burger { display: flex; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 240px;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform .25s;
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .overlay.show { display: block; }
  .portal-main { padding: 60px 16px 24px; }

  /* Sidebar selalu vertikal */
  .side-nav { display: flex !important; flex-direction: column !important; flex-wrap: nowrap !important; }
  .side-link { display: block !important; width: 100% !important; font-size: 15px; padding: 10px 18px; }
  .side-section, .side-group-header { padding: 14px 18px 4px; }

  /* HERO: tampilkan foto di mobile juga */
  .hero-home { padding: 40px 0 32px; }
  .hero-home .hero-grid { grid-template-columns: 1fr !important; }
  .hero-img-wrap { display: block !important; margin-top: 20px; width: 100% !important; max-height: none !important; }
  .hero-img-wrap img { width: 100% !important; height: auto !important; max-height: 280px; object-fit: cover; border-radius: 12px; }

  /* Header */
  .site-header .nav { display: none; }
  .site-header .inner { flex-wrap: wrap; gap: 8px; }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card .n { font-size: 28px; }

  /* Cards */
  .cards { grid-template-columns: 1fr; gap: 14px; }
  .news-grid, .potensi-grid, .prog-grid { grid-template-columns: 1fr; }
  .galeri-grid { grid-template-columns: repeat(2, 1fr); }
  .about-grid { grid-template-columns: 1fr; }

  /* Footer */
  .site-footer .grid { grid-template-columns: 1fr; gap: 20px; }

  /* Tabel */
  .tbl th, .tbl td { padding: 7px 9px; font-size: 12.5px; }
  .act button, .act a { font-size: 11px; padding: 4px 7px; }

  /* Modal dari bawah */
  .modal { align-items: flex-end; padding: 0; }
  .modal .box { border-radius: 16px 16px 0 0; max-height: 90vh; padding: 20px 16px; }

  /* Dashboard */
  .module-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .portal-head h1 { font-size: 20px; }
}

/* ============================================================
   TABLET (768–1024px)
   ============================================================ */
@media (min-width: 768px) and (max-width: 1024px) {
  .sidebar { width: 190px; }
  .side-link { font-size: 13px; padding: 8px 14px; }
  .news-grid, .potensi-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .portal-main { padding: 24px 20px; }
}

/* Override tema lama */
@media (max-width: 860px) {
  .side-nav { display: flex !important; flex-direction: column !important; flex-wrap: nowrap !important; }
  .side-link { display: block !important; width: 100% !important; }
}
