/* Responsive Utilities CSS */
/* Common responsive patterns and utilities for the web application */

:root {
  /* Responsive breakpoints */
  --breakpoint-xs: 360px;
  --breakpoint-sm: 480px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1200px;
  --breakpoint-xxl: 1400px;
  
  /* Fluid spacing scale */
  --fluid-spacing-xs: clamp(0.25rem, 1vw, 0.5rem);
  --fluid-spacing-sm: clamp(0.5rem, 2vw, 1rem);
  --fluid-spacing-md: clamp(1rem, 3vw, 1.5rem);
  --fluid-spacing-lg: clamp(1.5rem, 4vw, 2rem);
  --fluid-spacing-xl: clamp(2rem, 5vw, 3rem);
  --fluid-spacing-xxl: clamp(3rem, 6vw, 4rem);
  
  /* Fluid typography scale */
  --fluid-text-xs: clamp(0.75rem, 1.5vw, 0.875rem);
  --fluid-text-sm: clamp(0.875rem, 2vw, 1rem);
  --fluid-text-base: clamp(1rem, 2.5vw, 1.125rem);
  --fluid-text-lg: clamp(1.125rem, 3vw, 1.25rem);
  --fluid-text-xl: clamp(1.25rem, 3.5vw, 1.5rem);
  --fluid-text-2xl: clamp(1.5rem, 4vw, 2rem);
  --fluid-text-3xl: clamp(2rem, 5vw, 2.5rem);
  --fluid-text-4xl: clamp(2.5rem, 6vw, 3rem);
}

/* Container System */
.container-xs { max-width: 480px; margin: 0 auto; padding: 0 var(--fluid-spacing-sm); }
.container-sm { max-width: 640px; margin: 0 auto; padding: 0 var(--fluid-spacing-sm); }
.container-md { max-width: 768px; margin: 0 auto; padding: 0 var(--fluid-spacing-md); }
.container-lg { max-width: 1024px; margin: 0 auto; padding: 0 var(--fluid-spacing-md); }
.container-xl { max-width: 1200px; margin: 0 auto; padding: 0 var(--fluid-spacing-lg); }
.container-xxl { max-width: 1400px; margin: 0 auto; padding: 0 var(--fluid-spacing-lg); }
.container-full { width: 100%; padding: 0 var(--fluid-spacing-md); }

/* Responsive Grid System */
.grid-responsive {
  display: grid;
  gap: var(--fluid-spacing-md);
  grid-template-columns: 1fr;
}

.grid-responsive-2 {
  display: grid;
  gap: var(--fluid-spacing-md);
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-responsive-3 {
  display: grid;
  gap: var(--fluid-spacing-md);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid-responsive-4 {
  display: grid;
  gap: var(--fluid-spacing-md);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* Responsive Flexbox Utilities */
.flex-responsive {
  display: flex;
  flex-wrap: wrap;
  gap: var(--fluid-spacing-md);
}

.flex-responsive > * {
  flex: 1 1 250px;
}

.flex-stack-mobile {
  display: flex;
  gap: var(--fluid-spacing-md);
}

@media (max-width: 768px) {
  .flex-stack-mobile {
    flex-direction: column;
  }
}

/* Responsive Typography */
.text-responsive-xs { font-size: var(--fluid-text-xs); }
.text-responsive-sm { font-size: var(--fluid-text-sm); }
.text-responsive-base { font-size: var(--fluid-text-base); }
.text-responsive-lg { font-size: var(--fluid-text-lg); }
.text-responsive-xl { font-size: var(--fluid-text-xl); }
.text-responsive-2xl { font-size: var(--fluid-text-2xl); }
.text-responsive-3xl { font-size: var(--fluid-text-3xl); }
.text-responsive-4xl { font-size: var(--fluid-text-4xl); }

/* Responsive Spacing */
.p-responsive { padding: var(--fluid-spacing-md); }
.px-responsive { padding-left: var(--fluid-spacing-md); padding-right: var(--fluid-spacing-md); }
.py-responsive { padding-top: var(--fluid-spacing-md); padding-bottom: var(--fluid-spacing-md); }
.m-responsive { margin: var(--fluid-spacing-md); }
.mx-responsive { margin-left: var(--fluid-spacing-md); margin-right: var(--fluid-spacing-md); }
.my-responsive { margin-top: var(--fluid-spacing-md); margin-bottom: var(--fluid-spacing-md); }

/* Responsive Images and Media */
.img-responsive {
  max-width: 100%;
  height: auto;
  display: block;
}

.img-fluid {
  width: 100%;
  height: auto;
  object-fit: cover;
}

.video-responsive {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  overflow: hidden;
}

.video-responsive iframe,
.video-responsive video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Responsive Tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--fluid-spacing-md);
}

.table-responsive table {
  min-width: 600px;
  width: 100%;
  border-collapse: collapse;
}

.table-responsive th,
.table-responsive td {
  padding: var(--fluid-spacing-sm);
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .table-responsive th,
  .table-responsive td {
    padding: var(--fluid-spacing-xs);
    font-size: var(--fluid-text-sm);
  }
}

/* Responsive Forms */
.form-responsive {
  display: flex;
  flex-direction: column;
  gap: var(--fluid-spacing-md);
}

.form-row-responsive {
  display: flex;
  gap: var(--fluid-spacing-md);
  flex-wrap: wrap;
}

.form-row-responsive > * {
  flex: 1;
  min-width: 200px;
}

@media (max-width: 768px) {
  .form-row-responsive {
    flex-direction: column;
  }
  
  .form-row-responsive > * {
    min-width: 100%;
  }
}

.input-responsive {
  width: 100%;
  padding: var(--fluid-spacing-sm);
  border: 1px solid #ccc;
  border-radius: 0.375rem;
  font-size: var(--fluid-text-base);
  min-height: 44px; /* Touch-friendly */
}

.button-responsive {
  padding: var(--fluid-spacing-sm) var(--fluid-spacing-md);
  border: none;
  border-radius: 0.375rem;
  font-size: var(--fluid-text-base);
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: all 0.2s ease;
}

/* Responsive Cards */
.card-responsive {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: var(--fluid-spacing-md);
  margin-bottom: var(--fluid-spacing-md);
}

.card-grid-responsive {
  display: grid;
  gap: var(--fluid-spacing-md);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Responsive Navigation */
.nav-responsive {
  display: flex;
  flex-wrap: wrap;
  gap: var(--fluid-spacing-sm);
  align-items: center;
}

.nav-responsive a {
  padding: var(--fluid-spacing-sm) var(--fluid-spacing-md);
  text-decoration: none;
  border-radius: 0.375rem;
  transition: background-color 0.2s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
}

@media (max-width: 768px) {
  .nav-responsive {
    flex-direction: column;
    align-items: stretch;
  }
  
  .nav-responsive a {
    text-align: center;
    justify-content: center;
  }
}

/* Responsive Visibility Utilities */
/* Hide on mobile */
@media (max-width: 767px) {
  .d-none-mobile { display: none !important; }
}

/* Hide on tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  .d-none-tablet { display: none !important; }
}

/* Hide on desktop */
@media (min-width: 1024px) {
  .d-none-desktop { display: none !important; }
}

/* Show only on mobile */
@media (min-width: 768px) {
  .d-mobile-only { display: none !important; }
}

/* Show only on tablet and up */
@media (max-width: 767px) {
  .d-tablet-up { display: none !important; }
}

/* Show only on desktop */
@media (max-width: 1023px) {
  .d-desktop-only { display: none !important; }
}

/* Responsive Text Alignment */
.text-center-mobile {
  text-align: left;
}

@media (max-width: 768px) {
  .text-center-mobile {
    text-align: center;
  }
}

.text-left-mobile {
  text-align: center;
}

@media (max-width: 768px) {
  .text-left-mobile {
    text-align: left;
  }
}

/* Responsive Aspect Ratios */
.aspect-ratio-16-9 {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%;
  overflow: hidden;
}

.aspect-ratio-4-3 {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 75%;
  overflow: hidden;
}

.aspect-ratio-1-1 {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 100%;
  overflow: hidden;
}

.aspect-ratio-16-9 > *,
.aspect-ratio-4-3 > *,
.aspect-ratio-1-1 > * {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Responsive Overflow Utilities */
.overflow-responsive {
  overflow: hidden;
}

@media (max-width: 768px) {
  .overflow-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Touch-friendly Interactive Elements */
.touch-target {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Responsive Modal/Dialog */
.modal-responsive {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90vw;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  background: white;
  border-radius: 0.75rem;
  padding: var(--fluid-spacing-lg);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

@media (max-width: 480px) {
  .modal-responsive {
    width: 95vw;
    padding: var(--fluid-spacing-md);
    border-radius: 0.5rem;
  }
}

/* Responsive Loading States */
.skeleton-responsive {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 0.375rem;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Responsive Print Styles */
@media print {
  .no-print { display: none !important; }
  
  .print-break-before { page-break-before: always; }
  .print-break-after { page-break-after: always; }
  .print-break-inside-avoid { page-break-inside: avoid; }
  
  .container-xs,
  .container-sm,
  .container-md,
  .container-lg,
  .container-xl,
  .container-xxl,
  .container-full {
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .card-responsive {
    border: 2px solid #000;
  }
  
  .button-responsive {
    border: 2px solid #000;
  }
  
  .input-responsive {
    border: 2px solid #000;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .skeleton-responsive {
    animation: none;
  }
  
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Focus Management */
.focus-trap {
  outline: 2px solid #1877f2;
  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;
}

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}
