/* mobile.css - Mobile-first responsive improvements for DeliveryMate
 * Add this to both sender.html and driver.html:
 * <link rel="stylesheet" href="/css/mobile.css" />
 */

/* ============================================
   Mobile Breakpoint: < 640px
   ============================================ */

@media (max-width: 640px) {
  
  /* Touch-Friendly Buttons */
  button, .btn {
    min-height: 44px; /* Apple HIG minimum touch target */
    padding: 12px 16px;
    font-size: 15px;
  }
  
  /* Prevent iOS Zoom on Input Focus */
  input, select, textarea {
    font-size: 16px; /* iOS won't zoom if >= 16px */
    min-height: 44px;
    padding: 10px 12px;
  }
  
  /* Container Spacing */
  .container {
    padding: 12px;
    max-width: 100%;
  }
  
  /* Card Spacing */
  .card {
    padding: 14px;
    margin: 12px 0;
    border-radius: 12px;
  }
  
  .card.compact {
    padding: 10px;
  }
  
  /* Force Single Column Layouts */
  .grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  
  /* Stack Button Rows */
  .btn-row, .row {
    flex-direction: column;
    gap: 8px;
  }
  
  .btn-row .btn,
  .btn-row button {
    width: 100%;
  }
  
  /* Navigation */
  .topbar {
    padding: 10px 12px;
  }
  
  .nav {
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
  }
  
  .nav a {
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 8px;
  }
  
  /* Headings */
  h1 {
    font-size: 24px;
    margin-bottom: 12px;
  }
  
  h2 {
    font-size: 20px;
    margin-top: 16px;
  }
  
  h3 {
    font-size: 18px;
    margin-top: 12px;
  }
  
  /* Form Labels */
  label {
    font-size: 14px;
    margin-top: 10px;
    margin-bottom: 6px;
  }
  
  /* Select Dropdowns */
  select {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border-radius: 8px;
  }
  
  /* Alerts & Banners */
  .alert, .banner {
    padding: 12px;
    font-size: 14px;
    border-radius: 10px;
  }
  
  /* Status Pills */
  .pill {
    font-size: 12px;
    padding: 5px 10px;
  }
  
  /* Timeline Steps */
  .timeline {
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .step {
    font-size: 12px;
    padding: 5px 8px;
  }
  
  /* Details/Debug Sections */
  details.debug {
    margin-top: 12px;
  }
  
  details.debug > summary {
    font-size: 13px;
    padding: 8px 0;
  }
  
  /* Pre/Code Blocks */
  pre {
    font-size: 11px;
    padding: 10px;
    overflow-x: auto;
    border-radius: 8px;
  }
  
  /* Tables (Admin) */
  .table {
    font-size: 13px;
    display: block;
    overflow-x: auto;
  }
  
  .table th,
  .table td {
    padding: 8px;
    font-size: 13px;
  }
  
  /* Muted Text */
  .muted {
    font-size: 13px;
  }
  
  /* Spacing Utilities */
  .mt-2 {
    margin-top: 12px;
  }
  
  .mb-2 {
    margin-bottom: 12px;
  }
}

/* ============================================
   Tablet Breakpoint: 640px - 1024px
   ============================================ */

@media (min-width: 640px) and (max-width: 1024px) {
  
  .container {
    padding: 20px;
  }
  
  /* Two-column grid for certain sections */
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
  }
  
  /* Comfortable button sizing */
  button, .btn {
    min-height: 40px;
    padding: 10px 16px;
  }
  
  input, select, textarea {
    min-height: 40px;
  }
}

/* ============================================
   Landscape Phone: < 900px height
   ============================================ */

@media (max-height: 900px) and (orientation: landscape) {
  
  /* Reduce vertical spacing in landscape */
  .card {
    margin: 8px 0;
    padding: 12px;
  }
  
  h1 {
    margin-bottom: 8px;
  }
  
  h2 {
    margin-top: 12px;
    margin-bottom: 6px;
  }
  
  .topbar {
    padding: 8px 12px;
  }
}

/* ============================================
   Touch Device Optimizations
   ============================================ */

@media (hover: none) and (pointer: coarse) {
  
  /* Larger touch targets for all interactive elements */
  a, button, input, select, label, summary {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  /* Remove hover states on touch devices */
  .btn:hover {
    background: var(--primary);
  }
  
  /* Better checkbox/radio sizing */
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
    margin-right: 10px;
  }
}

/* ============================================
   Accessibility Improvements
   ============================================ */

/* Focus indicators for keyboard navigation */
@media (max-width: 640px) {
  
  button:focus,
  input:focus,
  select:focus,
  textarea:focus {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
  }
  
  /* Ensure adequate color contrast */
  .muted {
    color: #475569; /* Darker than default for better readability */
  }
}

/* ============================================
   Prevent Layout Shift
   ============================================ */

@media (max-width: 640px) {
  
  /* Prevent horizontal scroll */
  body {
    overflow-x: hidden;
  }
  
  /* Ensure images don't break layout */
  img {
    max-width: 100%;
    height: auto;
  }
  
  /* Prevent long text from breaking layout */
  pre,
  code {
    word-wrap: break-word;
    white-space: pre-wrap;
  }
}

/* ============================================
   Print Styles (Bonus)
   ============================================ */

@media print {
  
  /* Hide navigation and buttons when printing */
  .topbar,
  .btn,
  button,
  details.debug {
    display: none !important;
  }
  
  /* Optimize for print */
  .card {
    border: 1px solid #000;
    page-break-inside: avoid;
  }
  
  /* Ensure good contrast */
  body {
    background: #fff;
    color: #000;
  }
}

/* ============================================
   Dark Mode Support (Future Enhancement)
   ============================================ */

@media (prefers-color-scheme: dark) {
  /* Placeholder for dark mode styles
   * Uncomment and customize when ready:
   *
   * body {
   *   background: #0f172a;
   *   color: #e2e8f0;
   * }
   *
   * .card {
   *   background: #1e293b;
   *   border-color: #334155;
   * }
   */
}

/* ============================================
   Performance: Reduce Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  
  /* Disable smooth scrolling for users who prefer reduced motion */
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
