/* Mobile Layout Styles */
/* Mobile-specific styles for touch-friendly panel navigation */

/* When mobile layout is active (forced via ?layout=mobile or auto-detected) */
body.mobile-layout-active .lm_goldenlayout {
  display: none !important;
}

body.mobile-layout-active .mobile-layout-container {
  display: flex !important;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  background-color: #2d2d2d;
  color: #cecece;
  position: relative;
  overflow: hidden;
}

body.mobile-layout-active .mobile-panel-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  padding-bottom: 60px;
  background-color: #2d2d2d;
}

body.mobile-layout-active .mobile-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background-color: #1a1a1a;
  border-top: 1px solid #666;
  display: flex !important;
  align-items: center;
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

body.mobile-layout-active .mobile-tab-bar {
  flex: 1;
  height: 100%;
  display: flex !important;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #666 #1a1a1a;
  scroll-behavior: smooth;
}

body.mobile-layout-active .mobile-nav-btn {
  background: #3a3a3a;
  border: 1px solid #555;
  color: #fff;
  padding: 0;
  width: 50px;
  height: 100%;
  font-size: 20px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.mobile-layout-active .mobile-nav-btn:hover:not(:disabled) {
  background: #4a4a4a;
}

body.mobile-layout-active .mobile-nav-btn:disabled {
  cursor: not-allowed;
  opacity: 0.3;
}

body.mobile-layout-active .mobile-nav-left {
  border-right: 1px solid #444;
}

body.mobile-layout-active .mobile-nav-right {
  border-left: 1px solid #444;
}

/* Panel instance styling when mobile is active */
body.mobile-layout-active .mobile-panel-instance {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 10px;
  box-sizing: border-box;
}

/* Individual tabs when mobile is active */
body.mobile-layout-active .mobile-tab {
  flex: 0 0 auto;
  min-width: 70px;
  max-width: 100px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 8px 10px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  position: relative;
}

body.mobile-layout-active .mobile-tab:active {
  background-color: rgba(255, 255, 255, 0.1);
}

body.mobile-layout-active .mobile-tab.active {
  background-color: rgba(52, 152, 219, 0.2);
}

body.mobile-layout-active .mobile-tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: #3498db;
}

body.mobile-layout-active .mobile-tab-icon {
  font-size: 20px;
  margin-bottom: 4px;
  user-select: none;
}

body.mobile-layout-active .mobile-tab-label {
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  color: #cecece;
  user-select: none;
  font-weight: 400;
}

body.mobile-layout-active .mobile-tab.active .mobile-tab-label {
  color: #3498db;
  font-weight: 500;
}

/* When desktop layout is active, hide mobile elements */
body.desktop-layout-active .mobile-layout-container,
body.desktop-layout-active .mobile-tab-bar {
  display: none !important;
}

/*
 * Touch-friendly and small-screen adjustments.
 *
 * All rules are scoped under body.mobile-layout-active so they only apply
 * when the app explicitly chose mobile mode — never on a desktop layout
 * that simply has a narrow window.
 */

/* Error message styling */
body.mobile-layout-active .mobile-error-message {
  padding: 20px;
  text-align: center;
  color: #e74c3c;
}

body.mobile-layout-active .mobile-error-message h3 {
  margin-bottom: 10px;
}

/* Adjust existing panels for mobile */
body.mobile-layout-active #main-content,
body.mobile-layout-active #inventory-column,
body.mobile-layout-active #locations-column {
  width: 100% !important;
  min-width: unset !important;
  max-width: 100% !important;
  border: none !important;
  margin: 0 !important;
  padding: 10px !important;
}

/* Hide main content collapse button on mobile */
body.mobile-layout-active #main-content-collapse-btn,
body.mobile-layout-active #main-content-expand-btn {
  display: none !important;
}

/* Make buttons and inputs touch-friendly */
body.mobile-layout-active .button,
body.mobile-layout-active button,
body.mobile-layout-active input[type="button"],
body.mobile-layout-active input[type="submit"] {
  min-height: 44px;
  padding: 12px 16px;
  font-size: 16px; /* Prevent zoom on iOS */
}

body.mobile-layout-active input[type="text"],
body.mobile-layout-active input[type="number"],
body.mobile-layout-active input[type="email"],
body.mobile-layout-active textarea,
body.mobile-layout-active select {
  min-height: 44px;
  padding: 10px;
  font-size: 16px; /* Prevent zoom on iOS */
}

/* Larger checkboxes and radio buttons */
body.mobile-layout-active input[type="checkbox"],
body.mobile-layout-active input[type="radio"] {
  min-width: 24px;
  min-height: 24px;
  margin: 8px;
}

/* Improve spacing for touch targets */
body.mobile-layout-active .inventory-items .item-button,
body.mobile-layout-active .location-card,
body.mobile-layout-active .exit-card {
  min-height: 44px;
  padding: 10px;
  margin-bottom: 8px;
}

/* Adjust grid layouts for mobile */
body.mobile-layout-active #locations-grid,
body.mobile-layout-active #exits-grid {
  grid-template-columns: 1fr !important;
  gap: 10px;
}

/* Make modals mobile-friendly */
body.mobile-layout-active .modal {
  width: 90% !important;
  max-width: 100% !important;
  margin: 5% auto !important;
}

body.mobile-layout-active .modal-content {
  max-height: 80vh;
  overflow-y: auto;
}

/* Adjust loop controls for mobile */
body.mobile-layout-active .loop-controls {
  flex-wrap: wrap;
  gap: 8px;
}

body.mobile-layout-active .loop-controls button {
  flex: 1;
  min-width: 100px;
}

/* Make region blocks more touch-friendly */
body.mobile-layout-active .loop-region-block {
  margin-bottom: 15px;
}

body.mobile-layout-active .loop-region-header {
  min-height: 44px;
  padding: 12px;
}

/* Adjust test panel for mobile */
body.mobile-layout-active .test-item {
  padding: 12px;
}

body.mobile-layout-active .test-item-controls {
  flex-wrap: wrap;
  gap: 8px;
}

/* Hide desktop-specific features */
body.mobile-layout-active .view-selector {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

/* Ensure scrolling works properly */
body.mobile-layout-active {
  overflow: hidden; /* Prevent body scroll */
  position: fixed;
  width: 100%;
  height: 100%;
}

/* Loading screen adjustments */
body.mobile-layout-active .loading-screen {
  z-index: 2000; /* Above mobile tab bar */
}

/* Add subtle gradients on edges to indicate scrollability */
body.mobile-layout-active .mobile-tab-bar::before,
body.mobile-layout-active .mobile-tab-bar::after {
  content: '';
  position: fixed;
  top: auto;
  bottom: 0;
  width: 20px;
  height: 60px;
  pointer-events: none;
  z-index: 1001;
}

body.mobile-layout-active .mobile-tab-bar::before {
  left: 0;
  background: linear-gradient(to right, #1a1a1a 0%, transparent 100%);
}

body.mobile-layout-active .mobile-tab-bar::after {
  right: 0;
  background: linear-gradient(to left, #1a1a1a 0%, transparent 100%);
}

/* Custom scrollbar for webkit browsers */
body.mobile-layout-active .mobile-tab-bar::-webkit-scrollbar {
  height: 4px;
}

body.mobile-layout-active .mobile-tab-bar::-webkit-scrollbar-track {
  background: #1a1a1a;
}

body.mobile-layout-active .mobile-tab-bar::-webkit-scrollbar-thumb {
  background: #666;
  border-radius: 2px;
}

body.mobile-layout-active .mobile-tab-bar::-webkit-scrollbar-thumb:hover {
  background: #888;
}

/* Landscape mode adjustments */
@media (orientation: landscape) {
  body.mobile-layout-active .mobile-bottom-bar {
    height: 50px;
  }

  body.mobile-layout-active .mobile-nav-btn {
    width: 45px;
    font-size: 18px;
  }

  body.mobile-layout-active .mobile-tab-bar::before,
  body.mobile-layout-active .mobile-tab-bar::after {
    height: 50px;
  }

  body.mobile-layout-active .mobile-tab {
    min-width: 65px;
    max-width: 90px;
  }

  body.mobile-layout-active .mobile-tab-icon {
    font-size: 18px;
  }

  body.mobile-layout-active .mobile-tab-label {
    font-size: 10px;
  }

  body.mobile-layout-active .mobile-panel-content {
    padding-bottom: 50px;
  }
}

/* Tablet adjustments (larger touch devices) */
@media (min-width: 769px) and (pointer: coarse) {
  body.mobile-layout-active .mobile-tab-bar {
    height: 70px;
  }

  body.mobile-layout-active .mobile-tab-bar::before,
  body.mobile-layout-active .mobile-tab-bar::after {
    height: 70px;
  }

  body.mobile-layout-active .mobile-tab {
    min-width: 80px;
    max-width: 120px;
  }

  body.mobile-layout-active .mobile-tab-icon {
    font-size: 24px;
  }

  body.mobile-layout-active .mobile-tab-label {
    font-size: 12px;
  }

  /* Allow 2-column grids on tablets */
  body.mobile-layout-active #locations-grid,
  body.mobile-layout-active #exits-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
  }
}

/* Panel instance styling */
.mobile-panel-instance {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 10px;
  box-sizing: border-box;
}