/* ==========================================================================
   Cross-Device Compatibility CSS - Maison du Croissant
   Enhanced responsive design for all devices
   ========================================================================== */

/* ===== RESET & BASE STYLES ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  /* Prevent horizontal scroll on mobile */
  overflow-x: hidden;
  /* Better font size scaling */
  font-size: 16px;
}

body {
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #fff;
  /* Prevent horizontal scroll */
  overflow-x: hidden;
  /* Improve text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Better touch scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}

/* ===== RESPONSIVE IMAGES ===== */
img {
  max-width: 100%;
  height: auto;
  display: block;
  /* Prevent image distortion */
  object-fit: cover;
}

/* ===== CONTAINER SYSTEM ===== */
.container-fluid {
  padding-left: 15px;
  padding-right: 15px;
  /* Prevent overflow on mobile */
  overflow-x: hidden;
}

/* Enhanced container with better responsive padding */
.container {
  width: 100%;
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
  /* Prevent overflow */
  overflow-x: hidden;
}

/* ===== RESPONSIVE TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

p {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ===== RESPONSIVE BUTTONS ===== */
.btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  transition: all 0.3s ease;
  /* Prevent text selection */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.btn:focus {
  box-shadow: 0 0 0 0.2rem rgba(212, 175, 55, 0.25);
}

/* ===== RESPONSIVE NAVIGATION ===== */
.navbar {
  /* Ensure navbar doesn't overflow */
  overflow-x: hidden;
}

.navbar-brand {
  /* Prevent brand text from wrapping */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.navbar-nav {
  /* Better spacing on mobile */
  margin: 0;
}

.nav-link {
  /* Better touch targets */
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
}

/* ===== RESPONSIVE CARDS ===== */
.card {
  /* Prevent card overflow */
  overflow: hidden;
  word-wrap: break-word;
  /* Better shadow on mobile */
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.card-img-top {
  width: 100%;
  height: 200px;
  object-fit: cover;
  /* Prevent image stretching */
}

.card-body {
  padding: 1.25rem;
  /* Prevent content overflow */
  overflow-wrap: break-word;
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  /* Prevent title overflow */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-text {
  /* Prevent text overflow */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* ===== RESPONSIVE FORMS ===== */
.form-control {
  /* Better touch targets */
  min-height: 44px;
  font-size: 16px; /* Prevent zoom on iOS */
  border-radius: 0.375rem;
  /* Better focus styles */
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
  box-shadow: 0 0 0 0.2rem rgba(212, 175, 55, 0.25);
  border-color: #d4af37;
}

/* ===== RESPONSIVE TABLES ===== */
.table-responsive {
  /* Better table scrolling */
  -webkit-overflow-scrolling: touch;
  overflow-x: auto;
}

.table {
  /* Prevent table overflow */
  min-width: 100%;
  margin-bottom: 0;
}

/* ===== RESPONSIVE MODALS ===== */
.modal-dialog {
  /* Better modal positioning */
  margin: 0.5rem;
  /* Ensure modal doesn't overflow */
  max-width: calc(100vw - 1rem);
}

.modal-content {
  /* Better modal appearance */
  border: none;
  border-radius: 0.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
  /* Better header styling */
  border-bottom: 1px solid #dee2e6;
  padding: 1rem 1.5rem;
}

.modal-body {
  /* Better body styling */
  padding: 1.5rem;
  /* Prevent content overflow */
  overflow-wrap: break-word;
}

.modal-footer {
  /* Better footer styling */
  border-top: 1px solid #dee2e6;
  padding: 1rem 1.5rem;
  /* Stack buttons on mobile */
  flex-wrap: wrap;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Extra Small Devices (Portrait Phones) - Less than 576px */
@media (max-width: 575.98px) {
  html {
    font-size: 14px;
  }
  
  .container {
    max-width: 100%;
    padding-left: 10px;
    padding-right: 10px;
  }
  
  /* Typography adjustments */
  h1 { font-size: 1.75rem !important; line-height: 1.2; }
  h2 { font-size: 1.5rem !important; line-height: 1.3; }
  h3 { font-size: 1.25rem !important; line-height: 1.3; }
  h4 { font-size: 1.1rem !important; line-height: 1.4; }
  h5 { font-size: 1rem !important; line-height: 1.4; }
  h6 { font-size: 0.9rem !important; line-height: 1.4; }
  
  /* Button adjustments */
  .btn {
    font-size: 0.875rem;
    padding: 0.75rem 1.5rem;
    width: 100%;
    margin-bottom: 0.5rem;
    /* Better touch targets */
    min-height: 48px;
  }
  
  .btn-group .btn {
    width: auto;
  }
  
  /* Navigation adjustments */
  .navbar-brand {
    font-size: 1.1rem;
    max-width: 150px;
  }
  
  .navbar-nav .nav-link {
    padding: 0.75rem 0.5rem;
    text-align: center;
  }
  
  /* Card adjustments */
  .card {
    margin-bottom: 1rem;
    border-radius: 0.5rem;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  .card-img-top {
    height: 180px;
  }
  
  /* Form adjustments */
  .form-control {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 0.75rem 0.75rem;
  }
  
  /* Modal adjustments */
  .modal-dialog {
    margin: 0.25rem;
    max-width: calc(100vw - 0.5rem);
  }
  
  .modal-content {
    border-radius: 0.375rem;
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1rem;
  }
  
  /* Table adjustments */
  .table {
    font-size: 0.875rem;
  }
  
  /* Grid adjustments */
  .row {
    margin-left: -5px;
    margin-right: -5px;
  }
  
  .col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6,
  .col-7, .col-8, .col-9, .col-10, .col-11, .col-12,
  .col-auto, .col-sm, .col-sm-1, .col-sm-2, .col-sm-3,
  .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8,
  .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-auto {
    padding-left: 5px;
    padding-right: 5px;
  }
  
  /* Utility classes for mobile */
  .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; }
  .d-xs-inline-flex { display: inline-flex !important; }
  
  /* Text utilities */
  .text-xs-left { text-align: left !important; }
  .text-xs-center { text-align: center !important; }
  .text-xs-right { text-align: right !important; }
}

/* Small Devices (Landscape Phones) - 576px and up */
@media (min-width: 576px) and (max-width: 767.98px) {
  html {
    font-size: 15px;
  }
  
  .container {
    max-width: 540px;
  }
  
  .btn {
    font-size: 0.9rem;
    padding: 0.75rem 1.25rem;
    min-height: 44px;
  }
  
  .card-img-top {
    height: 200px;
  }
  
  .navbar-brand {
    max-width: 180px;
  }
  
  /* Grid adjustments */
  .row {
    margin-left: -7.5px;
    margin-right: -7.5px;
  }
  
  .col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6,
  .col-7, .col-8, .col-9, .col-10, .col-11, .col-12,
  .col-auto, .col-sm, .col-sm-1, .col-sm-2, .col-sm-3,
  .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8,
  .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-auto {
    padding-left: 7.5px;
    padding-right: 7.5px;
  }
}

/* Medium Devices (Tablets) - 768px and up */
@media (min-width: 768px) and (max-width: 991.98px) {
  .container {
    max-width: 720px;
  }
  
  .btn {
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
    min-height: 42px;
  }
  
  .card-img-top {
    height: 220px;
  }
  
  .navbar-brand {
    max-width: 220px;
  }
}

/* Large Devices (Desktops) - 992px and up */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .container {
    max-width: 960px;
  }
  
  .card-img-top {
    height: 240px;
  }
  
  .navbar-brand {
    max-width: 250px;
  }
}

/* Extra Large Devices (Large Desktops) - 1200px and up */
@media (min-width: 1200px) and (max-width: 1399.98px) {
  .container {
    max-width: 1140px;
  }
  
  .card-img-top {
    height: 260px;
  }
  
  .navbar-brand {
    max-width: 300px;
  }
}

/* XXL Devices (Larger Desktops) - 1400px and up */
@media (min-width: 1400px) {
  .container {
    max-width: 1320px;
  }
  
  .card-img-top {
    height: 280px;
  }
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {
  /* Touch device specific styles */
  .btn:hover {
    /* Remove hover effects on touch devices */
    transform: none;
    box-shadow: none;
  }
  
  .card:hover {
    transform: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  }
  
  /* Better touch targets */
  .btn,
  .nav-link,
  .form-control,
  .dropdown-item {
    min-height: 44px;
  }
  
  /* Remove hover effects that don't work on touch */
  .btn:hover,
  .nav-link:hover,
  .dropdown-item:hover {
    background-color: inherit;
    color: inherit;
  }
}

/* ===== LANDSCAPE ORIENTATION ===== */
@media (orientation: landscape) and (max-height: 568px) {
  /* Landscape phone adjustments */
  .modal-dialog {
    margin: 0.25rem;
  }
  
  .navbar {
    min-height: 50px;
  }
  
  .navbar-brand {
    font-size: 1rem;
  }
  
  .nav-link {
    padding: 0.5rem 0.75rem;
  }
}

/* ===== HIGH DPI DISPLAYS ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* High DPI optimizations */
  .card {
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
  }
  
  .btn {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .navbar,
  .footer,
  .btn,
  .modal,
  .d-print-none {
    display: none !important;
  }
  
  .container {
    max-width: none !important;
    padding: 0 !important;
  }
  
  .card {
    border: 1px solid #dee2e6 !important;
    box-shadow: none !important;
  }
  
  body {
    color: #000 !important;
    background: #fff !important;
  }
  
  h1, h2, h3, h4, h5, h6 {
    color: #000 !important;
  }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
/* Focus styles for keyboard navigation */
.btn:focus,
.nav-link:focus,
.form-control:focus,
.dropdown-item:focus {
  outline: 2px solid #d4af37;
  outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== BROWSER SPECIFIC FIXES ===== */
/* iOS Safari fixes */
@supports (-webkit-overflow-scrolling: touch) {
  body {
    -webkit-overflow-scrolling: touch;
  }
  
  .modal-body {
    -webkit-overflow-scrolling: touch;
  }
}

/* Edge/IE fixes */
@supports (-ms-ime-align: auto) {
  .card {
    display: block;
  }
  
  .btn {
    display: inline-block;
  }
}

/* Firefox fixes */
@-moz-document url-prefix() {
  .form-control {
    padding: 0.75rem 0.75rem;
  }
}

/* ===== CUSTOM UTILITY CLASSES ===== */
.overflow-hidden {
  overflow: hidden !important;
}

.overflow-x-hidden {
  overflow-x: hidden !important;
}

.overflow-y-hidden {
  overflow-y: hidden !important;
}

.word-break {
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
}

.text-truncate {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.no-select {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
}

.touch-action-none {
  touch-action: none !important;
}

.touch-action-manipulation {
  touch-action: manipulation !important;
}

/* ===== LOADING STATES ===== */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== FINAL OVERRIDES ===== */
/* Ensure no horizontal scroll anywhere */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

.container,
.container-fluid,
.row {
  max-width: 100%;
  overflow-x: hidden;
}

/* Ensure all images are responsive */
img,
picture,
video,
canvas,
svg {
  max-width: 100%;
  height: auto;
}

/* Ensure text doesn't break layout */
p, h1, h2, h3, h4, h5, h6, span, div {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Better link styling */
a {
  color: #d4af37;
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover {
  color: #b8941f;
  text-decoration: underline;
}

/* Ensure forms work well on all devices */
input, textarea, select {
  max-width: 100%;
  box-sizing: border-box;
}

/* Better table responsiveness */
table {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  display: block;
  white-space: nowrap;
}

table thead,
table tbody,
table tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

/* ===== END OF CROSS-DEVICE COMPATIBILITY ===== */
