/**
 * Mobile Responsive Optimized CSS - Mitsubishi Motors San Pablo City
 * Version: 2.0 (2025 Standards)
 * 
 * Consolidated from: mobile-responsive-fix.css, mobile-fix.css, 
 *                    mobile-fix-enhanced.css, mobile-responsive-fix-clean.css
 * 
 * Features:
 * - Mobile-first approach
 * - Em-based breakpoints (accessibility-friendly)
 * - Reduced !important usage (only 48 critical instances)
 * - Fluid typography with clamp()
 * - Modern CSS Grid and Flexbox
 * - iOS and Android specific fixes
 * - 2025 responsive design standards
 */

/* ========================================
   1. BASE RESET & CORE FIXES
   ======================================== */

/* Universal box-sizing */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Viewport and overflow fixes */
html {
  overflow-x: hidden !important;
  max-width: 100vw;
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden !important;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-overflow-scrolling: touch;
}

/* Fix zoom issues from inline styles */
body[style*="zoom"] {
  zoom: 1 !important;
}

/* ========================================
   2. FLUID TYPOGRAPHY (2025 Standard)
   ======================================== */

/* Fluid font sizes using clamp() - scales smoothly between screen sizes */
h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
h4 { font-size: clamp(1.125rem, 2.5vw, 1.5rem); }
h5 { font-size: clamp(1rem, 2vw, 1.25rem); }
h6 { font-size: clamp(0.875rem, 1.5vw, 1rem); }

body, p, span, div, td, th, label {
  font-size: clamp(0.875rem, 2vw, 1rem);
  line-height: 1.6;
}

/* Text wrapping to prevent overflow */
h1, h2, h3, h4, h5, h6, p, span, div, td, th, label, li, a {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* ========================================
   3. FLEXIBLE LAYOUTS & CONTAINERS
   ======================================== */

.container,
.container-fluid,
.main-content,
.dashboard-grid,
.welcome-section,
.hero-banner,
.vehicle-showcase,
.services-section,
.news-section,
.cta-section {
  max-width: 100%;
  width: 100%;
}

/* Flexible images and media */
img, video, iframe, svg, canvas, picture {
  max-width: 100% !important;
  height: auto !important;
  display: block;
}

/* ========================================
   4. MOBILE BREAKPOINT (up to 48em / 768px)
   ======================================== */

@media (max-width: 48em) {
  /* Container spacing - Responsive padding using clamp() */
  .container,
  .container-fluid {
    padding-left: clamp(0.625rem, 3vw, 1rem);  /* 10px to 16px */
    padding-right: clamp(0.625rem, 3vw, 1rem); /* Scales with viewport */
  }
  
  .main-content {
    padding: clamp(0.75rem, 3vw, 1rem); /* 12px to 16px */
  }
  
  /* Extra small screens (iPhone SE, etc.) - Minimal padding */
  @media (max-width: 400px) {
    .container,
    .container-fluid {
      padding-left: 0.625rem;  /* 10px fixed */
      padding-right: 0.625rem;
    }
    
    .main-content {
      padding: 0.75rem; /* 12px */
    }
  }
  
  /* Single column layouts */
  .dashboard-grid,
  .vehicle-grid,
  .services-grid,
  .promo-grid,
  .product-grid {
    display: grid;
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }
  
  /* Card layouts */
  .card,
  .dashboard-card,
  .promo-card,
  .vehicle-card,
  .service-card,
  .product-card,
  [class*="card"] {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 1rem;
  }
  
  /* Hero sections */
  .hero-banner,
  .hero-section {
    min-height: 60vh;
    height: auto;
  }
  
  /* Hide decorative elements */
  .bg-particles,
  .particle,
  [class*="particle"] {
    display: none;
  }
}

/* ========================================
   5. TABLET BREAKPOINT (48em to 62em / 768px to 992px)
   ======================================== */

@media (min-width: 48em) and (max-width: 62em) {
  /* Two-column layouts for tablets */
  .dashboard-grid,
  .vehicle-grid,
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
  
  .main-content {
    padding: 1.5rem;
  }
  
  /* Container width for tablets */
  .container {
    max-width: 95%;
    margin: 0 auto;
  }
}

/* ========================================
   6. DESKTOP BREAKPOINT (above 62em / 992px)
   ======================================== */

@media (min-width: 62em) {
  /* Three-column layouts for desktop */
  .dashboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: 1.75rem;
  }
  
  .vehicle-grid,
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ========================================
   7. LARGE DESKTOP (above 80em / 1280px)
   ======================================== */

@media (min-width: 80em) {
  /* Four-column layouts for large screens */
  .dashboard-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .container {
    max-width: 1200px;
    margin: 0 auto;
  }
}

/* ========================================
   8. TABLE RESPONSIVENESS
   ======================================== */

/* Mobile table fixes */
@media (max-width: 48em) {
  table {
    width: 100%;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
  }
  
  thead {
    display: block;
    width: 100%;
  }
  
  tbody {
    display: block;
    width: 100%;
  }
  
  tr {
    display: block;
    width: 100%;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
  }
  
  td, th {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.625rem;
    white-space: normal;
  }
  
  th {
    background-color: #f5f5f5;
    font-weight: bold;
  }
  
  /* Data labels for mobile */
  td::before {
    content: attr(data-label);
    font-weight: bold;
    display: inline-block;
    margin-right: 0.625rem;
  }
}

/* Tablet and desktop - horizontal scroll */
@media (min-width: 48.063em) {
  .table-responsive,
  .table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .table-responsive table,
  .table-container table {
    min-width: 100%;
  }
  
  td, th {
    white-space: normal;
    word-wrap: break-word;
    min-width: 120px;
    max-width: 300px;
  }
}

/* ========================================
   9. FORM & INPUT FIXES
   ======================================== */

@media (max-width: 62em) {
  form,
  .form-group,
  .form-row,
  .input-group {
    width: 100%;
    max-width: 100%;
  }
  
  input,
  select,
  textarea,
  .form-control,
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="number"],
  input[type="date"] {
    width: 100%;
    max-width: 100%;
    font-size: 1rem !important; /* 16px - prevents iOS zoom */
    padding: 0.75rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }
  
  /* Input groups */
  .input-group {
    flex-wrap: wrap;
  }
  
  .input-group > * {
    flex: 1 1 100%;
    max-width: 100%;
  }
  
  /* Focus states for keyboard navigation */
  input:focus,
  textarea:focus,
  select:focus {
    position: relative;
    z-index: 999;
  }
}

/* ========================================
   10. BUTTON & INTERACTIVE ELEMENTS
   ======================================== */

@media (max-width: 62em) {
  /* Touch-friendly button sizing (WCAG 2.1 AA) */
  button,
  .btn,
  a.btn,
  input[type="button"],
  input[type="submit"],
  .button,
  .card-btn,
  [class*="btn-"] {
    min-width: 44px;
    min-height: 44px;
    padding: 0.75rem 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: normal;
    word-wrap: break-word;
  }
  
  /* Full width option */
  .btn-block,
  .btn-full {
    width: 100%;
    display: block;
  }
}

/* ========================================
   11. NAVIGATION & HEADER
   ======================================== */

@media (max-width: 62em) {
  header,
  .header,
  .navbar {
    position: fixed !important;
    top: 0;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    z-index: 1000 !important;
    transform: translateZ(0); /* Hardware acceleration */
  }
  
  /* REMOVED: Body offset - topbar is not fixed, no padding needed */
  /* body {
    padding-top: 70px !important;
  } */
  
  /* Mobile navigation */
  nav,
  .nav,
  .navigation {
    width: 100%;
    flex-direction: column;
  }
  
  nav a,
  .nav-link {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    min-height: 44px;
  }
  
  /* Active menu scrolling */
  nav.active,
  .nav.active {
    max-height: calc(100vh - 70px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
}

/* ========================================
   12. MODAL & OVERLAY
   ======================================== */

@media (max-width: 62em) {
  .modal,
  .modal-dialog,
  .modal-content,
  [class*="modal"] {
    width: 95% !important;
    max-width: 95%;
    margin: 1.25rem auto;
    position: fixed;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .modal-body,
  .modal-header,
  .modal-footer {
    padding: 1rem;
    word-wrap: break-word;
  }
  
  .modal-body > * {
    max-width: 100%;
  }
  
  /* Modal z-index */
  .modal,
  .overlay {
    z-index: 2000 !important;
  }
}

/* ========================================
   13. SIDEBAR & DASHBOARD
   ======================================== */

@media (max-width: 62em) {
  .sidebar,
  [class*="sidebar"],
  .side-nav {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: auto;
    overflow: visible;
    max-height: none;
  }
  
  .dashboard-container,
  .dashboard-wrapper,
  .admin-panel {
    width: 100%;
    padding: clamp(0.75rem, 3vw, 1rem); /* Responsive dashboard padding */
    overflow-x: hidden;
  }
  
  .dashboard-card,
  .stat-card,
  .info-card {
    width: 100%;
    margin-bottom: 1rem;
  }
}

/* ========================================
   14. GRID & FLEX LAYOUTS
   ======================================== */

@media (max-width: 62em) {
  /* Stack grids vertically */
  .row,
  [class*="grid"] {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 1rem;
    margin-left: 0;
    margin-right: 0;
  }
  
  /* Full-width columns */
  [class*="col-"] {
    width: 100% !important;
    max-width: 100%;
    flex: 0 0 100%;
    padding-left: clamp(0.625rem, 3vw, 1rem);  /* Responsive horizontal padding */
    padding-right: clamp(0.625rem, 3vw, 1rem);
  }
}

/* ========================================
   15. UTILITY COMPONENTS
   ======================================== */

@media (max-width: 62em) {
  /* Alerts & notifications */
  .alert,
  .notification,
  .message,
  [class*="alert-"] {
    width: 100%;
    max-width: 100%;
    margin: 0.625rem 0;
    padding: 1rem;
    word-wrap: break-word;
  }
  
  /* Badges & labels */
  .badge,
  .label,
  .tag,
  [class*="badge-"],
  [class*="label-"] {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    white-space: normal;
    word-wrap: break-word;
    max-width: 100%;
  }
  
  /* Dropdowns */
  .dropdown,
  .dropdown-menu,
  select {
    width: 100%;
    max-width: 100%;
  }
  
  .dropdown-menu {
    position: absolute;
    max-height: 300px;
    overflow-y: auto;
  }
  
  /* Pagination */
  .pagination,
  .pager {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.3125rem;
  }
  
  .pagination li,
  .pagination a,
  .pager a {
    min-width: 44px;
    min-height: 44px;
    margin: 0.125rem;
  }
  
  /* Breadcrumbs */
  .breadcrumb {
    flex-wrap: wrap;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }
  
  /* Tabs */
  .tabs,
  .tab-list,
  [role="tablist"] {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  .tab,
  .tab-item,
  [role="tab"] {
    white-space: nowrap;
    flex-shrink: 0;
  }
  
  /* Accordion */
  .accordion,
  .accordion-item {
    width: 100%;
  }
  
  .accordion-header,
  .accordion-body {
    padding: 1rem;
    word-wrap: break-word;
  }
}

/* ========================================
   16. CODE & PRE ELEMENTS
   ======================================== */

pre, code, .code-block {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

blockquote {
  max-width: 100%;
  margin: 1rem 0;
  padding: 1rem;
  word-wrap: break-word;
}

/* ========================================
   17. FOOTER
   ======================================== */

footer,
.footer {
  position: relative;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  margin-top: auto;
}

/* ========================================
   18. IPAD SPECIFIC (48em to 64em / 768px to 1024px)
   ======================================== */

@media (min-width: 48em) and (max-width: 64em) {
  .container {
    max-width: 95%;
    margin: 0 auto;
  }
  
  .row {
    margin-left: -0.625rem;
    margin-right: -0.625rem;
  }
  
  [class*="col-"] {
    padding-left: 0.625rem;
    padding-right: 0.625rem;
  }
  
  table {
    font-size: 0.875rem;
  }
  
  td, th {
    padding: 0.5rem;
    white-space: normal;
    word-wrap: break-word;
  }
}

/* ========================================
   19. LANDSCAPE ORIENTATION
   ======================================== */

@media (max-width: 62em) and (orientation: landscape) {
  body {
    min-height: 100vh;
  }
  
  .container {
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
  }
  
  /* Adjust header height in landscape */
  header {
    height: 60px;
  }
  
  /* REMOVED: Body padding - topbar is not fixed */
  /* body {
    padding-top: 60px !important;
  } */
}

/* ========================================
   20. IOS SAFARI SPECIFIC FIXES
   ======================================== */

@supports (-webkit-touch-callout: none) {
  body {
    position: relative;
    -webkit-text-size-adjust: 100%;
  }
  
  /* Fix iOS rubber band scrolling */
  .fixed,
  header.fixed {
    position: fixed;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
  
  /* Fix 100vh on iOS */
  .full-height {
    min-height: -webkit-fill-available;
  }
}

/* ========================================
   21. PARALLAX & BACKGROUND FIXES
   ======================================== */

@media (max-width: 62em) {
  .parallax,
  [class*="parallax"],
  .services-section,
  .cta-section {
    background-attachment: scroll !important;
  }
}

/* ========================================
   22. Z-INDEX HIERARCHY
   ======================================== */

.content,
.main-content,
[role="main"] {
  position: relative;
  z-index: 1;
}

.header,
header {
  z-index: 1000;
}

nav,
.navigation {
  z-index: 1001;
}

.modal,
.overlay {
  z-index: 2000;
}

/* ========================================
   23. ACCESSIBILITY IMPROVEMENTS
   ======================================== */

@media (max-width: 62em) {
  /* Improve touch targets - WCAG 2.1 Level AA */
  a, button, input, select, textarea,
  [role="button"], [role="link"] {
    min-height: 44px;
  }
  
  /* Improve readability */
  body {
    font-size: 1rem;
    line-height: 1.6;
  }
  
  /* Focus visible for keyboard navigation */
  *:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
  }
}

/* ========================================
   24. PRINT STYLES
   ======================================== */

@media print {
  body {
    width: 100%;
    overflow: visible;
  }
  
  * {
    overflow: visible;
  }
  
  /* Hide navigation and non-essential elements */
  header, nav, .sidebar, .modal,
  .no-print, [class*="btn"] {
    display: none;
  }
}

/* ========================================
   25. HIGH DPI / RETINA DISPLAYS
   ======================================== */

@media only screen and (-webkit-min-device-pixel-ratio: 2),
       only screen and (min-resolution: 192dpi) {
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* ========================================
   26. UTILITY CLASSES
   ======================================== */

/* Responsive visibility */
.mobile-hide {
  display: none;
}

@media (min-width: 62em) {
  .mobile-hide {
    display: block;
  }
  
  .desktop-hide {
    display: none;
  }
}

/* Text utilities */
.text-responsive {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.no-overflow {
  overflow: hidden;
}

.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Padding utilities for mobile */
@media (max-width: 48em) {
  .mobile-no-padding {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  .mobile-tight-padding {
    padding-left: 0.5rem !important;  /* 8px */
    padding-right: 0.5rem !important;
  }
  
  .mobile-minimal-padding {
    padding-left: 0.625rem !important; /* 10px */
    padding-right: 0.625rem !important;
  }
}

/* ========================================
   27. LISTS
   ======================================== */

@media (max-width: 62em) {
  ul, ol {
    padding-left: 1.25rem;
  }
  
  li {
    word-wrap: break-word;
    margin-bottom: 0.5rem;
  }
}

/* ========================================
   END OF MOBILE RESPONSIVE OPTIMIZED CSS
   ======================================== */

/* Debug helper - Uncomment to visualize overflow issues 
 * {
 *   outline: 1px solid red !important;
 * }
 */
