/**
 * MOBILE TOUCH INTERACTIONS - Styles
 * Ticket: MOBILE-TOUCH-001
 * Author: LeoWolf (Mobile Touch Specialist)
 * Date: 2026-04-25
 */

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

.mobile-column-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-section);
  border-top: 1px solid var(--border);
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.column-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 0;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
}

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

.column-dot.active {
  background: var(--coral);
  transform: scale(1.4);
  width: 16px;
  border-radius: 3px;
}

.column-tabs {
  display: flex;
  height: 64px;
  align-items: stretch;
  justify-content: space-around;
}

.column-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: 44px;
  min-height: 44px;
  color: var(--text-soft);
  font-size: 0.65rem;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

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

.column-tab.active {
  color: var(--coral);
}

.column-tab.active::before {
  transform: translateX(-50%) scaleX(1);
}

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

.tab-emoji {
  font-size: 1.4rem;
  line-height: 1;
  filter: grayscale(0.3);
  transition: filter 0.2s;
}

.column-tab.active .tab-emoji {
  filter: grayscale(0);
}

.tab-name {
  font-size: 0.6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Floating Action Button */
.fab-create-task {
  display: none;
  position: fixed;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--coral);
  color: white;
  border: none;
  cursor: pointer;
  z-index: 999;
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
  transition: all 0.2s ease;
  align-items: center;
  justify-content: center;
}

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

.fab-icon {
  font-size: 1.75rem;
  font-weight: 300;
  line-height: 1;
}

/* ============================================
   2. TOUCH INTERACTION STYLES
   ============================================ */

/* Touch pressing state */
.task-card.touch-pressing {
  transition: transform 0.1s ease;
}

/* Swipe hint overlay */
.swipe-hint-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.swipe-hint-overlay.show-left,
.swipe-hint-overlay.show-right {
  opacity: 1;
}

.swipe-hint-left,
.swipe-hint-right {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
  opacity: 0;
  transform: translateX(-20px);
  transition: all 0.2s ease;
}

.swipe-hint-right {
  transform: translateX(20px);
}

.swipe-hint-overlay.show-left .swipe-hint-left {
  opacity: 1;
  transform: translateX(0);
}

.swipe-hint-overlay.show-right .swipe-hint-right {
  opacity: 1;
  transform: translateX(0);
}

.hint-arrow {
  font-size: 1.2rem;
}

/* Shake animation for "can't move" */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ============================================
   3. TOUCH MENU STYLES
   ============================================ */

.touch-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.touch-menu {
  position: fixed;
  background: var(--bg-light);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  min-width: 260px;
  max-width: 90vw;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 2001;
  opacity: 0;
  transform: scale(0.9) translateY(20px);
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.touch-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-section);
  border-bottom: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
}

.menu-task-id {
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 600;
}

.menu-back {
  background: none;
  border: none;
  color: var(--ocean);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.menu-back:active {
  background: rgba(14, 165, 233, 0.1);
}

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

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

.touch-menu-item.danger {
  color: #f44336;
}

.touch-menu-item.danger:hover,
.touch-menu-item.danger:active {
  background: #ffebee;
}

.touch-menu-item.selected {
  background: rgba(255, 107, 107, 0.1);
}

.touch-menu-item.selected::after {
  content: '✓';
  margin-left: auto;
  color: var(--coral);
  font-weight: 700;
}

.touch-menu-item.has-submenu .menu-chevron {
  margin-left: auto;
  color: var(--text-light);
  font-size: 1.2rem;
}

.menu-icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.menu-text {
  flex: 1;
  font-weight: 500;
}

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

/* ============================================
   4. MOBILE-SPECIFIC LAYOUT (< 640px)
   ============================================ */

@media (max-width: 639px) {
  /* Show mobile navigation */
  .mobile-column-nav {
    display: block;
  }

  .fab-create-task {
    display: flex;
  }

  /* Body padding for nav */
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 16px);
  }

  /* Single column layout - show only active */
  .board-columns {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-x: visible;
  }

  .board-column {
    display: none;
    width: 100%;
    min-width: auto;
    max-width: none;
    margin: 0 0 1rem 0;
    animation: fadeInColumn 0.3s ease;
  }

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

  @keyframes fadeInColumn {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* Task card mobile optimizations */
  .task-card {
    touch-action: pan-y pinch-zoom;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    overflow: hidden;
  }

  /* Prevent text selection during swipe */
  .task-card * {
    -webkit-user-select: none;
    user-select: none;
  }

  /* Enhanced card feedback */
  .task-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
      rgba(14, 165, 233, 0) 0%, 
      rgba(14, 165, 233, 0) 100%
    );
    pointer-events: none;
    transition: background 0.2s ease;
  }

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

  .logo {
    font-size: 1.1rem;
  }

  nav {
    gap: 0.75rem;
  }

  nav a {
    font-size: 0.8rem;
  }

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

  /* Mobile filter toggle */
  .mobile-filter-toggle {
    display: flex;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 0.95rem;
    cursor: pointer;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
  }

  /* Filter bar as dropdown */
  .filter-bar {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    z-index: 99;
    background: var(--bg-section);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    max-height: 70vh;
    overflow-y: auto;
    margin: 0;
    box-shadow: var(--shadow-lg);
  }

  .filter-bar.visible {
    display: flex;
  }

  /* Mobile modal styles */
  .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);
    }
  }

  .modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .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;
  }

  /* Touch-friendly form inputs */
  input[type="text"],
  input[type="email"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px;
    padding: 12px;
    width: 100%;
  }

  textarea {
    min-height: 120px;
  }

  /* Touch-friendly buttons */
  .btn,
  button[type="submit"],
  button[type="button"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
  }

  /* Column header compact */
  .column-header {
    padding: 0.75rem;
  }

  .column-title {
    font-size: 0.9rem;
  }

  /* Task card compact */
  .task-card {
    padding: 1rem;
  }

  .task-title {
    font-size: 0.95rem;
  }

  /* Notification positioning */
  .touch-notification {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 20px);
  }
}

/* ============================================
   5. TOUCH NOTIFICATION
   ============================================ */

.touch-notification {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--coral);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 3000;
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}

.touch-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   6. ACCESSIBILITY
   ============================================ */

/* Focus visible styles */
.column-tab:focus-visible,
.fab-create-task:focus-visible,
.touch-menu-item:focus-visible {
  outline: 2px solid var(--ocean);
  outline-offset: -2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .mobile-column-nav,
  .column-tab,
  .touch-menu,
  .task-card,
  .touch-notification {
    transition: none !important;
    animation: none !important;
  }

  .board-column.mobile-active {
    animation: none;
  }
}

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

  .column-tab.active {
    border-color: currentColor;
  }

  .touch-menu-item {
    border-bottom: 1px solid var(--border);
  }
}

/* ============================================
   7. TABLET ADJUSTMENTS (640px - 1024px)
   ============================================ */

@media (min-width: 640px) and (max-width: 1024px) {
  /* Hide mobile nav on tablet */
  .mobile-column-nav,
  .fab-create-task {
    display: none !important;
  }

  /* Two column grid */
  .board-columns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .board-column {
    display: block !important;
    min-width: auto;
  }

  /* Restore body padding */
  body {
    padding-bottom: 0;
  }
}

/* ============================================
   8. SAFE AREA SUPPORT
   ============================================ */

@supports (padding-top: env(safe-area-inset-top)) {
  header {
    padding-top: max(0.5rem, env(safe-area-inset-top));
  }

  .mobile-column-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .fab-create-task {
    bottom: calc(64px + env(safe-area-inset-bottom) + 16px);
  }
}

/* ============================================
   9. DARK MODE SUPPORT
   ============================================ */

.dark .mobile-column-nav {
  background: var(--bg-section);
  border-color: var(--border);
}

.dark .column-dots {
  background: var(--bg-light);
}

.dark .touch-menu {
  background: var(--bg-light);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.dark .touch-menu-header {
  background: var(--bg-section);
}

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

.dark .touch-menu-item.danger:hover,
.dark .touch-menu-item.danger:active {
  background: rgba(244, 67, 54, 0.2);
}

.dark .swipe-hint-left,
.dark .swipe-hint-right {
  background: rgba(0, 0, 0, 0.8);
}
