/* Responsive Design Enhancements */

/* Mobile First - Base styles for mobile */
@media (max-width: 767px) {
  /* Auth page mobile padding */
  .auth-page {
    padding: 1.5rem 1rem;
  }

  /* Dashboard hero scaling */
  .dashboard-hero {
    padding: 1.25rem;
  }

  .dashboard-hero h1 {
    font-size: 1.5rem !important;
  }

  /* Typography adjustments */
  h1 {
    font-size: 24px !important;
  }

  h2 {
    font-size: 20px !important;
  }

  h3 {
    font-size: 18px !important;
  }

  /* Padding adjustments */
  main {
    padding: 16px !important;
  }

  .card {
    padding: 16px !important;
  }

  /* Grid adjustments */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr !important;
  }

  /* Form adjustments */
  md-outlined-text-field,
  md-filled-text-field {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Table responsiveness */
  table {
    font-size: 12px;
  }

  table th,
  table td {
    padding: 8px !important;
  }

  /* Hide less important table columns on mobile */
  table th:nth-child(1),
  table td:nth-child(1) {
    display: none; /* Hide ID column */
  }

  /* Button adjustments */
  md-filled-button,
  md-outlined-button {
    width: 100%;
    margin-bottom: 8px;
  }

  /* Stats cards */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Map adjustments */
  #mapPickerContainer,
  .map-container {
    height: 300px !important;
  }

  /* Modal adjustments */
  .modal-content {
    width: 95% !important;
    max-width: none !important;
  }

  /* Navigation adjustments */
  .desktop-nav {
    display: none !important;
  }

  /* Job/Request cards */
  .job-card,
  .request-card {
    margin-bottom: 12px;
  }

  /* Search and filter */
  .filter-chips {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1024px) {
  main {
    padding: 20px !important;
  }

  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Stats cards - 2 columns on tablet */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Desktop */
@media (min-width: 1025px) {
  /* Optimal desktop spacing */
  main {
    padding: 24px !important;
  }

  /* Show desktop navigation */
  .mobile-only {
    display: none !important;
  }
}

/* Touch-friendly targets */
@media (hover: none) and (pointer: coarse) {
  /* Increase tap targets for touch devices */
  md-filled-button,
  md-outlined-button,
  md-text-button,
  md-icon-button {
    min-height: 48px;
    min-width: 48px;
  }

  md-filter-chip,
  md-assist-chip {
    min-height: 40px;
    padding: 8px 16px;
  }
}

/* Landscape mobile */
@media (max-width: 767px) and (orientation: landscape) {
  #mapPickerContainer,
  .map-container {
    height: 250px !important;
  }
}

/* Print styles */
@media print {
  .no-print,
  md-filled-button,
  md-outlined-button,
  nav,
  header {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  .card {
    page-break-inside: avoid;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
}

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

/* Dark mode support (optional - can be enhanced) */
@media (prefers-color-scheme: dark) {
  :root {
    /* Already defined in theme.css */
  }

  /* Additional dark mode adjustments if needed */
  iframe {
    filter: invert(0.9) hue-rotate(180deg);
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .card {
    border: 2px solid var(--md-sys-color-outline) !important;
  }

  md-filled-button,
  md-outlined-button {
    border-width: 2px !important;
  }
}

/* Loading animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* Skeleton loading state */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--md-sys-color-surface-variant) 25%,
    var(--md-sys-color-surface-container) 50%,
    var(--md-sys-color-surface-variant) 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Focus visible (accessibility) */
*:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }

  header {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}
