/*
 * MOBILE-FIRST ARCHITECTURE
 * tickets.instaparadise.com - Mobile Implementation
 * Ticket: MOBILE-DEV-001
 * Author: Lyle (Mobile Dev Lead)
 * Date: 2026-04-25
 */

/* Touch target size enforcement - UPDATED for 48px minimum */
.touch-target {
  min-width: 48px;
  min-height: 48px;
}

/* ============================================
   1. MOBILE NAVIGATION COMPONENT - BOTTOM TAB BAR
   ============================================ */

:root {
  --mobile-nav-height: 64px;
  --mobile-nav-bg: var(--bg-section);
  --mobile-nav-border: var(--border);
  --mobile-tab-active: var(--coral);
  --mobile-tab-inactive: var(--text-soft);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Mobile Navigation Container */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--mobile-nav-height) + var(--safe-area-bottom));
  background: var(--mobile-nav-bg);
  border-top: 1px solid var(--mobile-nav-border);
  z-index: 1000;
  padding-bottom: var(--safe-area-bottom);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}

.mobile-nav-tabs {
  display: flex;
  height: var(--mobile-nav-height);
  align-items: stretch;
  justify-content: space-around;
}

.mobile-nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  min-width: 48px;
  min-height: 48px;
  color: var(--mobile-tab-inactive);
  font-size: 0.7rem;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.mobile-nav-tab::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--mobile-tab-active);
  border-radius: 0 0 4px 4px;
  transition: width 0.2s ease;
}

.mobile-nav-tab.active {
  color: var(--mobile-tab-active);
}

.mobile-nav-tab.active::before {
  width: 40%;
}

.mobile-nav-tab:active {
  background: rgba(255, 107, 107, 0.1);
}

.mobile-nav-tab .tab-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.mobile-nav-tab .tab-label {
  font-size: 0.65rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Column Dots Indicator */
.mobile-nav-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 4px 0;
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-light);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.mobile-nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.2s ease;
}

.mobile-nav-dot.active {
  background: var(--coral);
  transform: scale(1.3);
}

/* ============================================
   2. TOUCH INTERACTION HANDLERS
   ============================================ */

/* Touch Action Zones */
.touch-zone {
  touch-action: pan-y pinch-zoom;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Long Press Indicator */
.long-press-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 107, 107, 0.2);
  border: 3px solid var(--coral);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.long-press-indicator.pressing {
  opacity: 1;
  animation: longPressPulse 0.5s ease-out forwards;
}

@keyframes longPressPulse {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; }
}

/* Swipe Actions Container */
.swipe-actions {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.swipe-actions.left {
  left: 0;
}

.swipe-actions.right {
  right: 0;
}

.swipe-actions.visible {
  opacity: 1;
  pointer-events: auto;
}

.swipe-action-btn {
  width: 80px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.swipe-action-btn:active {
  transform: scale(0.95);
}

.swipe-action-btn.move-left {
  background: var(--ocean);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.swipe-action-btn.move-right {
  background: var(--sand);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.swipe-action-btn.delete {
  background: #f44336;
}

.swipe-action-btn .action-icon {
  font-size: 1.2rem;
}

/* Task Card Swipe State - ENHANCED with visual feedback */
.task-card.swiping {
  transition: transform 0.1s linear;
}

.task-card.swiping-left {
  background: linear-gradient(to left, rgba(212, 168, 83, 0.15) 0%, transparent 30%) !important;
  box-shadow: inset -4px 0 0 var(--sand);
}

.task-card.swiping-right {
  background: linear-gradient(to right, rgba(14, 165, 233, 0.15) 0%, transparent 30%) !important;
  box-shadow: inset 4px 0 0 var(--ocean);
}

.task-card.swiped-left {
  transform: translateX(-80px);
}

.task-card.swiped-right {
  transform: translateX(80px);
}

/* Swipe action hints */
.task-card::before,
.task-card::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 10;
}

.task-card.swiping-right::before {
  content: '⬅️';
  left: 10px;
  opacity: 0.8;
  background: var(--ocean);
}

.task-card.swiping-left::after {
  content: '➡️';
  right: 10px;
  opacity: 0.8;
  background: var(--sand);
}

/* Touch Menu (Context Menu for Mobile) */
.touch-menu {
  position: fixed;
  background: var(--bg-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 8px 0;
  min-width: 200px;
  z-index: 1001;
  opacity: 0;
  transform: scale(0.95) translateY(10px);
  pointer-events: none;
  transition: all 0.15s ease-out;
}

.touch-menu.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.touch-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  min-height: 48px;
}

.touch-menu-item:hover,
.touch-menu-item:active {
  background: var(--bg-section);
}

.touch-menu-item .menu-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.touch-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* Touch Menu Overlay */
.touch-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.touch-menu-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================
   3. RESPONSIVE BREAKPOINT SYSTEM
   ============================================ */

/* Mobile: < 640px - Single Column View */
@media (max-width: 639px) {
  /* Show mobile navigation */
  .mobile-nav {
    display: block;
  }

  /* Add padding for nav */
  body {
    padding-bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 16px);
  }

  /* Single column layout */
  .board-columns {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-x: visible;
    scroll-snap-type: none;
    padding: 0;
    margin: 0;
  }

  .board-column {
    flex: none;
    width: 100%;
    min-width: auto;
    max-width: none;
    scroll-snap-align: none;
    margin: 0 0 1rem 0;
    display: none; /* Hidden by default, shown via JS */
  }

  .board-column.active {
    display: block;
  }

  /* Hide desktop filters on mobile */
  .filter-bar {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    z-index: 99;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    margin: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    max-height: 70vh;
    overflow-y: auto;
  }

  .filter-bar.visible {
    transform: translateY(0);
  }

  /* Mobile filter toggle button */
  .mobile-filter-toggle {
    display: flex;
    position: fixed;
    top: 60px;
    right: 1rem;
    z-index: 98;
    width: auto;
    padding: 0.5rem 1rem;
    background: var(--coral);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
  }

  /* Adjust board container */
  .board-container {
    padding: 0.75rem;
    padding-top: 3rem;
  }

  /* Full-width modals */
  .task-detail-modal {
    padding: 0;
    align-items: flex-end;
  }

  .task-detail-content {
    max-width: none;
    width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: slideUpModal 0.3s ease;
  }

  @keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* Compact header */
  header {
    padding: 0.5rem 1rem;
  }

  .logo {
    font-size: 1.1rem;
  }

  nav {
    gap: 0.75rem;
  }

  nav a {
    font-size: 0.8rem;
  }

  /* Hide desktop board stats in header */
  .board-header .board-stats {
    display: none;
  }

  /* Floating action button for new task */
  .fab-new-task {
    display: flex;
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 16px);
    right: 1rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--coral);
    color: white;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
    border: none;
    cursor: pointer;
    z-index: 999;
    transition: transform 0.2s, box-shadow 0.2s;
  }

  .fab-new-task:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
  }

  /* Hide desktop new task button */
  .refresh-btn[onclick*="openNewTaskModal"] {
    display: none;
  }
}

/* Tablet: 640px - 1024px - Two Column View */
@media (min-width: 640px) and (max-width: 1024px) {
  .board-columns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    overflow-x: visible;
    scroll-snap-type: none;
  }

  .board-column {
    min-width: auto;
    max-width: none;
  }

  /* Adjust filter bar */
  .filter-bar {
    flex-wrap: wrap;
  }

  .search-box {
    flex: 1 1 100%;
    max-width: none;
    margin-bottom: 0.5rem;
  }

  /* Compact modals */
  .task-detail-content {
    max-width: 90vw;
  }
}

/* Desktop: > 1024px - Full Kanban */
@media (min-width: 1025px) {
  .board-columns {
    display: grid;
    grid-template-columns: repeat(6, minmax(280px, 1fr));
  }

  /* Hide mobile-only elements */
  .mobile-nav,
  .fab-new-task,
  .mobile-filter-toggle {
    display: none !important;
  }
}

/* ============================================
   4. FLUID TYPOGRAPHY
   ============================================ */

/* Clamp-based fluid typography */
.board-title {
  font-size: clamp(1.25rem, 4vw, 1.75rem);
}

.column-title {
  font-size: clamp(0.85rem, 2vw, 0.95rem);
}

.task-title {
  font-size: clamp(0.9rem, 2.5vw, 1rem);
}

.task-id {
  font-size: clamp(0.7rem, 1.5vw, 0.75rem);
}

.priority-badge {
  font-size: clamp(0.65rem, 1.5vw, 0.75rem);
}

/* ============================================
   5. PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* GPU Acceleration for animations */
.task-card,
.board-column,
.mobile-nav-tab,
.swipe-action-btn {
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Contain layout for better performance */
.board-column {
  contain: layout style;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .task-card,
  .board-column,
  .mobile-nav-tab,
  .swipe-action-btn {
    will-change: auto;
  }
}

/* Content visibility for off-screen columns */
.board-column {
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
}

.board-column.active {
  content-visibility: visible;
}

/* ============================================
   6. MOBILE FORM EXPERIENCE
   ============================================ */

@media (max-width: 639px) {
  /* Better input sizing for mobile - 16px font prevents zoom on iOS */
  input[type="text"],
  input[type="email"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 48px; /* UPDATED: 48px minimum touch target */
    padding: 14px 16px; /* UPDATED: More padding for touch */
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    width: 100%;
  }

  /* Touch-friendly form buttons - UPDATED to 48px minimum */
  .btn,
  button[type="submit"],
  button[type="button"] {
    min-height: 48px;
    min-width: 48px;
    padding: 14px 24px;
    font-size: 16px; /* Prevents zoom */
  }

  /* Modal form layout */
  #new-task-modal-content .modal-body > div[style*="grid"] {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  /* Sticky modal actions */
  .modal-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg-section);
    padding: 1rem;
    border-top: 1px solid var(--border);
    margin: 0 -1.5rem -1.5rem -1.5rem;
    display: flex;
    gap: 0.75rem;
  }

  .modal-actions .btn {
    flex: 1;
    justify-content: center;
  }

  /* Full-width inputs in modals */
  .modal-body input,
  .modal-body textarea,
  .modal-body select {
    width: 100%;
  }

  /* Better textarea sizing */
  textarea {
    min-height: 120px;
  }

  /* Date/time picker improvements */
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"] {
    min-height: 48px;
    font-size: 16px;
  }

  /* Full-screen modals on mobile */
  .task-detail-modal {
    padding: 0;
    align-items: flex-end;
  }

  .task-detail-content {
    max-width: none;
    width: 100%;
    max-height: 95vh;
    height: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: slideUpModal 0.3s ease;
  }

  @keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* Move buttons - ensure 48px touch target */
  .move-btn {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  /* Modal close button - ensure 48px touch target */
  .modal-close-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
  }
}

/* ============================================
   7. OFFLINE SUPPORT STYLES
   ============================================ */

/* Offline indicator */
.offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #ff9800;
  color: white;
  text-align: center;
  padding: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 10000;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.offline-indicator.visible {
  transform: translateY(0);
}

/* Sync pending indicator */
.sync-pending {
  position: relative;
}

.sync-pending::after {
  content: '⏳';
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 0.75rem;
  background: var(--sand);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Loading states */
.loading-shimmer {
  background: linear-gradient(
    90deg,
    var(--bg-section) 25%,
    var(--bg-light) 50%,
    var(--bg-section) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

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

/* ============================================
   8. ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/* Focus visible styles */
.mobile-nav-tab:focus-visible,
.fab-new-task:focus-visible,
.swipe-action-btn:focus-visible {
  outline: 2px solid var(--ocean);
  outline-offset: -2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .mobile-nav-tab {
    border: 1px solid transparent;
  }

  .mobile-nav-tab.active {
    border-color: currentColor;
  }

  .task-card {
    border-width: 2px;
  }
}

/* Screen reader only text */
.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;
}

/* ============================================
   9. UTILITY CLASSES
   ============================================ */

.hide-mobile { display: inherit; }
.hide-desktop { display: none; }

@media (max-width: 639px) {
  .hide-mobile { display: none !important; }
  .hide-desktop { display: inherit !important; }
}

/* Touch target size enforcement */
.touch-target {
  min-width: 44px;
  min-height: 44px;
}

/* Safe area insets for notched devices */
@supports (padding-top: env(safe-area-inset-top)) {
  header {
    padding-top: max(0.5rem, env(safe-area-inset-top));
  }
}
