/* ===========================================
   GLOBAL COMPREHENSIVE RESPONSIVE DESIGN
   =========================================== */

/* Base universal styles */
* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  overflow-x: hidden;
}

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

/* Container responsive behavior */
.container, .container-fluid {
  width: 100%;
  padding-left: 15px;
  padding-right: 15px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

/* ===========================================
   MOBILE FIRST BREAKPOINTS
   =========================================== */

/* Extra Small devices (phones, less than 576px) */
@media (max-width: 575.98px) {
  .container {
    max-width: 100%;
    padding-left: 10px;
    padding-right: 10px;
  }
  
  /* Typography */
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.2rem; }
  h4 { font-size: 1.1rem; }
  h5 { font-size: 1rem; }
  
  /* Buttons */
  .btn {
    padding: 8px 16px;
    font-size: 14px;
    width: 100%;
    margin-bottom: 10px;
  }
  
  /* Forms */
  .form-control {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 12px;
  }
  
  /* Cards */
  .card {
    margin-bottom: 15px;
    border-radius: 8px;
  }
  
  .card-body {
    padding: 15px;
  }
  
  /* Tables - make scrollable */
  .table-responsive {
    font-size: 14px;
  }
  
  .table th, .table td {
    padding: 8px;
    font-size: 13px;
  }
  
  /* Navigation adjustments */
  .navbar-nav {
    text-align: center;
  }
  
  .navbar-nav .nav-link {
    padding: 10px;
  }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
  .container {
    max-width: 540px;
  }
  
  /* Grid adjustments */
  .row {
    margin-left: -10px;
    margin-right: -10px;
  }
  
  .col, .col-sm-6, .col-md-4, .col-lg-3 {
    padding-left: 10px;
    padding-right: 10px;
  }
  
  /* Buttons */
  .btn {
    padding: 10px 20px;
    font-size: 15px;
  }
  
  /* Typography */
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.6rem; }
  h3 { font-size: 1.4rem; }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
  .container {
    max-width: 720px;
  }
  
  /* Typography */
  h1 { font-size: 2rem; }
  h2 { font-size: 1.8rem; }
  h3 { font-size: 1.6rem; }
  
  /* Buttons */
  .btn {
    padding: 12px 24px;
    font-size: 16px;
    width: auto;
    margin-bottom: 0;
  }
  
  /* Tables */
  .table th, .table td {
    padding: 12px;
    font-size: 15px;
  }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .container {
    max-width: 960px;
  }
  
  /* Typography */
  h1 { font-size: 2.25rem; }
  h2 { font-size: 2rem; }
  h3 { font-size: 1.75rem; }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
  .container {
    max-width: 1140px;
  }
  
  /* Typography */
  h1 { font-size: 2.5rem; }
  h2 { font-size: 2.25rem; }
  h3 { font-size: 2rem; }
}

/* ===========================================
   COMPONENT SPECIFIC RESPONSIVE RULES
   =========================================== */

/* Modal responsiveness */
@media (max-width: 767.98px) {
  .modal-dialog {
    margin: 10px;
    max-width: calc(100% - 20px);
  }
  
  .modal-content {
    border-radius: 8px;
  }
  
  .modal-header, .modal-footer {
    padding: 15px;
  }
  
  .modal-body {
    padding: 20px 15px;
  }
}

/* Dropdown responsiveness */
@media (max-width: 767.98px) {
  .dropdown-menu {
    width: 100%;
    box-shadow: none;
    border: none;
    border-top: 1px solid #dee2e6;
  }
}

/* Alert responsiveness */
@media (max-width: 575.98px) {
  .alert {
    padding: 12px;
    font-size: 14px;
    border-radius: 6px;
  }
  
  .alert-heading {
    font-size: 16px;
  }
}

/* Badge responsiveness */
@media (max-width: 575.98px) {
  .badge {
    font-size: 11px;
    padding: 4px 8px;
  }
}

/* Pagination responsiveness */
@media (max-width: 575.98px) {
  .pagination {
    font-size: 14px;
  }
  
  .page-link {
    padding: 8px 12px;
  }
}

/* Progress bar responsiveness */
@media (max-width: 575.98px) {
  .progress {
    height: 16px;
  }
  
  .progress-bar {
    font-size: 12px;
    line-height: 16px;
  }
}

/* List group responsiveness */
@media (max-width: 575.98px) {
  .list-group-item {
    padding: 12px 15px;
    font-size: 14px;
  }
}

/* ===========================================
   UTILITY CLASSES FOR RESPONSIVE DESIGN
   =========================================== */

/* Hide/Show elements based on screen size */
@media (max-width: 575.98px) {
  .d-xs-none { display: none !important; }
  .d-xs-block { display: block !important; }
  .d-xs-inline { display: inline !important; }
  .d-xs-inline-block { display: inline-block !important; }
  .d-xs-flex { display: flex !important; }
}

@media (min-width: 576px) and (max-width: 767.98px) {
  .d-sm-none { display: none !important; }
  .d-sm-block { display: block !important; }
  .d-sm-inline { display: inline !important; }
  .d-sm-inline-block { display: inline-block !important; }
  .d-sm-flex { display: flex !important; }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .d-md-none { display: none !important; }
  .d-md-block { display: block !important; }
  .d-md-inline { display: inline !important; }
  .d-md-inline-block { display: inline-block !important; }
  .d-md-flex { display: flex !important; }
}

/* Spacing utilities for mobile */
@media (max-width: 575.98px) {
  .p-xs-0 { padding: 0 !important; }
  .p-xs-1 { padding: 0.25rem !important; }
  .p-xs-2 { padding: 0.5rem !important; }
  .p-xs-3 { padding: 1rem !important; }
  
  .m-xs-0 { margin: 0 !important; }
  .m-xs-1 { margin: 0.25rem !important; }
  .m-xs-2 { margin: 0.5rem !important; }
  .m-xs-3 { margin: 1rem !important; }
  
  .mb-xs-0 { margin-bottom: 0 !important; }
  .mb-xs-1 { margin-bottom: 0.25rem !important; }
  .mb-xs-2 { margin-bottom: 0.5rem !important; }
  .mb-xs-3 { margin-bottom: 1rem !important; }
}

/* Text utilities for mobile */
@media (max-width: 575.98px) {
  .text-xs-center { text-align: center !important; }
  .text-xs-left { text-align: left !important; }
  .text-xs-right { text-align: right !important; }
}

/* ===========================================
   ACCESSIBILITY AND PERFORMANCE
   =========================================== */

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

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn {
    border-width: 2px;
  }
  
  .card {
    border-width: 2px;
  }
  
  .alert {
    border-width: 2px;
  }
}

/* Dark theme media query support */
@media (prefers-color-scheme: dark) {
  body:not(.light-theme) {
    background-color: #1a1a1a;
    color: #ffffff;
  }
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }
  
  .container {
    max-width: none !important;
  }
  
  .btn {
    border: 1px solid #000;
    background: transparent;
    color: #000;
  }
  
  .card {
    border: 1px solid #000;
    page-break-inside: avoid;
  }
}

/* ===========================================
   SPECIFIC FIXES FOR OVERFLOW ISSUES
   =========================================== */

/* Ensure no horizontal overflow */
.row {
  margin-left: 0;
  margin-right: 0;
}

.col, [class*="col-"] {
  padding-left: 8px;
  padding-right: 8px;
}

@media (max-width: 575.98px) {
  .col, [class*="col-"] {
    padding-left: 5px;
    padding-right: 5px;
  }
}

/* Image responsiveness */
img {
  max-width: 100%;
  height: auto;
}

/* Video responsiveness */
video {
  max-width: 100%;
  height: auto;
}

/* Table responsiveness */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Ensure inputs don't overflow */
.form-control, .form-select {
  max-width: 100%;
  box-sizing: border-box;
}

/* Fix for floating elements */
@media (max-width: 767.98px) {
  .float-left, .float-right {
    float: none !important;
  }
}

/* === Product page responsive fixes === */
@media (max-width: 991.98px) {
	.product-media #mainMediaDesktop,
	.gallery-mobile .gallery-viewport,
	.gallery-mobile .gallery-track img,
	.gallery-mobile .gallery-track video {
		width: 100%;
		height: auto;
		max-height: 60vh;
		object-fit: contain;
	}
	.product-details h1 { font-size: 18px; line-height: 1.25; }
	.product-details p.description { font-size: 14px; line-height: 1.5; }
}
@media (max-width: 575.98px) {
	.product-details h1 { font-size: 16px; }
	.product-details p.description { font-size: 13px; }
}

/* Horizontal scroller for related/random products containers if present */
.related-products, .random-products {
	overflow-x: auto;
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: 70%;
	gap: 12px;
}
@media (min-width: 576px) {
	.related-products, .random-products { grid-auto-columns: 45%; }
}
@media (min-width: 768px) {
	.related-products, .random-products { grid-auto-columns: 30%; }
}

/* === Footer news ticker mobile refinements === */
@media (max-width: 575.98px) {
	.news-ticker-container { padding: 8px 0; }
	.news-ticker-title { font-size: 12px; }
	.news-ticker .news-title { font-size: 13px; line-height: 1.3; }
	.news-ticker .news-content { font-size: 12px; line-height: 1.4; }
	.news-item { min-width: 82%; }
}