/* ========== RESPONSIVE - ALL DEVICES ========== */

/* Large screens (1200px+) - default Bootstrap behavior */

/* Tablets & small laptops (992px - 1199px) */
@media only screen and (max-width: 1199px) {
  .table-responsive {
    white-space: nowrap;
  }
  .sidebar-wrapper {
    left: -260px;
  }
  .sidebar-wrapper .sidebar-header .sidebar-close {
    display: flex;
  }
  .top-header .navbar {
    left: 0;
  }
  .main-wrapper {
    margin-left: 0;
  }
  .page-content {
    margin-left: 0;
  }
  .page-footer {
    left: 0px;
  }
  .mini-sidebar {
    left: -70px;
  }
  .toggled .sidebar-wrapper {
    width: 260px;
    left: 0px;
  }
  .toggled .sidebar-wrapper .sidebar-header {
    width: 260px;
  }
  .toggled .sidebar-wrapper .sidebar-bottom {
    width: 260px;
  }
  .toggled .logo-name {
    display: block;
  }
  .toggled .top-header .navbar {
    left: 0px;
  }
  .toggled .page-footer {
    left: 0px;
  }
  .toggled .main-wrapper {
    margin-left: 0;
  }
  .toggled .overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: #000;
    opacity: 0.5;
    z-index: 11;
    display: block;
    cursor: move;
    transition: all 0.23s ease-out;
  }
  .top-header .navbar .dropdown {
    position: static;
  }
  .top-header .navbar .dropdown .dropdown-menu {
    width: 100%;
  }
  .top-header .navbar .dropdown .dropdown-menu::after {
    display: none;
  }
  .top-header .navbar .mega-menu-widgets {
    padding: 1rem;
    position: relative;
    height: 480px;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .card-body {
    padding: 1rem;
  }
}

/* Tablets (768px - 991px) */
@media only screen and (max-width: 991px) {
  .search-popup {
    position: fixed !important;
    top: 0 !important;
    z-index: 10;
  }
  .row-cols-xl-4 > .col {
    flex: 0 0 50%;
    max-width: 50%;
  }
  .main-content {
    padding: 0.75rem;
  }
  .filter-container .row {
    flex-direction: column;
  }
  .filter-container .col-auto {
    width: 100%;
  }
  .filter-container .col-auto input,
  .filter-container .col-auto button {
    width: 100%;
  }
  .card .card-body {
    padding: 0.875rem;
  }
  h4, .h4 {
    font-size: 1.1rem;
  }
  h5, .h5 {
    font-size: 0.95rem;
  }
}

/* Mobile landscape (576px - 767px) */
@media only screen and (max-width: 767px) {
  .row-cols-xl-4 > .col {
    flex: 0 0 100%;
    max-width: 100%;
  }
  .row-cols-1.row-cols-xl-4 {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  .top-header {
    padding: 0 0.5rem;
  }
  .top-header .navbar {
    padding: 0.5rem 0;
  }
  .sidebar-wrapper {
    width: 280px;
  }
  .main-content {
    padding: 0.5rem;
  }
  .card {
    margin-bottom: 0.75rem;
  }
  .card-body {
    padding: 0.75rem;
  }
  .filter-container {
    padding: 0.75rem !important;
  }
  .filter-container .row.g-3 > .col-auto {
    padding: 0.25rem 0;
  }
  .table-responsive {
    font-size: 0.8rem;
  }
  .table-responsive table {
    min-width: 500px;
  }
}

/* Mobile portrait (under 576px) */
@media only screen and (max-width: 575px) {
  .main-content {
    padding: 0.375rem;
  }
  .card-body {
    padding: 0.625rem;
  }
  .sidebar-wrapper {
    width: 260px;
  }
  .top-header .navbar .nav-link {
    padding: 0.25rem;
  }
  .top-header .navbar .nav-link img {
    width: 35px;
    height: 35px;
  }
  .filter-container .row.g-3 {
    gap: 0.25rem;
  }
  .filter-container label {
    font-size: 0.8rem;
  }
  .filter-container input,
  .filter-container button {
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
  }
  h4, .h4 {
    font-size: 1rem;
  }
  .logo-name h5 {
    font-size: 0.85rem;
  }
  .table-responsive {
    font-size: 0.75rem;
  }
  .btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
  }
  .badge {
    font-size: 0.65rem;
  }
  .metismenu .menu-title {
    font-size: 0.8rem;
  }
  .metismenu a {
    padding: 0.4rem 0.75rem;
  }
  .row-cols-xl-4 > .col {
    flex: 0 0 100%;
    max-width: 100%;
  }
  .main-wrapper {
    padding-top: 56px;
  }
  .top-header {
    height: 56px;
  }
}

/* Very small screens (under 400px) */
@media only screen and (max-width: 399px) {
  .card-body {
    padding: 0.5rem;
  }
  .main-content {
    padding: 0.25rem;
  }
  .sidebar-wrapper {
    width: 240px;
  }
  .table-responsive table {
    min-width: 400px;
  }
  h4, .h4 {
    font-size: 0.9rem;
  }
  .logo-icon img {
    width: 2rem !important;
  }
}

/* Fixes for print */
@media print {
  .sidebar-wrapper,
  .top-header,
  .page-footer,
  .overlay {
    display: none !important;
  }
  .main-wrapper {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  .main-content {
    padding: 0 !important;
  }
  .card {
    border: none !important;
    box-shadow: none !important;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  input, select, textarea {
    font-size: 16px !important; /* Prevents iOS zoom on focus */
  }
}

/* High-resolution screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .logo-img,
  .card img {
    image-rendering: auto;
  }
}

/* Accessibility: prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
