/* ============================================================
   RESPONSIVE MOBILE - buffortune
   Covers: Sidebar Drawer, Navbar, Bottom Nav, Grid/Flex, Tables
   ============================================================ */

/* ==============================================
   1. GLOBAL OVERFLOW PREVENTION
   ============================================== */
html, body {
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
}

.layout-wrapper,
.layout-container,
.layout-page,
.content-wrapper {
  max-width: 100vw;
  overflow-x: hidden;
}

/* ==============================================
   2. SIDEBAR DRAWER (Mobile < 1200px)
   The Sneat template already has drawer behavior
   via layout-menu-toggle. We enhance it here.
   ============================================== */

/* Ensure sidebar is hidden off-screen on mobile */
@media (max-width: 1199px) {
  .layout-menu {
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 1100;
  }

  .layout-menu-expanded .layout-menu {
    transform: translateX(0);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.15);
  }

  /* Overlay when sidebar is open */
  .layout-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1099;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .layout-menu-expanded .layout-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  /* Hamburger button visible */
  .layout-menu-toggle {
    display: flex !important;
  }
}

/* ==============================================
   3. NAVBAR RESPONSIVE
   ============================================== */

/* --- Tablet (< 992px) --- */
@media (max-width: 991px) {
  .layout-navbar .navbar-nav-right {
    flex-wrap: nowrap;
  }

  /* Compact credit/credit_used boxes */
  .layout-navbar .navbar-search-wrapper .rounded-2 {
    padding: 4px 8px !important;
  }

  .layout-navbar .navbar-search-wrapper .rounded-2 span[style*="font-size: 17px"] {
    font-size: 14px !important;
  }

  .layout-navbar .navbar-search-wrapper .rounded-2 span[style*="font-size: 11px"] {
    font-size: 9px !important;
  }
}

/* --- Mobile (< 768px) --- */
@media (max-width: 767px) {
  /* Make navbar more compact */
  #layout-navbar {
    padding: 0.25rem 0.5rem !important;
  }

  /* Hide credit labels, show only values */
  .layout-navbar .navbar-search-wrapper .rounded-2 span[style*="font-size: 11px"] {
    display: none !important;
  }

  .layout-navbar .navbar-search-wrapper .rounded-2 {
    padding: 3px 6px !important;
    margin-right: 4px !important;
    border-radius: 6px !important;
  }

  .layout-navbar .navbar-search-wrapper .rounded-2 span[style*="font-size: 17px"] {
    font-size: 12px !important;
  }

  /* Compact language dropdown */
  .nav-item.dropdown-language {
    margin-left: 4px !important;
    margin-right: 4px !important;
  }

  /* Smaller avatar */
  .navbar-dropdown .avatar img {
    width: 32px !important;
    height: 32px !important;
  }

  /* Reduce navbar gap */
  .navbar-nav.flex-row {
    gap: 2px;
  }
}

/* --- Small Mobile (< 576px) --- */
@media (max-width: 575px) {
  /* Hide credit used box entirely on very small screens */
  .layout-navbar .navbar-nav > .navbar-search-wrapper.mx-1 {
    display: none !important;
  }

  .layout-navbar .navbar-search-wrapper .rounded-2 {
    padding: 2px 5px !important;
  }

  .layout-navbar .navbar-search-wrapper .rounded-2 span[style*="font-size: 17px"] {
    font-size: 11px !important;
  }

  /* Level badge on avatar – smaller */
  .navbar-dropdown .avatar .badge {
    font-size: 6px !important;
    padding: 1px 3px !important;
  }
}

/* ==============================================
   4. BOTTOM NAVIGATION BAR (Mobile Only)
   ============================================== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1090;
  background: #ffffff;
  border-top: 1px solid #e9ecef;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  padding: 0;
  height: 64px;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  background: rgba(255, 255, 255, 0.95);
}

.mobile-bottom-nav__items {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mobile-bottom-nav__item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-bottom-nav__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #6c757d;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  padding: 6px 0;
  transition: color 0.2s ease, transform 0.2s ease;
  width: 100%;
  position: relative;
}

.mobile-bottom-nav__link i {
  font-size: 22px;
  margin-bottom: 2px;
  transition: transform 0.2s ease;
}

.mobile-bottom-nav__link span {
  font-size: 10px;
  white-space: nowrap;
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-bottom-nav__link:hover,
.mobile-bottom-nav__link:focus {
  color: #21337F;
  text-decoration: none;
}

.mobile-bottom-nav__link:hover i {
  transform: scale(1.1);
}

.mobile-bottom-nav__link.active {
  color: #21337F;
  font-weight: 600;
}

.mobile-bottom-nav__link.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: #21337F;
  border-radius: 0 0 4px 4px;
}

/* Badge on bottom nav items */
.mobile-bottom-nav__badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  font-size: 9px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  color: #fff;
  background: #dc3545;
  border-radius: 10px;
  padding: 0 4px;
}

/* Show bottom nav only on mobile */
@media (max-width: 991px) {
  .mobile-bottom-nav {
    display: block;
  }

  /* Add padding to content so it's not hidden behind bottom nav */
  .content-wrapper {
    padding-bottom: 80px !important;
  }

  /* Also pad the layout-page */
  .layout-page {
    padding-bottom: 64px;
  }
}

/* Dark mode support */
[data-theme="dark"] .mobile-bottom-nav,
.dark-style .mobile-bottom-nav {
  background: rgba(43, 48, 60, 0.95);
  border-top-color: #3b4056;
}

[data-theme="dark"] .mobile-bottom-nav__link,
.dark-style .mobile-bottom-nav__link {
  color: #a1a4b5;
}

[data-theme="dark"] .mobile-bottom-nav__link.active,
.dark-style .mobile-bottom-nav__link.active,
[data-theme="dark"] .mobile-bottom-nav__link:hover,
.dark-style .mobile-bottom-nav__link:hover {
  color: #7c6cff;
}

[data-theme="dark"] .mobile-bottom-nav__link.active::before,
.dark-style .mobile-bottom-nav__link.active::before {
  background: #7c6cff;
}

/* ==============================================
   5. CONTENT AREA - GRID / FLEXBOX RESPONSIVE
   ============================================== */

/* --- Tablet (< 992px) --- */
@media (max-width: 991px) {
  /* Stack row items vertically */
  .row > [class*="col-lg-"],
  .row > [class*="col-xl-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Cards take full width */
  .card {
    margin-bottom: 1rem;
  }

  /* Reduce container padding */
  .container-xxl,
  .container-fluid {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .container-p-y {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }
}

/* --- Mobile (< 768px) --- */
@media (max-width: 767px) {
  /* Stack flex-row items vertically */
  .d-flex.flex-row:not(.navbar-nav):not(.mobile-bottom-nav__items):not(.align-items-center):not([class*="dropdown"]) {
    flex-direction: column !important;
  }

  /* Row with multiple cols stacks */
  .row > [class*="col-md-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Cards - full width & compact */
  .card .card-body {
    padding: 0.875rem !important;
  }

  .card .card-header {
    padding: 0.75rem 0.875rem !important;
  }

  /* Stat cards - 2 per row instead of 4 */
  .row > .col-sm-6.col-lg-3,
  .row > .col-xl-3.col-sm-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }
}

/* --- Small Mobile (< 576px) --- */
@media (max-width: 575px) {
  /* Stat cards full width on tiny screens */
  .row > .col-sm-6.col-lg-3,
  .row > .col-xl-3.col-sm-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .container-xxl,
  .container-fluid {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
}

/* ==============================================
   6. TABLE RESPONSIVE
   ============================================== */

/* Wrap tables in scrollable container */
.table-responsive,
.dataTables_wrapper {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  width: 100% !important;
}

@media (max-width: 991px) {
  /* Make DataTables horizontally scrollable */
  .dataTables_wrapper .dataTables_scroll,
  .dataTables_wrapper .dataTables_scrollBody {
    overflow-x: auto !important;
  }

  table.dataTable {
    min-width: 800px;
  }

  /* DataTable controls stack */
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    text-align: left !important;
    margin-bottom: 0.5rem;
  }

  .dataTables_wrapper .dataTables_info {
    font-size: 12px;
    padding-top: 0.5rem;
  }

  .dataTables_wrapper .dataTables_paginate {
    margin-top: 0.5rem;
  }

  .dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.3rem 0.6rem !important;
    font-size: 12px;
  }

  /* General tables */
  .table th,
  .table td {
    white-space: nowrap;
    font-size: 13px;
    padding: 0.5rem 0.625rem !important;
  }
}

@media (max-width: 767px) {
  table.dataTable {
    min-width: 700px;
  }

  .table th,
  .table td {
    font-size: 12px;
    padding: 0.4rem 0.5rem !important;
  }
}

/* ==============================================
   7. FORMS & FILTERS RESPONSIVE
   ============================================== */
@media (max-width: 991px) {
  /* Filter sections stack vertically */
  .d-flex.align-items-center.gap-2,
  .d-flex.align-items-center.gap-3 {
    flex-wrap: wrap;
  }

  /* Form inputs take full width in filter rows */
  .d-flex.align-items-center.gap-2 > .form-control,
  .d-flex.align-items-center.gap-2 > .form-select,
  .d-flex.align-items-center.gap-3 > .form-control,
  .d-flex.align-items-center.gap-3 > .form-select {
    min-width: 0;
    flex: 1 1 auto;
  }

  /* Select2 dropdowns */
  .select2-container {
    width: 100% !important;
    min-width: 0 !important;
  }
}

@media (max-width: 767px) {
  /* Stack filter groups */
  .d-flex.flex-wrap.gap-2 > * {
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }

  /* Input group compact */
  .input-group {
    flex-wrap: nowrap;
  }

  .form-control,
  .form-select {
    font-size: 13px !important;
  }
}

/* ==============================================
   8. MODALS & OFFCANVAS RESPONSIVE
   ============================================== */
@media (max-width: 767px) {
  .modal-dialog {
    margin: 0.5rem !important;
    max-width: calc(100% - 1rem) !important;
  }

  .modal-body {
    padding: 0.875rem !important;
  }

  .offcanvas {
    max-width: 90vw !important;
  }
}

/* ==============================================
   9. TYPOGRAPHY RESPONSIVE
   ============================================== */
@media (max-width: 767px) {
  h1, .h1 { font-size: 1.5rem !important; }
  h2, .h2 { font-size: 1.3rem !important; }
  h3, .h3 { font-size: 1.15rem !important; }
  h4, .h4 { font-size: 1rem !important; }
  h5, .h5 { font-size: 0.9rem !important; }

  p, .fs-6
  {
    font-size: 14px !important;
    line-height: 1.5 !important;
  }

  .breadcrumb {
    font-size: 12px;
  }
}

/* ==============================================
   10. BUTTONS & ACTION BARS RESPONSIVE
   ============================================== */
@media (max-width: 767px) {
  /* Stack action buttons */
  .d-flex.gap-2 > .btn,
  .d-flex.gap-3 > .btn {
    flex: 1 1 auto;
    font-size: 12px;
    padding: 0.4rem 0.75rem;
  }

  .btn-group {
    flex-wrap: wrap;
  }
}

/* ==============================================
   11. TABS RESPONSIVE
   ============================================== */
@media (max-width: 767px) {
  .nav-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav-tabs::-webkit-scrollbar {
    display: none;
  }

  .nav-tabs .nav-item {
    flex: 0 0 auto;
  }

  .nav-tabs .nav-link {
    white-space: nowrap;
    font-size: 13px;
    padding: 0.5rem 0.875rem;
  }
}

/* ==============================================
   12. CHART CONTAINERS RESPONSIVE
   ============================================== */
@media (max-width: 991px) {
  .highcharts-container,
  [id*="chart"],
  [id*="Chart"] {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ==============================================
   13. NOTIFICATION / BADGE RESPONSIVE
   ============================================== */
@media (max-width: 767px) {
  .badge {
    font-size: 10px;
    padding: 0.2em 0.5em;
  }
}

/* ==============================================
   14. HOME / PUBLIC PAGES RESPONSIVE
   ============================================== */
@media (max-width: 991px) {
  /* Home page sections */
  .home1-banner-area,
  .home-service-section {
    padding: 2rem 0 !important;
  }
}

@media (max-width: 767px) {
  /* Service/Product cards grid */
  .row > [class*="col-md-4"],
  .row > [class*="col-md-6"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Search bar on home */
  .home-search-container {
    padding: 0 10px !important;
  }

  .home-search-container input {
    font-size: 14px !important;
  }
}

/* ==============================================
   15. INBOX / CHAT RESPONSIVE
   ============================================== */
@media (max-width: 991px) {
  .app-chat .app-chat-sidebar-left,
  .app-chat .app-chat-contacts {
    width: 100% !important;
    max-width: 100% !important;
  }

  .app-chat .app-chat-history {
    width: 100% !important;
  }
}

/* ==============================================
   16. PROFILE PAGE RESPONSIVE
   ============================================== */
@media (max-width: 767px) {
  .user-profile-header .d-flex {
    flex-direction: column !important;
    text-align: center;
  }

  .user-profile-header .avatar-xl,
  .user-profile-header .avatar-lg {
    margin: 0 auto 1rem !important;
  }
}

/* ==============================================
   17. PRINT HIDE BOTTOM NAV
   ============================================== */
@media print {
  .mobile-bottom-nav {
    display: none !important;
  }
}

/* ==============================================
   18. SAFE AREA (Notch) SUPPORT
   ============================================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(64px + env(safe-area-inset-bottom));
  }

  @media (max-width: 991px) {
    .content-wrapper {
      padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }
  }
}

/* ==============================================
   19. IMAGES & MEDIA RESPONSIVE
   ============================================== */
img, video, iframe, embed, object {
  max-width: 100%;
  height: auto;
}

@media (max-width: 767px) {
  .avatar img,
  .avatar-xl img,
  .avatar-lg img {
    width: 40px !important;
    height: 40px !important;
  }
}

/* ==============================================
   20. SCROLLBAR HIDDEN ON MOBILE
   ============================================== */
@media (max-width: 991px) {
  .table-responsive::-webkit-scrollbar,
  .dataTables_wrapper::-webkit-scrollbar {
    height: 4px;
  }

  .table-responsive::-webkit-scrollbar-track,
  .dataTables_wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
  }

  .table-responsive::-webkit-scrollbar-thumb,
  .dataTables_wrapper::-webkit-scrollbar-thumb {
    background: #c5c5c5;
    border-radius: 2px;
  }
}

/* ==============================================
   21. ADDITIONAL OVERFLOW FIXES
   ============================================== */
@media (max-width: 991px) {
  pre, code {
    white-space: pre-wrap;
    word-break: break-all;
  }

  .text-nowrap {
    white-space: normal !important;
  }

  /* Long URLs / text */
  td, th, a, span, p, div {
    word-break: break-word;
  }

  /* Fixed width elements */
  [style*="width:"][style*="px"],
  [style*="min-width:"][style*="px"] {
    max-width: 100% !important;
  }
}

/* ==============================================
   22. PAGE-SPECIFIC: ORDER FILTERS
   Handles col-2/col-10 filter layout in order pages
   ============================================== */
@media (max-width: 991px) {
  /* Filter header: stack col-2/col-10 vertically */
  .card-header .row[style*="display: flex"] {
    flex-direction: column !important;
    gap: 10px;
  }

  .card-header .row .col-2,
  .card-header .row .col-10 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .card-header .col-10.gap-2 {
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
  }

  .card-header .col-10.gap-2 .form-floating {
    flex: 1 1 calc(50% - 8px);
    min-width: 120px;
  }

  /* Filter rows stack vertically */
  .card-header .col-12[style*="display: flex"][style*="justify-content: space-between"] {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .card-header .col-12 .d-flex.justify-content-start,
  .card-header .col-12 .d-flex.justify-content-end {
    flex-wrap: wrap !important;
    width: 100% !important;
  }

  .card-header .col-12 .d-flex.justify-content-start .form-floating,
  .card-header .col-12 .d-flex.justify-content-end .form-floating {
    flex: 1 1 calc(50% - 8px);
    min-width: 120px;
  }

  /* Fixed width form floating overrides */
  .form-floating[style*="width: 230px"],
  .form-floating[style*="min-width: 150px"],
  .form-floating[style*="width: 400px"] {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Text wrap with fixed width */
  .text-wrap[style*="width: 400px"],
  .text-wrap {
    width: auto !important;
    max-width: 200px;
  }

  /* DataTables pagination compact */
  .dataTables_wrapper .row:first-child {
    min-height: auto !important;
  }

  .dataTables_wrapper .row:first-child .dataTables_length {
    position: static !important;
  }
}

@media (max-width: 767px) {
  /* Filters go full width on mobile */
  .card-header .col-10.gap-2 .form-floating,
  .card-header .col-12 .d-flex .form-floating {
    flex: 1 1 100% !important;
  }

  /* Fixed width select2 override */
  .fixed-width-select2 {
    width: 100% !important;
  }

  /* More compact text wrap */
  .text-wrap {
    max-width: 150px !important;
  }

  /* Service box compact padding */
  .service_box {
    margin-top: 10px !important;
  }

  .service_box .line-bottom {
    padding: 12px !important;
  }

  .service_box .line-bottom h4,
  .service_box .line-bottom .h4 {
    font-size: 0.95rem !important;
  }
}

/* ==============================================
   23. PAGE-SPECIFIC: DATERANGEPICKER MOBILE
   ============================================== */
@media (max-width: 767px) {
  .daterangepicker {
    width: calc(100vw - 20px) !important;
    left: 10px !important;
    right: 10px !important;
  }

  .daterangepicker .drp-calendar {
    width: 100% !important;
    max-width: 100% !important;
  }

  .daterangepicker .drp-calendar.left,
  .daterangepicker .drp-calendar.right {
    float: none !important;
    clear: both !important;
  }
}

/* ==============================================
   24. PAGE-SPECIFIC: PAYMENT PAGES
   ============================================== */
@media (max-width: 767px) {
  /* Deposit step cards */
  .step-deposite .card-body {
    padding: 0.75rem !important;
  }

  /* Payment method radio buttons */
  .payment-method-item {
    padding: 8px !important;
  }
}

/* ==============================================
   25. PAGE-SPECIFIC: SUPPORT/TICKET PAGES
   ============================================== */
@media (max-width: 767px) {
  /* Ticket offcanvas full width */
  .offcanvas.offcanvas-end {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ==============================================
   26. CARD-DATATABLE WRAPPER
   Ensures DataTables within cards scroll properly
   ============================================== */
@media (max-width: 991px) {
  .card-datatable {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .card-datatable > .table,
  .card-datatable > .dataTables_wrapper {
    min-width: 100%;
  }
}

/* ==============================================
   27. ANIMATION FOR BOTTOM NAV APPEARANCE
   ============================================== */
@media (max-width: 991px) {
  .mobile-bottom-nav {
    animation: slideUpNav 0.3s ease-out;
  }

  @keyframes slideUpNav {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
}


