/* HoxTunnel MOD — balanced mobile fixes
   This version fixes the previous oversized cards and keeps the panel layout proportional. */

:root {
  --hox-mobile-card-radius: 16px;
  --hox-mobile-gutter: 12px;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body.hox-nav-open {
  overflow: hidden;
}

.hox-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(2, 6, 23, .50);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .18s ease, visibility .18s ease;
}

.hox-sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
}

button,
.btn,
.nav-link,
.form-control,
.form-select,
a[role='button'] {
  touch-action: manipulation;
}

@media (max-width: 991.98px) {
  :root {
    --hox-sidebar-width: min(84vw, 304px);
  }

  main.d-flex {
    min-width: 0;
  }

  main.d-flex > .container-fluid {
    width: 100%;
    min-width: 0;
  }

  .content {
    height: auto !important;
    min-height: calc(100dvh - 64px);
    padding: 14px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  .header {
    min-height: 60px;
    height: auto;
    padding: 9px 12px;
    gap: 10px;
    z-index: 1030;
  }

  .header .d-flex.align-items-center.ms-auto {
    min-width: 0;
    justify-content: flex-end;
  }

  .header a {
    min-width: 0;
    max-width: min(54vw, 240px);
    padding: 6px 8px;
  }

  .header a span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header button,
  #toggle-theme-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px;
    flex: 0 0 auto;
  }

  .sidebar {
    max-width: var(--hox-sidebar-width);
    width: var(--hox-sidebar-width);
    padding: 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0 20px 20px 0;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .sidebar-header {
    margin-bottom: 12px;
    padding-bottom: 12px;
  }

  .nav-link {
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 13px;
  }

  .row {
    --bs-gutter-x: .85rem;
    --bs-gutter-y: .85rem;
  }

  .card,
  .modal-content,
  .table-responsive,
  .hox-hero,
  .admin-card {
    border-radius: var(--hox-mobile-card-radius) !important;
  }

  /* Critical fix: do NOT stretch dashboard cards to viewport height. */
  .card.h-100 {
    height: auto !important;
    min-height: 0 !important;
  }

  .card-body {
    padding: 14px !important;
  }

  .hox-hero {
    grid-template-columns: 1fr;
    padding: 18px;
    margin-bottom: 14px;
  }

  .hox-hero h1,
  h1.h3,
  .text-gray-800,
  .hox-page-title {
    font-size: clamp(1.25rem, 5.2vw, 1.75rem) !important;
    line-height: 1.12;
    margin-bottom: 8px !important;
  }

  .btn {
    min-height: 38px;
    white-space: normal !important;
  }

  .btn-sm {
    min-height: 34px;
  }

  .form-control,
  .form-select,
  .input-group-text {
    min-height: 40px;
    font-size: 16px !important;
  }

  textarea.form-control,
  textarea.code {
    min-height: 180px !important;
    font-size: 13px !important;
    line-height: 1.55;
  }

  .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    min-width: 720px;
  }

  .pagination {
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
  }

  .page-link {
    min-width: 36px;
    text-align: center;
  }

  iframe,
  .theme-preview-frame,
  .preview-frame {
    width: 100% !important;
    max-width: 100% !important;
  }
}

@media (max-width: 767.98px) {
  .content {
    padding: 10px !important;
  }

  .header a {
    max-width: 44vw;
  }

  .header a span {
    display: none;
  }

  .header a img {
    margin-left: 0 !important;
  }

  .row {
    --bs-gutter-x: .7rem;
    --bs-gutter-y: .7rem;
  }

  .card-body {
    padding: 12px !important;
  }

  .content .d-md-flex,
  .content .d-sm-flex,
  .content .mobile-stack {
    flex-direction: column !important;
  }

  .content .d-flex.flex-wrap.gap-2,
  .content .d-flex.gap-2 {
    align-items: stretch !important;
  }

  .content .d-flex > .btn,
  .content .d-flex > a.btn,
  .content .d-flex > .form-control,
  .content .d-flex > .form-select,
  .content .input-group,
  .content .search-config,
  .content #userSearch,
  .content #statusFilter {
    max-width: 100% !important;
  }

  .modal-dialog {
    margin: 8px;
  }

  .modal-dialog-scrollable .modal-content {
    max-height: calc(100dvh - 16px);
  }

  .swal2-popup {
    width: calc(100vw - 24px) !important;
    max-width: 520px !important;
    border-radius: 20px !important;
  }
}

@media (max-width: 575.98px) {
  .content {
    padding: 8px !important;
  }

  .header {
    min-height: 58px;
    padding: 8px 10px;
  }

  .sidebar {
    max-width: 86vw;
    width: 86vw;
    border-radius: 0 18px 18px 0;
  }

  .btn,
  .form-control,
  .form-select,
  .input-group-text {
    border-radius: 12px !important;
  }

  .modal-dialog {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    align-items: flex-end;
  }

  .modal-content {
    width: 100%;
    border-radius: 22px 22px 0 0 !important;
    max-height: 92dvh;
  }

  .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}
