/*
 * Perbaikan tampilan mobile/tablet halaman publik.
 * Dimuat paling akhir di template/layout.twig agar menimpa templatemo/bootstrap/style.css.
 * Aturan desktop (> 991px) sengaja tidak diubah.
 */

/* ---------- Umum ---------- */
html, body {
  overflow-x: hidden;
}

img {
  max-width: 100%;
}

/* Paginasi panjang (mis. berita 30+ halaman) dilipat, bukan memanjang keluar layar */
.pagination {
  flex-wrap: wrap;
  justify-content: center;
  row-gap: 6px;
}

@media (max-width: 991px) {
  /* slide.twig mengosongkan padding .container secara global; kembalikan gutter di layar kecil */
  body .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Tabel lebar bisa digeser di dalam kotaknya sendiri */
  .konten-web table,
  .main-konten table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }

  /* Gambar/video dari editor (CKEditor/Summernote) sering punya width/height tetap */
  .konten-web img,
  .main-konten img {
    height: auto;
  }
  .konten-web iframe,
  .main-konten iframe {
    max-width: 100%;
  }
}

/* ---------- Header & menu hamburger (<= 1199px) ----------
   templatemo hanya memakai hamburger di <= 767px; di 768-1199px menu desktop tidak muat
   dan turun menumpuk di atas hero. Buka/tutup dikendalikan kelas .menu-open pada header
   (diset di template/header.twig) karena templatemo memaksa .nav display:flex !important. */
@media (max-width: 1199px) {
  .header-area {
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
  }

  /* Baris logo + tombol menu */
  .header-area .main-nav {
    position: relative;
    min-height: 60px;
    overflow: visible;
  }
  .header-area .main-nav .logo {
    line-height: 60px !important;
    margin-left: 0 !important;
    float: left;
  }
  .header-area .main-nav .logo img {
    max-height: 38px !important;
    vertical-align: middle;
  }
  .header-area .main-nav .menu-trigger {
    display: block !important;
    top: 10px !important;
    right: 4px !important;
    z-index: 10000;
  }

  /* Menu: tersembunyi, tampil di bawah logo saat dibuka; bisa digulir bila lebih tinggi dari layar */
  .header-area .main-nav .nav {
    display: none !important;
    float: none;
    width: 100%;
    clear: both;
    margin: 0 !important;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    flex-direction: column;
    flex-wrap: nowrap;
  }
  .header-area.menu-open .main-nav .nav {
    display: flex !important;
  }
  .header-area .main-nav .nav > li {
    display: block !important;
    width: 100%;
    padding: 0 !important;
    background: #fff;
    border-bottom: 1px solid #e7e7e7;
  }
  .header-area .main-nav .nav > li:first-child {
    border-top: 1px solid #eee;
  }
  .header-area .main-nav .nav > li > a {
    display: block !important;
    width: 100%;
    height: 50px !important;
    line-height: 50px !important;
    text-align: left !important;
    padding: 0 16px !important;
    border: none !important;
    background: #f7f7f7 !important;
    color: #191a20 !important;
    font-weight: 500 !important;
  }
  .header-area .main-nav .nav > li > a:hover,
  .header-area .main-nav .nav > li > a.active {
    background: #eee !important;
    color: #03646A !important;
  }
  .header-area .main-nav .nav > li > a::before {
    display: none !important;
  }
  .header-area .main-nav .nav > li.dropdown > a.nav-link::after {
    content: "\f107";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    float: right;
  }
  .header-area .main-nav .nav > li.dropdown > a.nav-link.active::after {
    content: "\f106";
  }
  .header-area .main-nav .nav li.nav-item form,
  .header-area .main-nav .nav li.nav-item .gradient-button {
    margin: 10px 12px !important;
  }
  .header-area .main-nav .nav li.nav-item .gradient-button a {
    display: inline-flex !important;
    justify-content: center;
    width: auto;
    height: 42px !important;
    line-height: 42px !important;
    padding: 0 24px !important;
    background: #0E9F8D !important;
    color: #fff !important;
    border-radius: 8px;
  }
  .header-area .main-nav .nav li .search-input-m {
    height: 42px;
  }

  /* Mega menu Layanan/Informasi di dalam menu */
  .dropdown-menu.mega-menu.show {
    position: static !important;
    width: 100% !important;
    padding: 8px 16px !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  .dropdown-menu.mega-menu .row {
    display: block !important;
    margin: 0 !important;
  }
  .dropdown-menu.mega-menu .row > div {
    width: 100%;
    padding: 0;
  }
  .header-area .main-nav .nav .mega-menu .list-group a {
    height: auto !important;
    line-height: 1.4 !important;
    padding: 8px 0 !important;
    background: transparent !important;
    color: #fff !important;
    text-align: left;
  }
  .header-area .main-nav .nav .mega-menu .title-menus {
    margin-top: 8px;
    text-align: left;
  }
}

@media (max-width: 767px) {
  /* Bar kontak: satu baris ringkas (alamat sudah ada di footer & halaman kontak) */
  .header-area .header-topbar .container {
    padding: 6px 12px !important;
  }
  .header-area .header-topbar .topbar-alamat {
    display: none !important;
  }
  .header-area .header-topbar .row > .topbar-kontak.col-md-6 {
    flex-direction: row !important;
    justify-content: center !important;
    gap: 1rem !important;
    font-size: 12px !important;
    padding: 0 !important;
  }
}

/* ---------- Hero beranda (slide.twig) ----------
   Di <= 1199px kotak pencarian & pintasan menutupi teks slide; dipindah ke bawah foto. */
@media (max-width: 1199px) {
  #myCarousel {
    --hero-h: clamp(280px, 46vw, 460px);
    margin-bottom: 24px !important;
  }
  #myCarousel .image-slide img {
    width: 100%;
    height: var(--hero-h);
    object-fit: cover;
  }
  #myCarousel .carousel-caption {
    top: calc(var(--hero-h) / 2);
    left: 5%;
    right: 5%;
  }
  #myCarousel .sub-heading {
    margin-bottom: 0;
  }
  /* Indikator tetap di atas foto (bukan di bawah widget) */
  #myCarousel .carousel-indicators {
    top: calc(var(--hero-h) - 32px);
    bottom: auto;
    margin-bottom: 0;
  }
  #myCarousel .carousel-control-prev,
  #myCarousel .carousel-control-next {
    display: none;
  }
  #myCarousel .search-and-shortcuts-widget {
    position: static;
    width: auto;
    margin: 16px 5% 0;
  }
  #myCarousel .search-and-shortcuts {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 12px;
  }
  #myCarousel .shortcuts-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  #myCarousel .shortcut-card {
    min-width: 0;
  }
}

@media (max-width: 767px) {
  /* Gradasi menutupi seluruh lebar agar teks tetap terbaca di atas foto */
  #myCarousel .carousel-item::before {
    width: 100%;
  }
  #myCarousel .carousel-item::after {
    display: none;
  }
  #myCarousel .carousel-caption {
    left: 16px;
    right: 16px;
  }
  #myCarousel .welcome-text {
    font-size: 12px;
    margin-bottom: 4px;
  }
  #myCarousel .main-heading {
    font-size: 24px;
  }
  #myCarousel .sub-heading {
    font-size: 13px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  #myCarousel .search-and-shortcuts-widget {
    margin: 16px 16px 0;
  }
  #myCarousel .search-and-shortcuts {
    flex-direction: column;
  }
  #myCarousel .search-container {
    padding: 14px;
  }
  #myCarousel .shortcut-card {
    padding: 10px 4px;
  }
  #myCarousel .shortcut-text {
    font-size: 11px;
    line-height: 1.25;
  }
}

@media (max-width: 360px) {
  #myCarousel .shortcuts-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Beranda: Poli Eksekutif, Testimoni ---------- */
@media (max-width: 767px) {
  /* Panah slider pindah ke baris indikator agar tidak menumpuk daftar keunggulan */
  .eksekutif-section {
    padding-bottom: 84px !important;
  }
  .eksekutif-section .eksekutif-navigation {
    top: auto;
    bottom: 16px;
    transform: none;
  }
  .eksekutif-section .eksekutif-nav-btn {
    width: 36px;
    height: 36px;
  }
  .eksekutif-section .eksekutif-indicators {
    bottom: 30px;
  }
}

/* ---------- Footer ---------- */
@media (max-width: 991px) {
  /* templatemo membatasi daftar link 40% lebar sehingga teks terlipat */
  .footer-widget ul {
    max-width: none !important;
  }
  footer .copyright-text p {
    text-align: center !important;
    line-height: 1.8;
  }
}

/* ---------- Halaman konten (berita, layanan, dokter, tarif, dll) ---------- */
@media (max-width: 991px) {
  /* 19 template memakai padding inline "20px 120px" pada .main-konten; di layar kecil
     padding samping itu memakan >60% lebar sehingga isi terjepit satu kata per baris */
  [style*="120px"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}

@media (max-width: 767px) {
  .judul-konten,
  h2.judul-konten {
    font-size: 24px !important;
    line-height: 1.3;
    word-wrap: break-word;
  }
  .judul-konten-white {
    font-size: 24px !important;
  }

  /* Breadcrumb panjang (judul berita/dokter) cukup satu baris dengan elipsis */
  .breadcrumb {
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .breadcrumb .breadcrumb-item {
    white-space: nowrap;
  }
  .breadcrumb .breadcrumb-item.active {
    overflow: hidden;
    flex: 0 1 auto;
    text-overflow: ellipsis;
    min-width: 0;
  }

  /* Footer: daftar link rata tengah seperti judul kolomnya */
  .footer-widget ul {
    padding-left: 0 !important;
    text-align: center !important;
  }
  .footer-widget ul li {
    text-align: center !important;
    justify-content: center;
  }

  /* Tombol "Butuh bantuan?" cukup ikon agar tidak menutupi konten */
  .cc-widget .cc-trigger-text {
    display: none;
  }
  .cc-widget .cc-trigger {
    padding: 6px !important;
    border-radius: 50% !important;
  }
}

@media (max-width: 767px) {
  /* templatemo: "ul, li { display:flex }" global membuat daftar biasa menyamping */
  .list-unstyled {
    display: block;
  }
  .list-unstyled > li {
    display: block;
    margin-bottom: 4px;
  }

  /* Judul di atas foto sampul (detail layanan/profil): selalu di dasar kotak, tidak terpotong */
  .bread-title-profil-layanan-medis,
  .bread-title-profil {
    height: auto !important;
    min-height: 180px;
    display: flex;
    align-items: flex-end;
    padding: 20px;
  }
  .bread-title-profil-layanan-medis label,
  .bread-title-profil label {
    margin: 0 !important;
    font-size: 26px !important;
    line-height: 1.25 !important;
  }
}

@media (max-width: 575px) {
  /* Rata kiri-kanan di layar sempit menghasilkan jarak antarkata yang renggang */
  [style*="text-align:justify"],
  [style*="text-align: justify"] {
    text-align: left !important;
  }
}
