/* =========================================================
   SIAPP - Responsive layer untuk perangkat mobile/tablet
   Dimuat setelah style.css. Hanya aktif pada layar sempit.
   ========================================================= */

/* ---- Umum (semua ukuran) ---- */
img { max-width: 100%; }
.content-wrapper, .main-footer { overflow-x: hidden; }
.content { word-wrap: break-word; }
.dataTables_wrapper { max-width: 100%; }

/* ---- Tablet & bawah (<= 991px) ---- */
@media (max-width: 991px) {
  .dataTables_wrapper .dataTables_filter { text-align: left; }
  .dataTables_wrapper .dataTables_filter input { max-width: 100%; }
}

/* ---- Mobile (<= 767px) ---- */
@media (max-width: 767px) {
  /* Ukuran gambar logo mengecil (tinggi blok tetap) */
  .main-header .logo .logo-lg { background-size: auto 76%; background-position: center; }
  .content-wrapper > .content { padding: 10px; }
  .content-header { padding: 10px; }
  .content-header > h1 { font-size: 18px; }
  .content-header > .breadcrumb { position: static; float: none; margin-top: 8px; padding: 0; background: transparent; }

  .box-header .box-title { font-size: 16px; }
  .box-header .box-tools { position: static; margin-top: 6px; }
  .box-header .btn, .box-body > .btn { margin-bottom: 4px; }

  /* Tabel */
  table.table, table.dataTable { max-width: none; }
  .table > thead > tr > th,
  .table > tbody > tr > td,
  .table > tfoot > tr > td { font-size: 12px; padding: 6px; }
  .table-responsive { border: 0; }
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate { float: none !important; text-align: center; display: block; }
  .dataTables_wrapper .dataTables_paginate { white-space: normal; }
  .dataTables_wrapper .dataTables_paginate ul.pagination { display: inline-block; margin: 6px 0 10px; }
  .dataTables_wrapper .dataTables_filter input { width: 100%; margin-left: 0; }

  /* Form: label di atas input, input penuh */
  .form-horizontal .control-label, .row > label.control-label { text-align: left; padding-top: 0; margin-bottom: 4px; }
  /* Pasangan label + nilai: dua kolom rata (label kiri, nilai kanan) */
  .row > label.control-label { display: inline-block; vertical-align: top; float: none; width: 44%; max-width: 44%; margin: 0 0 8px; padding: 0 15px; text-align: left; }
  .row > label.control-label + label.control-label { width: 55%; max-width: 55%; padding-left: 0; font-weight: normal; }
  .row > label.control-label > div { display: block; text-align: left; font-weight: normal; word-break: break-word; }
  /* Label yang berdiri sendiri (di atas input) tetap penuh */
  .row > label.control-label:only-of-type, .row > label.control-label:has(+ div), .row > label.control-label:has(+ input), .row > label.control-label:has(+ select) { display: block; width: 100%; max-width: 100%; }
  .form-horizontal .form-group { margin-left: 0; margin-right: 0; }
  .form-control, .select2-container { max-width: 100%; }
  .select2-container { width: 100% !important; }
  .input-group { max-width: 100%; }
  .comboTreeWrapper, .comboTreeInputWrapper { max-width: 100%; }
  textarea.form-control { max-width: 100%; }
  .btn-group-vertical-xs > .btn { display: block; width: 100%; margin-bottom: 4px; }
  .box-footer .btn, .modal-footer .btn { margin-bottom: 4px; }

  /* Modal */
  .modal-dialog, .modal-lg, .modal-sm { width: auto; max-width: none; margin: 8px; }
  .modal-content { max-width: 100%; }
  .modal-body { padding: 12px; }
  .modal-footer { text-align: right; }
  .modal-footer .btn { width: auto; }
  .modal-header .modal-title { font-size: 16px; padding-right: 20px; }

  /* Form wizard (SmartWizard) */
  .sw-main, .sw-container { max-width: 100%; }
  .sw-main .sw-container { overflow-x: hidden; }
  /* Judul wizard: kartu bertumpuk, satu per baris (gaya KERIS) */
  ul.step-anchor { display: block !important; overflow: visible; white-space: normal; padding: 0; margin: 0 0 10px; list-style: none; background: transparent !important; border: 0 !important; }
  ul.step-anchor > li { display: block !important; float: none !important; width: 100% !important; margin: 0 0 6px !important; padding: 0 !important; border: 0 !important; background: transparent !important; }
  ul.step-anchor > li > a,
  ul.step-anchor > li > a:hover {
    display: block !important; width: 100%; height: auto !important; min-height: 44px; margin: 0 !important;
    padding: 10px 14px !important; font-size: 15px; font-weight: bold; line-height: 24px;
    white-space: normal; text-align: left; border-radius: 8px !important;
    background: #cfeee7 !important; color: #1f6b5a !important; opacity: .75; border: 0 !important;
  }
  ul.step-anchor > li > a:before, ul.step-anchor > li > a:after { display: none !important; }
  ul.step-anchor > li.active > a { background: #fff !important; color: #17594a !important; opacity: 1; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
  ul.step-anchor > li.done > a { background: #1bbc9b !important; color: #fff !important; opacity: 1; }
  .sw-main .sw-toolbar { display: flex; justify-content: space-between; flex-wrap: wrap; }
  .sw-main .sw-toolbar > .btn { margin: 4px 2px; }
  .sw-main .step-content { padding: 10px 6px; }

  /* Tab Bootstrap: bisa digeser */
  .nav-tabs { overflow-x: auto; overflow-y: hidden; white-space: nowrap; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .nav-tabs > li { float: none; display: inline-block; }

  /* Pembungkus lain */
  .callout, .alert { word-wrap: break-word; }
  pre { white-space: pre-wrap; word-break: break-all; }
  .main-footer { text-align: center; }
  .main-footer .pull-right { float: none !important; display: block; margin-bottom: 4px; }
  .datepicker, .bootstrap-datetimepicker-widget { max-width: 100vw; }
  .notifyjs-corner { max-width: 95vw; }
  .notifyjs-bootstrap-base { white-space: normal !important; }
}

/* ---- HP kecil (<= 480px) ---- */
@media (max-width: 480px) {
  .btn { white-space: normal; }
  .small-box .icon { display: none; }
  .modal-dialog { margin: 4px; }
}

/* ---- DataTables Responsive (tata letak mengikuti KERIS) ---- */
.dataTables_scrollHeadInner, table.dataTable { width: 100% !important; }
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before { top: 16px; }
table.dataTable.dtr-inline.collapsed > tbody > tr > td.child,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.child,
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dataTables_empty { background: #f3fbf9; padding: 0; }
table.dataTable > tbody > tr.child { background: #f3fbf9; }
table.dataTable > tbody > tr.child ul.dtr-details { display: block; margin: 0; padding: 0; list-style: none; width: 100%; }
table.dataTable > tbody > tr.child ul.dtr-details > li {
  display: block; padding: .5em 10px; border-bottom: 1px solid #e6efed; white-space: normal; word-break: break-word;
}
table.dataTable > tbody > tr.child ul.dtr-details > li:last-child { border-bottom: 0; }
table.dataTable > tbody > tr.child span.dtr-title { display: block; width: 100%; font-weight: bold; margin-bottom: 2px; }
table.dataTable > tbody > tr.child span.dtr-data { display: block; width: 100%; }
div.dataTables_wrapper div.dataTables_paginate ul.pagination { white-space: normal; }
.btn-flex { display: flex; align-items: stretch; align-content: stretch; }
.btn-flex .btn:first-child { flex-grow: 1; text-align: left; }

/* Tombol opsi per baris: rata tengah */
table.dataTable > tbody > tr.child span.dtr-data:has(.btn),
table.dataTable > tbody > tr.child span.dtr-data:has(.btn-group) { text-align: center; }
table.dataTable > tbody > tr > td:has(> .btn),
table.dataTable > tbody > tr > td:has(> .btn-group) { text-align: center; }
table.dataTable > tbody > tr.child span.dtr-data .btn-group,
table.dataTable > tbody > tr.child span.dtr-data .btn-flex { justify-content: center; }

/* Wizard: tanpa scroll sumbu X pada kontainer konten */
.sw-container.tab-content,
.sw-main .sw-container,
.sw-container.tab-content > .step-content,
.sw-main .step-content { overflow-x: hidden !important; }

/* Modal: tanpa scroll internal pada dialog/konten/body */
.modal-dialog, .modal-content, .modal-body { overflow: visible !important; max-height: none !important; }

/* Tabel di dalam modal: tanpa scroll internal */
.modal .dataTables_wrapper,
.modal .table-responsive,
.modal .dataTables_scroll,
.modal .dataTables_scrollBody { overflow: visible !important; max-height: none !important; }

/* DataTables wrapper: tanpa scroll */
.dataTables_wrapper { overflow: visible !important; }

/* Teks panjang (mis. URL) tidak melebarkan tabel */
table.dataTable td { overflow-wrap: break-word; }

/* Daftar checkbox (mis. SDGs): teks baris lanjutan rata dengan teks baris pertama */
.form-check { display: flex; align-items: flex-start; margin: 0 0 6px; }
.form-check > .form-check-input { flex: 0 0 auto; margin: 4px 8px 0 0; position: static; }
.form-check > .form-check-label { flex: 1 1 auto; min-width: 0; margin: 0; padding: 0; text-align: left; word-break: break-word; }

/* Menu "Pilihan" di baris detail: lebar sama dengan tombolnya */
table.dataTable > tbody > tr.child .btn-group.btn-flex { position: relative; width: 100%; }
table.dataTable > tbody > tr.child .btn-group.btn-flex > .dropdown-menu {
  left: 0; right: 0; width: 100%; min-width: 100%; margin: 0 0 2px; box-sizing: border-box;
}
table.dataTable > tbody > tr.child .btn-group.btn-flex > .dropdown-menu { padding: 6px 8px; }
table.dataTable > tbody > tr.child .btn-group.btn-flex > .dropdown-menu > li { margin: 0 0 4px; }
table.dataTable > tbody > tr.child .btn-group.btn-flex > .dropdown-menu > li:last-child { margin-bottom: 0; }
table.dataTable > tbody > tr.child .btn-group.btn-flex > .dropdown-menu > li > .btn { width: 100%; box-sizing: border-box; margin: 0; }

/* Baris dengan data kosong: tinggi minimum agar ikon + tidak bertumpuk */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control { min-height: 25px; vertical-align: top; }
table.dataTable.dtr-inline.collapsed > tbody > tr:not(.child) > td { height: 40px; }

/* Kontrol Show/Search DataTables: rata tengah hanya di mobile; di layar lebar kembali ke tepi */
@media (max-width: 767px) {
  div.dataTables_wrapper div.dataTables_filter,
  div.dataTables_wrapper div.dataTables_length { text-align: center !important; float: none !important; display: block; }
  div.dataTables_wrapper div.dataTables_filter { margin-bottom: 14px; }
  div.dataTables_wrapper div.dataTables_length { margin-bottom: 8px; }
  div.dataTables_wrapper div.dataTables_length label { display: inline-block; text-align: center; }
  div.dataTables_wrapper div.dataTables_filter label { display: block; width: 100%; text-align: center; }
  div.dataTables_wrapper div.dataTables_filter input { display: block; width: 100%; margin: 4px 0 0; text-align: center; }
}
@media (min-width: 768px) {
  div.dataTables_wrapper div.dataTables_filter { margin-bottom: 10px; }
}

/* Pastikan sel header tabel selalu berlatar gelap (tidak transparan/putih) */
.table-bordered > thead > tr > th:not(.sorting_asc):not(.sorting_desc) { background-color: #0f3e4d; color: #fff; }

/* Logo halaman login/landing: kecilkan di mobile tanpa mengubah tinggi */
@media (max-width: 767px) {
  .login-logo { background-size: auto 70%; }
}

/* Syarat jadwal: label dan nilai di baris terpisah */
#tabel-jadwal td strong,
#tabel-jadwal .dtr-data strong { display: block; }

/* Header tabel: paksa latar gelap + teks putih pada semua th (termasuk setelah Responsive/recalc) */
table.dataTable.table-bordered > thead > tr > th,
table.dataTable.table-bordered > thead > tr > td,
.table-bordered > thead > tr > th {
  background-color: #0f3e4d !important;
  color: #fff !important;
}
table.dataTable.table-bordered > thead > tr > th.sorting_asc,
table.dataTable.table-bordered > thead > tr > th.sorting_desc {
  background-color: #000 !important;
}

table.dataTable.dtr-inline.collapsed > tbody > tr:not(.child) > td { height: 17px; }
