/* ============================================================
   MOBILE RESPONSIVE CSS — Heavenly Blush Order System
   Breakpoint utama: max-width 768px (tablet & HP ≥ 5 inch)
   ============================================================ */

/* ---- GLOBAL MOBILE RESET ---- */
@media (max-width: 768px) {

  /* Body padding lebih kecil di mobile */
  body.p-3,
  body.p-lg-4 {
    padding: 10px !important;
  }

  /* ---- PAGE HEADER ---- */
  .page-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem;
  }

  .page-header .page-title {
    font-size: 1.2rem;
  }

  .page-header .btn,
  .page-header a.btn {
    width: 100%;
    text-align: center;
  }

  /* ---- CARDS ---- */
  .card-ghost {
    border-radius: 10px;
  }

  .card-body {
    padding: 0.75rem !important;
  }

  /* ---- TABLES ---- */
  .table-wrap {
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    font-size: 0.8rem;
  }

  .table th,
  .table td {
    padding: 0.4rem 0.5rem !important;
    white-space: nowrap;
  }

  /* ---- DATATABLES ---- */
  .dataTables_wrapper .dataTables_filter {
    width: 100%;
    text-align: left !important;
    margin-bottom: 0.5rem;
  }

  .dataTables_wrapper .dataTables_filter input {
    width: 100% !important;
    margin-left: 0 !important;
  }

  .dataTables_wrapper .dataTables_length {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .dataTables_wrapper .dataTables_info {
    font-size: 0.75rem;
    text-align: center;
    padding-top: 0.5rem;
  }

  .dataTables_wrapper .dataTables_paginate {
    text-align: center !important;
    margin-top: 0.5rem;
  }

  .dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.3rem 0.6rem !important;
    font-size: 0.8rem;
  }

  /* ---- FORMS ---- */
  .row.g-3>[class*="col-md"],
  .row.g-3>[class*="col-lg"] {
    width: 100% !important;
    flex: 0 0 100%;
    max-width: 100%;
  }

  .form-control,
  .form-select {
    font-size: 0.9rem;
  }

  /* Stack inline form elements */
  .row.align-items-center>.col-auto {
    width: 100%;
    margin-bottom: 0.25rem;
  }

  .row.align-items-center>.col {
    width: 100%;
    flex: 0 0 100%;
  }

  /* ---- ORDER FORM CART CONTROLS ---- */
  .d-flex.justify-content-between.align-items-center.mb-3 {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.5rem;
  }

  .d-flex.gap-2 {
    flex-direction: column;
    width: 100%;
  }

  .d-flex.gap-2 input,
  .d-flex.gap-2 button {
    width: 100%;
  }

  /* Cart table responsive */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-responsive .table {
    min-width: 900px;
    /* Diperlebar agar kolom tidak berhimpitan di mobile */
  }

  /* Penyesuaian khusus untuk input di dalam tabel order */
  .cart-qty {
    min-width: 80px !important;
    text-align: center;
  }

  .cart-unit {
    min-width: 100px !important;
  }

  .cart-price,
  .cart-discount {
    min-width: 100px !important;
  }

  /* Summary section full-width */
  .row.justify-content-end>[class*="col-md"] {
    width: 100% !important;
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Action buttons stack */
  .text-end.mt-3 {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .text-end.mt-3 .btn {
    width: 100%;
    margin-left: 0 !important;
  }

  /* ---- MODALS ---- */
  .modal-dialog {
    margin: 0.5rem !important;
    max-width: calc(100% - 1rem) !important;
  }

  .modal-dialog-lg,
  .modal-lg {
    max-width: calc(100% - 1rem) !important;
  }

  .modal-body {
    padding: 0.75rem;
  }

  .modal-header,
  .modal-footer {
    padding: 0.6rem 0.75rem;
  }

  .modal-title {
    font-size: 1rem;
  }

  /* ---- PILIH BARANG MODAL (Full Screen) ---- */
  #itemModal.modal {
    padding: 0 !important;
    overflow: hidden !important;
  }

  #itemModal .modal-dialog {
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
  }

  #itemModal .modal-content {
    height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    display: flex;
    flex-direction: column;
  }

  #itemModal .modal-header {
    flex: 0 0 auto;
    background-color: #f8f9fa;
    padding: 0.5rem;
  }

  #itemModal .modal-body {
    flex: 1 1 auto;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    padding: 5px;
  }

  #itemModal .modal-footer {
    flex: 0 0 auto;
    background-color: #f8f9fa;
    padding: 0.5rem 0.5rem 1.5rem 0.5rem;
    /* Extra padding bottom agar agak naik */
    border-top: 1px solid #dee2e6;
  }

  /* Pengecilan tombol di footer modal */
  #itemModal .modal-footer .btn {
    font-size: 0.75rem !important;
    padding: 0.3rem 0.6rem !important;
  }

  #itemModal #searchItem {
    margin-bottom: 0.5rem !important;
    font-size: 0.8rem;
    padding: 0.3rem 0.5rem;
  }

  /* Pengecilan teks & fix layout tabel Pilih Barang */
  #itemModal .table {
    font-size: 0.65rem !important;
    table-layout: fixed;
    width: 100%;
    margin-bottom: 0;
  }

  #itemModal .table th,
  #itemModal .table td {
    padding: 0.3rem 0.2rem !important;
    white-space: normal !important;
    /* Agar teks wrap ke bawah */
    word-break: break-word;
    vertical-align: middle;
  }

  #itemModal .table th:nth-child(1),
  #itemModal .table td:nth-child(1) {
    width: 10%;
    text-align: center;
  }

  #itemModal .table th:nth-child(2),
  #itemModal .table td:nth-child(2) {
    width: 30%;
  }

  #itemModal .table th:nth-child(3),
  #itemModal .table td:nth-child(3) {
    width: 60%;
  }

  #itemModal .table th:nth-child(4),
  #itemModal .table td:nth-child(4) {
    display: none !important;
    /* Sembunyikan Kategori agar lebar item lebih lega */
  }

  #itemModal .form-check-input {
    width: 1.2em;
    height: 1.2em;
    margin-top: 0;
  }

  /* ---- BTN GROUP ---- */
  .btn-group.btn-group-sm .btn {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
  }

  /* ---- BADGES ---- */
  .badge {
    font-size: 0.7rem;
    padding: 0.3em 0.5em;
  }

  /* ---- INFO BOXES (Dashboard Home) ---- */
  .info-box {
    padding: 12px;
  }

  .info-box-number {
    font-size: 18px;
  }

  .info-box-text {
    font-size: 12px;
  }

  /* ---- SELECT2 ---- */
  .select2-container {
    width: 100% !important;
  }

  .select2-container--bootstrap-5 .select2-selection {
    min-height: calc(2.2rem + 2px);
    font-size: 0.9rem;
  }

  /* ---- CHIP ---- */
  .chip {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
  }

  /* ---- UTILITY OVERRIDES ---- */
  .d-flex.justify-content-between {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .mb-3 h3 {
    font-size: 1.1rem;
  }

  .text-muted.mb-0 {
    font-size: 0.85rem;
  }

  /* Bantuan button */
  a.btn.btn-outline-info {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
  }
}

/* ============================================================
   DASHBOARD SIDEBAR — Mobile Overlay
   ============================================================ */
@media (max-width: 768px) {

  /* Sidebar sebagai overlay di mobile */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -260px !important;
    width: 220px !important;
    height: 100vh !important;
    z-index: 3000 !important;
    /* Tinggi agar di atas backdrop */
    transition: left 0.3s ease-in-out !important;
    overflow-y: auto !important;
    background-color: #343a40 !important;
  }

  .sidebar.mobile-open {
    left: 0 !important;
  }

  /* Backdrop overlay saat sidebar terbuka */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2999 !important;
    /* Di bawah sidebar (3000) tapi di atas segalanya */
  }

  .sidebar-backdrop.active {
    display: block !important;
  }

  /* Konten full-width di mobile */
  .content {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 10px !important;
  }

  /* iframe full height */
  .content iframe {
    height: calc(100vh - 100px);
  }

  /* Mobile hamburger floating button */
  .mobile-sidebar-toggle {
    display: block !important;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #343a40;
    color: white;
    border: none;
    font-size: 1.4rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1998;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
  }

  .mobile-sidebar-toggle:hover {
    background: #1d53a3;
  }

  /* Welcome bar stacking */
  .content>.d-flex.justify-content-between.align-items-center.mb-3 {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem;
  }

  .content>.d-flex h3 {
    font-size: 1.1rem;
  }
}

/* Hide mobile toggle by default (desktop) */
.mobile-sidebar-toggle {
  display: none;
}

/* ============================================================
   LANDING PAGE (home.php) — Mobile
   ============================================================ */
@media (max-width: 768px) {

  /* Navbar mobile */
  .navbar {
    padding: 8px 12px;
  }

  .logo img {
    width: 60px;
  }

  .login-btn,
  .help-btn {
    font-size: 0.85rem;
    padding: 8px 14px;
  }

  /* Hero section */
  .hero {
    height: auto;
    min-height: 40vh;
    padding: 60px 15px 30px;
  }

  .hero-content h1 {
    font-size: 1.1rem;
  }

  .hero-content p {
    font-size: 0.85rem;
  }

  /* Produk scroll section */
  .produk-scroll-section {
    padding: 30px 10px;
  }

  .produk-scroll-section h2 {
    font-size: 1rem;
  }

  .produk-item {
    width: 130px;
    height: 130px;
  }

  .scroll-track {
    gap: 20px;
  }

  /* Login modal */
  .login-box {
    width: 90%;
    max-width: 300px;
    padding: 20px;
  }

  /* Footer */
  footer {
    padding: 15px;
    font-size: 0.8rem;
    margin-top: 30px;
  }
}

/* ============================================================
   EXTRA SMALL DEVICES (< 360px)
   ============================================================ */
@media (max-width: 360px) {

  body.p-3 {
    padding: 6px !important;
  }

  .table {
    font-size: 0.72rem;
  }

  .btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
  }

  .page-title {
    font-size: 1rem;
  }

  .hero-content h1 {
    font-size: 0.95rem;
  }

  .produk-item {
    width: 100px;
    height: 100px;
  }

  .modal-dialog {
    margin: 0.25rem !important;
  }
}

/* ============================================================
   MOBILE BOTTOM NAVIGATION
   ============================================================ */
@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid #dee2e6;
    z-index: 1997;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease-in-out !important;
  }

  .mobile-bottom-nav.nav-hidden {
    transform: translateY(100%);
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #6c757d;
    font-size: 0.75rem;
    flex: 1;
    transition: color 0.2s;
  }

  .bottom-nav-item i {
    font-size: 1.4rem;
    margin-bottom: 2px;
  }

  .bottom-nav-item.active {
    color: #0d6efd;
    font-weight: bold;
  }

  /* Adjust content padding for bottom nav */
  .content {
    padding-bottom: 75px !important;
  }

  /* Adjust mobile sidebar toggle to be higher to avoid overlapping with bottom nav */
  .mobile-sidebar-toggle {
    bottom: 80px !important;
    transition: transform 0.3s ease-in-out, background 0.2s !important;
  }

  .mobile-sidebar-toggle.toggle-hidden {
    transform: translateY(150px);
  }
}

/* Hide bottom nav on desktop */
.mobile-bottom-nav {
  display: none;
}