/* ============================================
   MOBILE RESPONSIVENESS ENHANCEMENTS
   Modern Tailwind-Compatible Styles
   ============================================ */

/* Base mobile optimizations */
@media (max-width: 768px) {
  /* Touch-friendly buttons - minimum 44x44px touch target */
  button,
  a.button,
  input[type="submit"],
  input[type="button"] {
    min-height: 48px;
    min-width: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Form inputs - prevent zoom on iOS */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Safe area for notched devices */
  .safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .safe-area-top {
    padding-top: env(safe-area-inset-top);
  }

  /* Responsive tables */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Hide less important columns on mobile */
  .hide-mobile {
    display: none !important;
  }

  /* Full width buttons on mobile */
  .mobile-full-width {
    width: 100% !important;
  }

  /* Better tap targets */
  a, button {
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.1);
  }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
  /* Optimized spacing for tablets */
  .tablet-spacing {
    padding: 1.5rem;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  button,
  a,
  input,
  select {
    min-height: 48px;
  }

  /* Add active state for touch feedback */
  button:active,
  a:active {
    transform: scale(0.97);
    opacity: 0.9;
  }

  /* Improve scrolling */
  * {
    -webkit-overflow-scrolling: touch;
  }

  /* Disable hover effects on touch devices */
  @media (hover: none) {
    *:hover {
      transition: none;
    }
  }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
  /* Optimize for landscape viewing */
  .landscape-compact {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
  }
}

/* Small mobile devices */
@media (max-width: 375px) {
  /* Extra compact for small screens */
  .text-2xl {
    font-size: 1.25rem !important;
  }

  .text-xl {
    font-size: 1.125rem !important;
  }
}

/* Accessibility - high contrast mode */
@media (prefers-contrast: high) {
  button {
    border: 2px solid currentColor;
  }

  input,
  select,
  textarea {
    border: 2px solid #000;
  }
}

/* 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 - Tailwind handles this with dark: prefix */
@media (prefers-color-scheme: dark) {
  /* Additional dark mode enhancements if needed */
  :root {
    color-scheme: dark;
  }
}

/* Mobile-specific table styles */
@media (max-width: 768px) {
  /* Card-style table for mobile */
  .mobile-card-table thead {
    display: none;
  }

  .mobile-card-table tbody {
    display: block;
  }

  .mobile-card-table tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1rem;
    background: white;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  }

  .mobile-card-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border: none;
  }

  .mobile-card-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6B7280;
    margin-right: 1rem;
    font-size: 0.875rem;
  }

  /* Horizontal scroll for complex tables */
  .table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
  }

  .table-scroll-wrapper table {
    min-width: 600px;
  }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  /* Fix iOS input zoom */
  input,
  select,
  textarea {
    font-size: 16px;
  }

  /* Fix iOS button appearance */
  button,
  input[type="submit"],
  input[type="button"] {
    -webkit-appearance: none;
    appearance: none;
  }

  /* Fix iOS select appearance */
  select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
  }

  /* Safe area insets for notched devices */
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Android specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: 0.001dpcm) {
  /* Fix Android input appearance */
  input,
  select,
  textarea {
    -webkit-appearance: none;
    appearance: none;
  }
}

/* Print optimizations */
@media print {
  /* Hide navigation and UI elements */
  nav,
  aside,
  .mobile-nav,
  .no-print,
  button {
    display: none !important;
  }

  /* Reset layout for printing */
  main {
    margin: 0 !important;
  }

  /* Ensure proper page breaks */
  .page-break {
    page-break-after: always;
  }

  /* Optimize table printing */
  table {
    page-break-inside: avoid;
  }

  tr {
    page-break-inside: avoid;
  }

  /* White background for print */
  body {
    background: white !important;
  }
}

/* ============================================
   CUSTOM SCROLLBAR (Webkit browsers)
   ============================================ */
@media (min-width: 1024px) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: #F3F4F6;
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
  }
}

/* ============================================
   SMOOTH SCROLLING
   ============================================ */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}
