/* ============================================
   Comprehensive Mobile Responsive Styles
   ============================================ */

/* Base responsive utilities */
* {
  box-sizing: border-box;
}

/* Container adjustments */
.container-fluid {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

@media (min-width: 576px) {
  .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Tables - Make scrollable on mobile */
.table-responsive,
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

.table-responsive table,
.table-container table {
  min-width: 600px;
}

@media (max-width: 768px) {
  .table-responsive {
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
  }

  /* Stack table cells on very small screens */
  .table-responsive table {
    font-size: 0.875rem;
  }

  .table-responsive th,
  .table-responsive td {
    padding: 0.5rem 0.25rem;
    white-space: nowrap;
  }
}

/* Cards - Stack on mobile */
.card {
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .card {
    margin-bottom: 1rem;
  }

  .card-body {
    padding: 1rem;
  }

  .card-title {
    font-size: 1rem;
  }

  .card-text {
    font-size: 0.875rem;
  }
}

/* Forms - Stack inputs on mobile */
.form-group,
.mb-3,
.mb-4 {
  margin-bottom: 1rem;
}

@media (max-width: 768px) {

  .form-group,
  .mb-3,
  .mb-4 {
    margin-bottom: 0.75rem;
  }

  .form-control,
  .form-select {
    font-size: 16px;
    /* Prevents zoom on iOS */
  }

  .form-label {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
  }

  .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .btn-group {
    flex-direction: column;
    width: 100%;
  }

  .btn-group .btn {
    margin-bottom: 0.5rem;
  }
}

/* Buttons - Full width on mobile */
@media (max-width: 576px) {
  .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn-group .btn {
    border-radius: 0.25rem !important;
    margin-bottom: 0.5rem;
  }

  .btn-group .btn:last-child {
    margin-bottom: 0;
  }
}

/* Dashboard cards responsive */
@media (max-width: 1200px) {
  .col-xl-4 {
    flex: 0 0 auto;
    width: 50%;
  }
}

@media (max-width: 768px) {

  .col-xl-4,
  .col-lg-3,
  .col-md-6 {
    flex: 0 0 auto;
    width: 100%;
  }

  .dashboard-card {
    margin-bottom: 1rem;
  }

  .card-value {
    font-size: 1.5rem !important;
  }

  .card-icon {
    font-size: 2rem !important;
  }

  .card-title {
    font-size: 0.75rem !important;
  }
}

/* Welcome section responsive */
.welcome-section {
  padding: 1rem !important;
}

@media (max-width: 768px) {
  .welcome-section {
    padding: 1rem !important;
  }

  .welcome-section h3 {
    font-size: 1.25rem;
  }

  .welcome-section p {
    font-size: 0.875rem;
  }

  .welcome-section .d-flex {
    flex-direction: column;
    gap: 1rem;
  }

  .welcome-section .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

/* Content wrapper padding */
.content-wrapper {
  padding: 1rem 0.75rem;
}

@media (min-width: 768px) {
  .content-wrapper {
    padding: 2rem 1.5rem;
  }
}

/* Main panel adjustments */
@media (max-width: 991px) {
  .main-panel {
    margin-left: 0 !important;
    width: 100% !important;
    padding-top: 70px;
  }

  .content-wrapper {
    padding: 1rem 0.75rem;
  }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: rgba(0, 0, 0, 0.6) !important;
  z-index: 1049 !important;
  transition: opacity 0.3s ease !important;
  backdrop-filter: blur(2px) !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Navbar responsive */
@media (max-width: 991px) {
  .navbar-nav {
    gap: 0.5rem !important;
  }

  .navbar-nav .btn {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.875rem;
  }
}

/* Modals responsive */
@media (max-width: 768px) {
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }

  .modal-content {
    border-radius: 0.5rem;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1rem;
  }

  .modal-title {
    font-size: 1.125rem;
  }
}

/* DataTables responsive */
@media (max-width: 768px) {
  .dataTables_wrapper {
    overflow-x: auto;
  }

  .dataTables_length,
  .dataTables_filter {
    margin-bottom: 0.5rem;
  }

  .dataTables_length select,
  .dataTables_filter input {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .dataTables_info,
  .dataTables_paginate {
    font-size: 0.875rem;
    margin-top: 0.5rem;
  }
}

/* Forms - Input groups */
@media (max-width: 576px) {
  .input-group {
    flex-direction: column;
  }

  .input-group .form-control,
  .input-group .form-select,
  .input-group .btn {
    width: 100%;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
  }

  .input-group-text {
    width: 100%;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
  }
}

/* Row and column adjustments */
@media (max-width: 768px) {
  .row {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
  }

  .row>* {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .col-md-6,
  .col-md-4,
  .col-md-3 {
    margin-bottom: 1rem;
  }
}

/* Text responsive */
@media (max-width: 768px) {
  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.25rem;
  }

  h4 {
    font-size: 1.125rem;
  }

  h5 {
    font-size: 1rem;
  }

  h6 {
    font-size: 0.875rem;
  }

  p {
    font-size: 0.875rem;
  }

  small {
    font-size: 0.75rem;
  }
}

/* Badges and labels */
@media (max-width: 576px) {
  .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
}

/* Alerts */
@media (max-width: 768px) {
  .alert {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }
}

/* Pagination */
@media (max-width: 576px) {
  .pagination {
    flex-wrap: wrap;
    justify-content: center;
  }

  .page-link {
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
  }
}

/* Breadcrumbs */
@media (max-width: 768px) {
  .breadcrumb {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
  }
}

/* Tabs */
@media (max-width: 768px) {
  .nav-tabs {
    flex-wrap: wrap;
  }

  .nav-tabs .nav-link {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
  }

  .tab-content {
    padding: 1rem 0;
  }
}

/* Dropdowns */
@media (max-width: 768px) {
  .dropdown-menu {
    width: 100%;
    max-width: calc(100vw - 2rem);
  }
}

/* Print invoice responsive */
@media (max-width: 768px) {
  .invoice-container {
    padding: 0.5rem;
  }

  .invoice-header,
  .invoice-body,
  .invoice-footer {
    padding: 0.75rem;
  }

  .invoice-table {
    font-size: 0.75rem;
  }

  .invoice-table th,
  .invoice-table td {
    padding: 0.25rem;
  }
}

/* Repair form responsive */
@media (max-width: 768px) {
  .repair-form .row {
    margin-left: 0;
    margin-right: 0;
  }

  .repair-form .col-md-6,
  .repair-form .col-md-4 {
    padding-left: 0;
    padding-right: 0;
  }
}

/* Checkout page responsive */
@media (max-width: 768px) {
  .checkout-container {
    flex-direction: column;
  }

  .checkout-items,
  .checkout-summary {
    width: 100%;
    margin-bottom: 1rem;
  }
}

/* Sales management responsive */
@media (max-width: 768px) {
  .sales-filters {
    flex-direction: column;
  }

  .sales-filters .form-group {
    width: 100%;
    margin-bottom: 0.75rem;
  }
}

/* Product grid responsive */
@media (max-width: 1200px) {
  .product-grid .col-xl-3 {
    flex: 0 0 auto;
    width: 50%;
  }
}

@media (max-width: 768px) {

  .product-grid .col-xl-3,
  .product-grid .col-lg-4,
  .product-grid .col-md-6 {
    flex: 0 0 auto;
    width: 100%;
  }
}

/* Utility classes */
.d-mobile-none {
  display: none !important;
}

@media (min-width: 768px) {
  .d-mobile-none {
    display: block !important;
  }
}

.d-mobile-block {
  display: block !important;
}

@media (min-width: 768px) {
  .d-mobile-block {
    display: none !important;
  }
}

/* Fix for iOS input zoom */
@media screen and (max-width: 768px) {

  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="tel"],
  input[type="password"],
  input[type="search"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Focus styles for accessibility */
@media (max-width: 768px) {

  .btn:focus,
  .form-control:focus,
  .form-select:focus {
    outline: 2px solid #64b5f6;
    outline-offset: 2px;
  }
}