/* Mobile-specific styles for better touch interaction */

/* Ensure minimum touch target size of 44x44px */
@media (max-width: 768px) {
  /* Make all buttons have minimum touch target size */
  button {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation; /* Prevent double-tap zoom */
  }
  
  /* Increase spacing between buttons */
  .mobile-button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 8px;
    padding: 8px;
  }
  
  .mobile-button-grid.three-column {
    grid-template-columns: 1fr 1fr 1fr;
  }
  
  .mobile-button-grid.four-column {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }
  
  .mobile-button-grid.five-column {
    grid-template-columns: repeat(5, 1fr);
  }
  
  /* Priority buttons - larger and more prominent */
  .priority-button {
    font-size: 16px;
    padding: 12px 16px;
    font-weight: 600;
  }
  
  /* Secondary buttons */
  .secondary-button {
    font-size: 14px;
    padding: 10px 12px;
  }
  
  /* Expandable button groups */
  .button-group-collapsed {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
  }
  
  .button-group-expanded {
    max-height: 500px;
    transition: max-height 0.3s ease-in;
  }
  
  /* Mobile-specific quick actions bar */
  .mobile-quick-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(31, 41, 55, 0.95); /* bg-gray-800 with opacity */
    backdrop-filter: blur(10px);
    border-top: 1px solid #374151; /* border-gray-700 */
    z-index: 40;
    padding: 8px;
  }
  
  /* Swipeable button container */
  .swipe-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .swipe-container::-webkit-scrollbar {
    display: none;
  }
  
  .swipe-item {
    flex: 0 0 auto;
    scroll-snap-align: start;
    margin-right: 8px;
  }
  
  /* Visual feedback for button press */
  button:active {
    transform: scale(0.95);
    opacity: 0.8;
  }
  
  /* Larger close buttons for modals */
  .modal-close-button {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
  }
  
  /* Improved project action buttons */
  .project-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
  }
  
  .project-actions button {
    width: 100%;
    justify-content: center;
  }
  
  /* Terminal command buttons */
  .terminal-commands-mobile {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 8px;
    background: #1f2937; /* bg-gray-800 */
    border-radius: 8px;
    margin-bottom: 8px;
  }
  
  .terminal-commands-mobile button {
    padding: 12px;
    font-size: 14px;
    border-radius: 6px;
  }
  
  /* Full-width primary actions */
  .full-width-action {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
  }
  
  /* Floating action button (FAB) */
  .fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 50;
  }
  
  .fab-menu {
    position: fixed;
    bottom: 80px;
    right: 20px;
    display: flex;
    flex-direction: column-reverse;
    gap: 12px;
    z-index: 49;
  }
  
  .fab-menu button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

/* Accessibility improvements */
button:focus-visible {
  outline: 2px solid #3b82f6; /* blue-500 */
  outline-offset: 2px;
}

/* Haptic feedback indicator */
.haptic-feedback {
  position: relative;
  overflow: hidden;
}

.haptic-feedback::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s;
}

.haptic-feedback:active::after {
  width: 100%;
  height: 100%;
}

/* Copy button styles */
@media (max-width: 768px) {
  .copy-btn {
    min-width: 32px;
    min-height: 32px;
    padding: 4px 8px;
    font-size: 12px;
    background-color: rgba(55, 65, 81, 0.8); /* bg-gray-700 with opacity */
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
  }
  
  .copy-btn:active {
    background-color: rgba(34, 197, 94, 0.8); /* bg-green-600 with opacity */
    transform: scale(0.95);
  }
  
  /* Long press indicator */
  .long-press-hint {
    position: fixed;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(31, 41, 55, 0.95);
    color: #9ca3af;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 60;
  }
  
  .long-press-hint.show {
    opacity: 1;
  }
  
  /* Command button with copy indicator */
  .cmd-button {
    position: relative;
  }
  
  .cmd-button::before {
    content: '📋';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.2s;
  }
  
  .cmd-button.copying::before {
    opacity: 1;
  }
  
  /* Inline copy buttons */
  .inline-copy {
    margin-left: 4px;
    vertical-align: middle;
  }
  
  /* Copy section styling */
  .copy-commands-section {
    background: rgba(31, 41, 55, 0.5);
    border: 1px solid #374151;
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
  }
  
  .copy-commands-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
    margin-top: 8px;
  }
  
  /* Visual feedback for copyable items */
  .copyable {
    cursor: pointer;
    user-select: text;
    -webkit-user-select: text;
  }
  
  .copyable:active {
    background-color: rgba(59, 130, 246, 0.2); /* blue highlight */
  }
}

/* iPhone-specific terminal layout fixes */
@media (max-width: 428px) { /* iPhone 12/13/14 Pro Max and smaller */
  /* Prevent horizontal scrolling in terminals */
  body {
    overflow-x: hidden;
  }
  
  #terminal-view {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  
  .terminal-container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 5px !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  
  #terminal {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  /* Ensure xterm terminal fits properly */
  .xterm {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .xterm-viewport {
    width: 100% !important;
    overflow-x: hidden !important;
  }
  
  .xterm-screen {
    width: 100% !important;
  }
  
  /* Adjust font size for narrow screens */
  .xterm {
    font-size: 12px !important;
  }
  
  /* Grid layout for cubicles on mobile */
  #cubicle-terminals {
    grid-template-columns: 1fr !important;
    padding: 0.5rem !important;
    gap: 0.5rem !important;
  }
  
  /* Fix cubicle terminal containers on mobile */
  #cubicle-terminals > div {
    width: 100% !important;
    max-width: 100% !important;
    height: 300px !important;
    min-height: 300px !important;
  }
  
  /* Ensure cubicle terminals fit properly */
  .cubicle-terminal {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
  
  /* Fix cubicle terminal xterm instances */
  .cubicle-terminal .xterm {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 11px !important;
  }
  
  .cubicle-terminal .xterm-viewport {
    width: 100% !important;
    overflow-x: hidden !important;
  }
  
  .cubicle-terminal .xterm-screen {
    width: 100% !important;
  }
  
  /* Adjust quick commands for mobile */
  .mobile-quick-actions {
    padding: 6px !important;
  }
  
  /* Ensure modals don't cause horizontal scroll */
  .fixed {
    max-width: 100vw !important;
  }
  
  /* Double-stack context bars on mobile */
  .context-bar {
    flex-direction: column !important;
    gap: 0.5rem !important;
    padding: 0.5rem !important;
  }
  
  .context-bar > div {
    width: 100% !important;
  }
  
  /* Stack AI Office context bar items vertically */
  #ai-office-grid .bg-gray-800 > div:first-child {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }
  
  #ai-office-grid .bg-gray-800 h2 {
    font-size: 1rem !important;
    text-align: center !important;
  }
  
  /* Hide desktop commands on mobile AI Office */
  #ai-office-grid .hidden.md\\:flex {
    display: none !important;
  }
  
  /* Ensure dropdowns work on mobile */
  .dropdown-content {
    position: fixed !important;
    left: 1rem !important;
    right: 1rem !important;
    width: auto !important;
  }
  
  /* Fix AI office grid container */
  #ai-office-grid {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  
  /* Fix cubicle header buttons - OLD selector */
  .bg-gray-800.p-2.border-b.border-gray-700 {
    flex-wrap: wrap !important;
    gap: 0.25rem !important;
  }

  .bg-gray-800.p-2.border-b.border-gray-700 button {
    font-size: 0.75rem !important;
    padding: 0.25rem 0.5rem !important;
  }

  /* Fix cubicle header buttons - CORRECT selector for AI Office */
  .bg-gray-900.border-b.border-gray-700 .flex.items-center[class*="gap-"] {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
  }

  .bg-gray-900.border-b.border-gray-700 .flex.items-center[class*="gap-"] button {
    flex: 0 0 auto !important;
  }
}