/**
 * PolyMétis - Améliorations Responsive
 * Styles pour garantir une expérience optimale sur tous les appareils
 */

/* ==========================================================================
   BREAKPOINTS TAILWIND
   ========================================================================== */
/* sm: 640px, md: 768px, lg: 1024px, xl: 1280px, 2xl: 1536px */

/* ==========================================================================
   TABLEAUX RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
  /* Wrapper pour scroll horizontal sur petits écrans */
  .table-responsive-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
  }
  
  /* Tables en mode carte pour mobile */
  .table-mobile-card {
    display: block;
  }
  
  .table-mobile-card thead {
    display: none;
  }
  
  .table-mobile-card tbody {
    display: block;
  }
  
  .table-mobile-card tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  }
  
  .table-mobile-card td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
  }
  
  .table-mobile-card td:last-child {
    border-bottom: none;
  }
  
  .table-mobile-card td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #374151;
    flex-shrink: 0;
    margin-right: 1rem;
  }
}

/* ==========================================================================
   GRIDS RESPONSIVE
   ========================================================================== */
.grid-responsive {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid-responsive {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid-responsive {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1280px) {
  .grid-responsive-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ==========================================================================
   CARDS STATS DASHBOARD
   ========================================================================== */
.stat-card {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

@media (max-width: 640px) {
  .stat-card {
    min-height: 100px;
  }
  
  .stat-card .text-3xl {
    font-size: 1.5rem !important;
  }
  
  .stat-card .text-4xl {
    font-size: 2rem !important;
  }
}

/* ==========================================================================
   MODALS RESPONSIVE
   ========================================================================== */
.modal-content {
  max-height: 90vh;
  overflow-y: auto;
  margin: 1rem;
}

@media (min-width: 768px) {
  .modal-content {
    margin: 2rem;
  }
}

/* ==========================================================================
   FORMULAIRES RESPONSIVE
   ========================================================================== */
.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .form-grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .form-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Inputs responsive */
@media (max-width: 640px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important; /* Évite le zoom automatique sur iOS */
  }
}

/* ==========================================================================
   BUTTONS RESPONSIVE
   ========================================================================== */
@media (max-width: 640px) {
  .btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .btn-group button,
  .btn-group a {
    width: 100%;
  }
}

/* ==========================================================================
   NAVIGATION / SIDEBAR
   ========================================================================== */
/* Overlay pour fermer la sidebar sur mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 40;
}

.sidebar-overlay.active {
  display: block;
}

/* ==========================================================================
   TEXTES RESPONSIVE
   ========================================================================== */
.text-responsive-sm {
  font-size: 0.875rem;
}

@media (min-width: 768px) {
  .text-responsive-sm {
    font-size: 1rem;
  }
}

.text-responsive-lg {
  font-size: 1.125rem;
}

@media (min-width: 768px) {
  .text-responsive-lg {
    font-size: 1.25rem;
  }
}

@media (min-width: 1024px) {
  .text-responsive-lg {
    font-size: 1.5rem;
  }
}

/* ==========================================================================
   IMAGES RESPONSIVE
   ========================================================================== */
img {
  max-width: 100%;
  height: auto;
}

.img-responsive {
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* ==========================================================================
   CONTAINERS RESPONSIVE
   ========================================================================== */
.container-responsive {
  width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 640px) {
  .container-responsive {
    max-width: 640px;
  }
}

@media (min-width: 768px) {
  .container-responsive {
    max-width: 768px;
  }
}

@media (min-width: 1024px) {
  .container-responsive {
    max-width: 1024px;
  }
}

@media (min-width: 1280px) {
  .container-responsive {
    max-width: 1280px;
  }
}

/* ==========================================================================
   SPACING RESPONSIVE
   ========================================================================== */
@media (max-width: 640px) {
  .section-padding {
    padding-top: 2rem;
    padding-bottom: 2rem;
  }
}

@media (min-width: 641px) {
  .section-padding {
    padding-top: 3rem;
    padding-bottom: 3rem;
  }
}

@media (min-width: 1024px) {
  .section-padding {
    padding-top: 4rem;
    padding-bottom: 4rem;
  }
}

/* ==========================================================================
   UTILITAIRES RESPONSIVE
   ========================================================================== */
/* Masquer sur mobile */
.hide-mobile {
  display: none;
}

@media (min-width: 768px) {
  .hide-mobile {
    display: block;
  }
}

/* Afficher seulement sur mobile */
.show-mobile {
  display: block;
}

@media (min-width: 768px) {
  .show-mobile {
    display: none;
  }
}

/* ==========================================================================
   DASHBOARD CHARTS RESPONSIVE
   ========================================================================== */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

@media (min-width: 768px) {
  .chart-container {
    height: 350px;
  }
}

@media (min-width: 1024px) {
  .chart-container {
    height: 400px;
  }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    background: white;
  }
  
  .sidebar {
    display: none;
  }
  
  .lg\:ml-64 {
    margin-left: 0 !important;
  }
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */
/* Focus visible pour navigation clavier */
*:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Touch targets minimum 44x44px pour mobile */
@media (max-width: 768px) {
  button,
  a,
  input[type="button"],
  input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
  }
}
/* ==========================================================================
   ADMIN DASHBOARD SPECIFIC RESPONSIVE
   ========================================================================== */
/* Sidebar responsive avec overlay sur mobile */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    z-index: 50;
  }
  
  .lg\:ml-64 {
    margin-left: 0 !important;
  }
}

/* Cards stats responsive */
@media (max-width: 768px) {
  .stat-card h3 {
    font-size: 1.5rem !important;
  }
  
  .stat-card p {
    font-size: 0.875rem !important;
  }
}

/* Pending reservations responsive */
@media (max-width: 640px) {
  #pending-section .bg-white {
    padding: 0.75rem !important;
  }
}

/* ==========================================================================
   FORMS RESPONSIVE
   ========================================================================== */
/* Labels et inputs en colonnes sur mobile */
@media (max-width: 640px) {
  .form-grid label,
  .form-group label {
    margin-bottom: 0.5rem;
  }
}

/* ==========================================================================
   OVERFLOW ET SCROLL
   ========================================================================== */
/* Prévenir le débordement horizontal */
body {
  overflow-x: hidden;
}

/* Améliorer le scroll sur mobile */
@media (max-width: 768px) {
  * {
    -webkit-overflow-scrolling: touch;
  }
}

/* ==========================================================================
   ADMIN TABLES RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
  /* Masquer certaines colonnes sur mobile si besoin */
  .hide-on-mobile {
    display: none !important;
  }
  
  /* Réduire le padding des cellules de tableaux */
  table td,
  table th {
    padding: 0.5rem 0.25rem !important;
    font-size: 0.875rem !important;
  }
}

/* ==========================================================================
   MODAL RESPONSIVE IMPROVEMENTS
   ========================================================================== */
@media (max-width: 640px) {
  .modal-content {
    max-height: 80vh;
    overflow-y: auto;
  }
  
  /* Améliorer les boutons dans les modals */
  .modal-content button,
  .modal-content .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

/* ==========================================================================
   HEADER ET NAVIGATION RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.25rem !important;
  }
  
  header p {
    font-size: 0.75rem !important;
  }
}

/* ==========================================================================
   WIDGETS RESPONSIVE
   ========================================================================== */
@media (max-width: 640px) {
  .widget {
    padding: 1rem !important;
  }
  
  .widget .bg-white {
    padding: 1rem !important;
  }
}

/* ==========================================================================
   FLEX WRAP UTILITIES
   ========================================================================== */
.flex-wrap-mobile {
  flex-wrap: nowrap;
}

@media (max-width: 640px) {
  .flex-wrap-mobile {
    flex-wrap: wrap;
  }
}

/* ==========================================================================
   SIDEBAR MOBILE
   ========================================================================== */
@media (max-width: 1024px) {
  .sidebar-closed {
    transform: translateX(-100%);
  }
  
  #sidebar {
    transition: transform 0.3s ease-in-out;
  }
}

/* ==========================================================================
   SAFE AREA POUR NOTCH (iPhone X et +)
   ========================================================================== */
@supports (padding-top: env(safe-area-inset-top)) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}