/**
 * HEC Bore Merger - Mobile Styles
 * iOS Safari optimized, portrait-first responsive design
 */

/* ============================================
   Safari-Specific Fixes & Utilities
   ============================================ */

/* Disable tap highlight (we'll use custom active states) */
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* Fix iOS input zoom */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  font-size: 16px !important; /* Prevents iOS zoom on focus */
}

/* Safe area insets for notched devices (iPhone X+) */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Fix for 100vh on mobile Safari (address bar issues) */
.full-height-mobile {
  height: 100vh;
  height: -webkit-fill-available;
}

/* Prevent overscroll bounce on body */
body {
  overscroll-behavior-y: none;
}

/* ============================================
   Touch Target Utilities
   ============================================ */

/* Minimum 44px touch targets per iOS HIG */
.touch-target {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Larger touch padding for small interactive elements */
.touch-padding {
  padding: 12px 16px;
}

/* Active state feedback for touch */
.touch-active:active {
  opacity: 0.6;
  transform: scale(0.98);
  transition: all 0.1s ease;
}

/* ============================================
   Bottom Navigation (iOS Style)
   ============================================ */

.bottom-nav {
  display: none; /* Hidden by default, shown on mobile */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: var(--secondary-bg);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.3);
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom); /* Account for home indicator */
}

@media (max-width: 767px) {
  .bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
  }

  /* Hide desktop top nav on mobile */
  .nav-bar {
    height: 50px; /* Reduce height on mobile */
  }

  .nav-links {
    display: none; /* Hide desktop nav links */
  }

  .nav-container {
    padding: 0 16px; /* Reduce padding */
    height: 50px;
  }

  .nav-brand {
    font-size: 16px;
  }

  .nav-brand img {
    height: 28px;
  }

  /* Jobs page - button on right side on mobile */
  #new-job-btn {
    min-width: 100px;
    max-width: 140px;
    white-space: nowrap;
    padding: 8px 16px;
    font-size: 14px;
  }

  #status-filter,
  #sort-filter {
    min-width: 100px !important;
    font-size: 14px;
  }
}

.bottom-nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: #9ca3af;
  transition: all 0.2s ease;
  padding: 8px;
  min-width: 60px;
  position: relative;
}

.bottom-nav-tab:active {
  opacity: 0.6;
}

.bottom-nav-tab.active {
  color: var(--hec-orange);
}

.bottom-nav-tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  background: var(--hec-orange);
  border-radius: 0 0 3px 3px;
}

.bottom-nav-icon {
  font-size: 24px;
  line-height: 1;
}

.bottom-nav-label {
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
}

/* ============================================
   Mobile Portrait Layouts (< 768px)
   ============================================ */

@media (max-width: 767px) and (orientation: portrait) {

  /* Container adjustments */
  .main-content {
    padding: 16px;
    margin-top: 50px; /* Account for smaller nav */
  }

  .container {
    margin-top: calc(50px + env(safe-area-inset-top) + 16px); /* Nav height + safe area + extra spacing */
    padding: 16px;
  }

  /* Card layouts - stack vertically */
  .card-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .card {
    width: 100%;
    margin: 0;
  }

  /* Forms - full width inputs */
  form input,
  form textarea,
  form select,
  form button {
    width: 100%;
    font-size: 16px; /* Prevent iOS zoom */
  }

  form .btn {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  /* Tables - horizontal scroll */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 600px; /* Force horizontal scroll */
  }

  /* Modals - full screen on mobile */
  .modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
  }

  /* Hide elements that don't work well on mobile */
  .desktop-only {
    display: none !important;
  }

  /* Stack action button groups */
  .action-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .action-group .btn {
    width: 100%;
  }

  /* File upload areas - larger touch targets */
  .upload-area {
    min-height: 120px;
    padding: 24px;
  }

  /* Typography adjustments */
  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 20px;
  }

  h3 {
    font-size: 18px;
  }

  /* Reduce padding/margins overall */
  .section {
    padding: 16px;
  }

  .section-header {
    padding: 12px 16px;
  }
}

/* ============================================
   Mobile Landscape (GPS Capture Only)
   ============================================ */

@media (max-width: 767px) and (orientation: landscape) {

  /* GPS capture specific layout */
  .gps-capture-landscape {
    display: grid;
    grid-template-columns: 1fr 120px; /* Map + compact sidebar */
    grid-template-rows: 50px 1fr; /* Header + content */
    height: 100vh;
    height: -webkit-fill-available;
    gap: 0;
  }

  .gps-capture-header {
    grid-column: 1 / -1;
    padding: 8px 12px;
  }

  .gps-capture-map {
    grid-row: 2;
    grid-column: 1;
  }

  .gps-capture-sidebar {
    grid-row: 2;
    grid-column: 2;
    overflow-y: auto;
  }
}

/* ============================================
   Tablet (768px - 1024px)
   ============================================ */

@media (min-width: 768px) and (max-width: 1024px) {

  /* Hide bottom nav, show desktop nav */
  .bottom-nav {
    display: none;
  }

  /* Slightly larger containers */
  .main-content {
    padding: 24px;
  }

  /* Two-column card grid on tablet */
  .card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

/* ============================================
   Desktop (> 1024px)
   ============================================ */

@media (min-width: 1025px) {

  /* Hide bottom nav completely */
  .bottom-nav {
    display: none !important;
  }

  /* Hide mobile-only elements */
  .mobile-only {
    display: none !important;
  }
}

/* ============================================
   Collapsible Sections (Mobile)
   ============================================ */

@media (max-width: 767px) {

  .collapsible-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
  }

  .collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--card-bg);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    min-height: 44px; /* Touch target */
  }

  .collapsible-header:active {
    opacity: 0.8;
  }

  .collapsible-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
  }

  .collapsible-icon {
    font-size: 20px;
    transition: transform 0.3s ease;
  }

  .collapsible-section.expanded .collapsible-icon {
    transform: rotate(180deg);
  }

  .collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  .collapsible-section.expanded .collapsible-content {
    max-height: 5000px; /* Large enough for most content */
  }

  .collapsible-body {
    padding: 16px;
  }
}

/* ============================================
   Loading States & Animations
   ============================================ */

/* Skeleton loader for mobile */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.05) 25%,
    rgba(255,255,255,0.1) 50%,
    rgba(255,255,255,0.05) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Pull to refresh indicator (native on iOS) */
.refresh-indicator {
  display: none; /* iOS handles this natively */
}
