/**
 * Mobile CSS - Consolidated
 * Dana Hall Work Orders Manager
 * November 2025
 *
 * Consolidates 4 core mobile files into single optimized stylesheet:
 * - mobile-first-base.css (Design tokens, touch optimization, navigation)
 * - mobile-enhancements.css (Typography, buttons, forms, work orders)
 * - mobile-enhanced-forms.css (Form controls, camera, lazy loading)
 * - mobile-gradient-header-final.css (Header, counters, menu)
 *
 * Total size: ~45KB → Optimized for performance
 */

/* ============================================
   TABLE OF CONTENTS
   ============================================
   1. DESIGN TOKENS - Variables & Spacing
   2. BASE STYLES - Reset & Touch Optimization
   3. GRADIENT HEADER - Navigation & Counters
   4. FORMS - Enhanced Mobile Forms
   5. TYPOGRAPHY & BUTTONS
   6. WORK ORDERS & CARDS
   7. CAMERA & FILE INPUT
   8. LAZY LOADING
   9. RESPONSIVE & ACCESSIBILITY
   ============================================ */

/* ============================================
   1. DESIGN TOKENS - VARIABLES & SPACING
   ============================================ */

:root {
  /* Spacing Scale */
  --space-xxs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-xxl: 3rem;

  /* Touch Target Sizes */
  --touch-target-min: 44px;
  --touch-target-ideal: 48px;

  /* Breakpoints */
  --breakpoint-sm: 576px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;

  /* Z-index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-notification: 1080;

  /* Animation */
  --transition-fast: 150ms;
  --transition-base: 250ms;
  --transition-slow: 350ms;
  --easing-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --easing-decelerate: cubic-bezier(0, 0, 0.2, 1);
  --easing-accelerate: cubic-bezier(0.4, 0, 1, 1);

  /* Safe Areas for Notched Devices */
  --safe-area-inset-top: env(safe-area-inset-top);
  --safe-area-inset-right: env(safe-area-inset-right);
  --safe-area-inset-bottom: env(safe-area-inset-bottom);
  --safe-area-inset-left: env(safe-area-inset-left);
}

/* ============================================
   2. BASE STYLES - RESET & TOUCH OPTIMIZATION
   ============================================ */

* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  padding: var(--safe-area-inset-top) var(--safe-area-inset-right)
           var(--safe-area-inset-bottom) var(--safe-area-inset-left);
}

/* Mobile-only: Prevent iOS bounce scrolling - ONLY applies below 992px */
@media (max-width: 991.98px) {
  /* iOS Scroll Fix: Allow body to scroll naturally instead of fixed positioning */
  body {
    width: 100%;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Removed position:fixed and height:100vh that prevented scrolling */
  }

  /* Legacy .app-container support (if used) */
  .app-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    overflow-y: visible;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
}

/* Touch-Optimized Elements (EXCEPT checkboxes and radio buttons) */
button,
a,
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea,
.touchable {
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  padding: var(--space-sm) var(--space-md);
  user-select: none;
  -webkit-user-select: none;
}

/* Checkboxes and radio buttons - standard size, no forced minimum */
input[type="checkbox"],
input[type="radio"] {
  min-height: unset;
  min-width: unset;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

/* Mobile Buttons */
.btn-mobile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-target-ideal);
  padding: var(--space-sm) var(--space-lg);
  border-radius: 8px;
  font-weight: 500;
  transition: all var(--transition-fast) var(--easing-standard);
  position: relative;
  overflow: hidden;
}

.btn-mobile::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: var(--glass-bg-medium);
  transform: translate(-50%, -50%);
  transition: width var(--transition-base), height var(--transition-base);
}

.btn-mobile:active::after {
  width: 300px;
  height: 300px;
}

/* ============================================
   3. GRADIENT HEADER - NAVIGATION & COUNTERS
   ============================================ */

.mobile-gradient-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  overflow: hidden;
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  height: 90px;
}

.mobile-gradient-header.scrolled {
  height: 56px;
}

.header-gradient-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg,
    var(--dana-blue-dark) 0%,
    var(--dana-blue-medium) 50%,
    var(--dana-blue-light) 100%
  );
  background-image:
    linear-gradient(135deg,
      var(--dana-blue-dark) 0%,
      var(--dana-blue-medium) 50%,
      var(--dana-blue-light) 100%
    ),
    linear-gradient(180deg, var(--glass-bg-dark-subtle) 0%, transparent 100%);
}

.header-gradient-bg::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--glass-bg-light) 50%,
    transparent 100%
  );
}

.header-content {
  position: relative;
  z-index: 1;
  height: 100%;
  padding: env(safe-area-inset-top, 0) 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.header-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding-top: 8px;
}

.logo-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-gradient-header.scrolled .logo-brand {
  justify-content: flex-start;
  padding-left: 0.5rem;
}

.logo-brand img {
  height: 40px;
  width: 40px;
  object-fit: contain;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 2px 4px var(--glass-bg-dark-strong));
}

.mobile-gradient-header.scrolled .logo-brand img {
  height: 32px;
  width: 32px;
  opacity: 0;
  transform: scale(0.8);
}

.logo-brand-text {
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 2px var(--glass-bg-dark-medium);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-gradient-header.scrolled .logo-brand-text {
  font-size: 1rem;
}

/* Header Buttons */
.header-menu-btn,
.header-search-btn,
.header-create-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg-light);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-bg-medium);
  border-radius: 10px;
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px var(--glass-bg-dark-medium);
  text-decoration: none;
}

.header-menu-btn:active,
.header-search-btn:active,
.header-create-btn:active {
  transform: scale(0.95);
  background: var(--glass-bg-strong);
}

.header-menu-btn:hover,
.header-search-btn:hover,
.header-create-btn:hover {
  background: var(--glass-bg-medium);
  border-color: var(--glass-bg-strong);
  color: white;
  text-decoration: none;
}

.header-create-btn {
  background: var(--glass-bg-strong);
  font-size: 1.5rem;
  font-weight: 600;
}

.header-create-btn:active {
  background: var(--glass-bg-strong);
}

/* Status Summary Bar */
.header-stats-bar {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  padding: 0.5rem 0;
  opacity: 1;
  transform: translateY(0);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-gradient-header.scrolled .header-stats-bar {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

.header-stat-badge {
  background: var(--glass-bg-medium);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-bg-strong);
  padding: 0.4rem 0.75rem;
  border-radius: 20px;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  box-shadow: 0 2px 6px var(--glass-bg-dark-medium);
  transition: all 0.2s ease;
}

.header-stat-badge:active {
  transform: scale(0.95);
}

.header-stat-badge .stat-number {
  font-size: 0.85rem;
  font-weight: 700;
}

.header-stat-badge.stat-active .stat-number {
  color: var(--color-gold);
}

.header-stat-badge.stat-assigned .stat-number {
  color: var(--color-cyan);
}

.header-stat-badge.stat-completed .stat-number {
  color: var(--color-light-green);
}

.header-stat-badge.stat-unclosed .stat-number {
  color: var(--color-cyan);
}

.header-stat-badge.stat-unassigned .stat-number {
  color: var(--color-gold);
}

.header-stat-badge.stat-assigned-me .stat-number {
  color: var(--color-light-green);
}

.header-stat-badge.stat-all .stat-number {
  color: var(--color-gray-light);
}

/* Header User Role */
.header-user-role {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0) + 50px);
  right: 1rem;
  background: var(--glass-bg-light);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-bg-medium);
  padding: 0.35rem 0.65rem;
  border-radius: 12px;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 1;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px var(--glass-bg-dark-medium);
}

.mobile-gradient-header.scrolled .header-user-role {
  opacity: 0;
  transform: translateY(-5px);
}

/* Content Spacer */
.mobile-header-spacer {
  height: 20px;
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-gradient-header.scrolled ~ .mobile-header-spacer {
  height: 56px;
}

/* Shadow on Scroll */
.mobile-gradient-header::before {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 0;
  right: 0;
  height: 10px;
  background: linear-gradient(180deg, var(--glass-bg-dark-medium) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.mobile-gradient-header.scrolled::before {
  opacity: 1;
}

/* Admin Counters in Content Area */
.content-admin-counters {
  padding: 1rem 1rem 0;
  background: var(--color-white);
}

.counters-grid-2x2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  padding-bottom: 0.5rem;
}

.counter-pill {
  flex: 0 0 auto;
  background: linear-gradient(135deg, rgba(13, 71, 161, 0.08), rgba(25, 118, 210, 0.05));
  border: 1.5px solid rgba(13, 71, 161, 0.2);
  padding: 0.5rem 0.75rem;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 1px 3px var(--glass-bg-dark-light);
  transition: all 0.2s ease;
  min-width: fit-content;
}

.counter-pill:active {
  transform: scale(0.97);
  box-shadow: 0 1px 2px var(--glass-bg-dark-medium);
}

.counter-pill i {
  font-size: 0.9rem;
  opacity: 0.85;
}

.counter-pill .counter-number {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary) !important;
}

.counter-pill .counter-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary) !important;
  opacity: 1;
}

.counter-pill.counter-unclosed i,
.counter-pill.counter-unclosed .counter-number {
  color: var(--color-blue) !important;
}

.counter-pill.counter-unassigned i,
.counter-pill.counter-unassigned .counter-number {
  color: var(--color-orange) !important;
}

.counter-pill.counter-assigned-me i,
.counter-pill.counter-assigned-me .counter-number {
  color: var(--color-green) !important;
}

.counter-pill.counter-all i,
.counter-pill.counter-all .counter-number {
  color: var(--color-gray-medium) !important;
}

/* Mobile Menu */
.mobile-menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay-medium);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1029;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-menu-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.mobile-menu-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1031;
  padding-top: calc(env(safe-area-inset-top, 0) + 100px);
  max-height: 100vh;
  overflow-y: auto;
  transform: translateY(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu-container.show {
  transform: translateY(0);
}

.mobile-gradient-header.scrolled ~ .mobile-menu-container {
  padding-top: calc(env(safe-area-inset-top, 0) + 56px);
}

.mobile-menu-content {
  background: linear-gradient(180deg,
    var(--menu-bg-start) 0%,
    var(--menu-bg-end) 100%
  );
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 1rem;
  box-shadow: 0 8px 32px var(--overlay-medium);
}

.mobile-menu-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mobile-menu-item {
  display: flex !important;
  align-items: center !important;
  padding: 1rem 1.25rem !important;
  background: var(--glass-bg-light) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  border: 1px solid var(--glass-bg-medium) !important;
  border-radius: 12px !important;
  color: white !important;
  text-decoration: none !important;
  font-size: 1rem !important;
  font-weight: 500 !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 2px 8px var(--glass-bg-dark-medium) !important;
}

.mobile-menu-content .mobile-menu-items .mobile-menu-item {
  color: white !important;
}

.mobile-menu-item i {
  color: white !important;
  font-size: 1.1rem;
  width: 24px;
}

.mobile-menu-item:hover,
.mobile-menu-item:focus,
.mobile-menu-item:visited {
  background: var(--glass-bg-strong);
  border-color: var(--glass-bg-strong);
  color: white !important;
  text-decoration: none !important;
  transform: translateX(4px);
}

.mobile-menu-item:active {
  background: var(--glass-bg-strong);
  border-color: var(--glass-bg-strong);
  color: white !important;
  text-decoration: none !important;
  transform: scale(0.98) translateX(4px);
}

.mobile-menu-item.text-danger {
  background: var(--bs-danger-bg-subtle);
  border-color: var(--bs-danger-bg-subtle);
  color: var(--color-danger-light-text) !important;
}

.mobile-menu-item.text-danger:hover {
  background: var(--bs-danger-bg-subtle);
  border-color: var(--bs-danger-bg-subtle);
  color: white !important;
}

.mobile-menu-items hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--glass-bg-strong) 50%,
    transparent 100%
  );
  margin: 0.25rem 0;
}

/* ============================================
   4. FORMS - ENHANCED MOBILE FORMS
   ============================================ */

.mobile-enhanced-form {
  padding: var(--space-md);
}

.mobile-input-wrapper {
  position: relative;
  margin-bottom: var(--space-lg);
}

.mobile-input-wrapper input,
.mobile-input-wrapper textarea,
.mobile-input-wrapper select {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  font-size: 16px;
  border: 2px solid var(--bs-gray-300);
  border-radius: 12px;
  background: white;
  transition: all 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.mobile-input-wrapper.focused input,
.mobile-input-wrapper.focused textarea,
.mobile-input-wrapper.focused select {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 4px rgba(var(--bs-primary-rgb), 0.1);
}

.mobile-input-wrapper.has-error input,
.mobile-input-wrapper.has-error textarea {
  border-color: var(--bs-danger);
  background: var(--bs-danger-bg-subtle);
}

.mobile-input-wrapper.has-success input,
.mobile-input-wrapper.has-success textarea {
  border-color: var(--bs-success);
  background: var(--bs-success-bg-subtle);
}

/* Floating Labels */
.floating-label-group {
  position: relative;
  margin-bottom: var(--space-lg);
}

.floating-label-group label {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--bs-gray-600);
  pointer-events: none;
  transition: all 0.2s ease;
  background: white;
  padding: 0 4px;
}

.floating-label-group.has-value label,
.floating-label-group input:focus + label,
.floating-label-group textarea:focus + label,
.floating-label-group select:focus + label {
  top: 0;
  font-size: 12px;
  color: var(--bs-primary);
  font-weight: 500;
}

/* Clear Button */
.input-clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--bs-gray-500);
  padding: 4px;
  cursor: pointer;
  z-index: 2;
}

.input-clear-btn:hover {
  color: var(--bs-gray-700);
}

/* Character Counter */
.character-counter {
  position: absolute;
  right: 12px;
  bottom: -20px;
  font-size: 12px;
  color: var(--bs-gray-500);
}

.character-counter.warning {
  color: var(--bs-warning);
  font-weight: 500;
}

/* Validation Feedback */
.error-message {
  display: none;
  color: var(--bs-danger);
  font-size: 13px;
  margin-top: 4px;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.success-message {
  color: var(--bs-success);
  font-size: 13px;
  margin-top: 4px;
}

/* Drag & Drop Zone */
[data-drop-zone] {
  border: 2px dashed var(--bs-gray-400);
  border-radius: 12px;
  padding: var(--space-xl);
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

[data-drop-zone].drag-over {
  border-color: var(--bs-primary);
  background: var(--bs-primary-bg-subtle);
  transform: scale(1.02);
}

[data-drop-zone] .drop-icon {
  font-size: 48px;
  color: var(--bs-gray-400);
  margin-bottom: var(--space-md);
}

[data-drop-zone].drag-over .drop-icon {
  color: var(--bs-primary);
  animation: bounce 0.5s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* Submit Button */
.mobile-enhanced-form [type="submit"] {
  width: 100%;
  min-height: 52px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  background: var(--bs-primary);
  color: white;
  border: none;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.mobile-enhanced-form [type="submit"]:active {
  transform: scale(0.98);
}

.mobile-enhanced-form [type="submit"]:disabled {
  background: var(--bs-gray-400);
  cursor: not-allowed;
}

.mobile-enhanced-form [type="submit"]::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: var(--glass-bg-medium);
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
}

.mobile-enhanced-form [type="submit"]:active::after {
  width: 300px;
  height: 300px;
}

/* Keyboard Open State */
body.keyboard-open {
  padding-bottom: 300px;
}

body.keyboard-open .bottom-nav {
  display: none;
}

/* ============================================
   5. TYPOGRAPHY & BUTTONS
   ============================================ */

@media (max-width: 768px) {
  body {
    font-size: 16px;
    line-height: 1.5;
  }

  h1, .h1 { font-size: 1.75rem; }
  h2, .h2 { font-size: 1.5rem; }
  h3, .h3 { font-size: 1.25rem; }
  h4, .h4 { font-size: 1.125rem; }
  h5, .h5 { font-size: 1rem; }
  h6, .h6 { font-size: 0.9rem; }

  small, .small {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
  }

  p, .text-block {
    margin-bottom: 1rem;
    line-height: 1.6;
  }

  /* Enhanced Buttons */
  .btn {
    min-height: 48px;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.15s ease;
  }

  .btn:active {
    transform: scale(0.98);
  }

  .btn-sm {
    min-height: 44px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .btn-lg {
    min-height: 56px;
    padding: 1rem 1.5rem;
    font-size: 1.125rem;
  }
}

/* ============================================
   6. WORK ORDERS & CARDS
   ============================================ */

@media (max-width: 768px) {
  /* Form Controls */
  .form-control,
  .form-select {
    min-height: 48px;
    padding: 0.75rem;
    font-size: 16px;
    border-radius: 8px;
    border: 2px solid var(--border-medium);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }

  .form-control:focus,
  .form-select:focus {
    border-color: var(--focus-color);
    box-shadow: var(--focus-shadow);
  }

  .form-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
  }

  textarea.form-control {
    min-height: 120px;
    resize: vertical;
  }

  /* Cards */
  .card {
    border-radius: 12px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
  }

  .card-body {
    padding: 1.25rem;
  }

  .card-header {
    padding: 1rem 1.25rem;
    background-color: var(--background-muted);
    border-bottom: 1px solid var(--border-light);
    font-weight: 600;
  }

  /* Work Order Items */
  .work-order-item {
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background-color: var(--background-card);
    margin-bottom: 1rem;
    transition: all 0.2s ease;
    cursor: pointer;
  }

  .work-order-item:hover,
  .work-order-item:focus {
    border-color: var(--dana-blue-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
  }

  .work-order-item:active {
    transform: translateY(0) scale(0.98);
  }

  .work-order-item.active {
    border-color: var(--dana-blue-dark);
    background-color: var(--dana-blue-pale);
    box-shadow: var(--shadow-lg);
  }

  .work-order-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 0.75rem;
  }

  .work-order-meta {
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text-secondary);
  }

  /* Badges */
  .badge {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 6px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }

  .urgency-emergency,
  .urgency-1,
  .bg-dana-danger {
    background-color: var(--urgency-emergency-bg) !important;
    color: var(--urgency-emergency-text) !important;
    border: 1px solid rgba(114, 28, 36, 0.3);
  }

  /* Tables */
  .table-responsive {
    border-radius: 12px;
    border: 1px solid var(--border-light);
  }

  .table tr {
    background-color: var(--background-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
  }

  .table td::before {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.875rem;
  }

  .table td {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
  }

  .table td:last-child {
    border-bottom: none;
  }

  /* Spacing */
  .container,
  .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .section {
    margin-bottom: 2rem;
  }

  .list-group-item {
    padding: 1rem 1.25rem;
    border-radius: 8px !important;
    margin-bottom: 0.5rem;
  }

  /* Accessibility */
  *:focus {
    outline-width: 3px;
    outline-offset: 3px;
  }

  .skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--dana-blue-dark);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 9999;
  }

  .skip-link:focus {
    top: 6px;
  }

  .invalid-feedback,
  .alert {
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-weight: 500;
  }

  .alert-danger {
    background-color: var(--color-danger-bg);
    border-color: var(--color-danger);
    color: var(--color-danger);
  }

  .alert-warning {
    background-color: var(--color-warning-bg);
    border-color: var(--color-warning);
    color: var(--color-warning);
  }

  .alert-info {
    background-color: var(--color-info-bg);
    border-color: var(--color-info);
    color: var(--color-info);
  }

  .alert-success {
    background-color: var(--color-success-bg);
    border-color: var(--color-success);
    color: var(--color-success);
  }
}

/* ============================================
   7. CAMERA & FILE INPUT
   ============================================ */

.camera-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay-dark);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-interface {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 600px;
  max-height: 800px;
}

#camera-stream {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.camera-controls {
  position: absolute;
  bottom: 30px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  padding: 0 20px;
}

.camera-capture {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: white;
  border: 4px solid var(--glass-bg-strong);
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.camera-capture:active {
  transform: scale(0.9);
}

.capture-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--bs-danger);
  transition: all 0.2s ease;
}

.camera-capture:hover .capture-ring {
  width: 55px;
  height: 55px;
}

.camera-switch,
.camera-close {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--glass-bg-medium);
  backdrop-filter: blur(10px);
  border: 2px solid var(--glass-bg-strong);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.camera-switch:hover,
.camera-close:hover {
  background: var(--glass-bg-strong);
  transform: scale(1.1);
}

.camera-preview {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: black;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#captured-image {
  max-width: 100%;
  max-height: 70%;
  object-fit: contain;
  border-radius: 8px;
}

.preview-controls {
  position: absolute;
  bottom: 30px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 0 20px;
}

/* File Input & Preview */
.camera-input-wrapper {
  margin-bottom: var(--space-lg);
}

.camera-button-group {
  display: flex;
  gap: 12px;
  margin-bottom: var(--space-md);
}

.camera-btn,
.gallery-btn {
  flex: 1;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.camera-preview-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-top: var(--space-md);
}

.image-preview-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bs-gray-100);
  aspect-ratio: 1;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, var(--overlay-dark), transparent);
  color: white;
  padding: 8px;
  font-size: 11px;
}

.preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: var(--overlay-light);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preview-remove:hover {
  background: var(--bs-danger);
  color: white;
  transform: scale(1.1);
}

/* ============================================
   8. LAZY LOADING
   ============================================ */

.lazy-loading,
.lazy-placeholder {
  background: linear-gradient(90deg,
    var(--bs-gray-200) 0%,
    var(--bs-gray-100) 50%,
    var(--bs-gray-200) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

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

.lazy-loaded {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lazy-error {
  background: var(--bs-danger-bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bs-danger);
  min-height: 200px;
}

.lazy-bg-loading {
  background: var(--bs-gray-100);
  position: relative;
}

.lazy-bg-loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--glass-bg-strong) 50%,
    transparent 100%);
  animation: shimmer 1.5s ease-in-out infinite;
}

.component-loading {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bs-gray-50);
  border-radius: 8px;
}

.component-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bs-gray-300);
  border-top-color: var(--bs-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.component-error-message {
  color: var(--bs-danger);
  text-align: center;
  padding: var(--space-lg);
}

/* ============================================
   9. RESPONSIVE & ACCESSIBILITY
   ============================================ */

/* Small phones */
@media (max-width: 374px) {
  .logo-brand-text {
    font-size: 1rem;
  }

  .header-stat-badge {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
  }

  .counter-pill {
    padding: 0.45rem 0.65rem;
  }

  .counter-pill .counter-number {
    font-size: 0.95rem;
  }

  .counter-pill .counter-label {
    font-size: 0.65rem;
  }
}

/* Large phones and tablets */
@media (min-width: 768px) and (max-width: 991.98px) {
  .mobile-gradient-header {
    height: 110px;
  }

  .mobile-gradient-header.scrolled {
    height: 64px;
  }

  .mobile-header-spacer {
    height: 25px;
  }

  .mobile-gradient-header.scrolled ~ .mobile-header-spacer {
    height: 64px;
  }

  .counters-grid-2x2 {
    gap: 0.85rem;
  }

  .counter-pill {
    padding: 0.6rem 0.9rem;
  }

  .counter-pill .counter-number {
    font-size: 1.1rem;
  }

  .counter-pill .counter-label {
    font-size: 0.75rem;
  }
}

/* Desktop - hide mobile elements */
@media (min-width: 992px) {
  .mobile-gradient-header,
  .mobile-header-spacer {
    display: none;
  }
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .mobile-gradient-header,
  .logo-brand,
  .logo-brand img,
  .logo-brand-text,
  .header-stats-bar,
  .counter-pill,
  .header-user-role,
  .header-menu-btn,
  .header-search-btn,
  .mobile-header-spacer,
  .btn,
  .btn-mobile,
  .work-order-item,
  .camera-capture,
  .camera-switch,
  .camera-close,
  .preview-remove,
  .lazy-loading,
  .lazy-placeholder,
  .lazy-loaded,
  .component-spinner {
    transition: none !important;
    animation: none !important;
  }
}

/* Accessibility: High Contrast */
@media (prefers-contrast: high) {
  .header-gradient-bg {
    background: var(--dana-blue-dark);
  }

  .header-menu-btn,
  .header-search-btn,
  .header-stat-badge,
  .counter-pill,
  .header-user-role {
    border-width: 2px;
    background: var(--glass-bg-strong);
  }

  .card,
  .work-order-item,
  .image-preview-item {
    border: 2px solid var(--color-black);
  }
}

/* Utility Classes */
.touch-none { pointer-events: none; }
.touch-auto { pointer-events: auto; }
.select-none { user-select: none; -webkit-user-select: none; }
.select-text { user-select: text; -webkit-user-select: text; }
.scroll-smooth { scroll-behavior: smooth; }
.scroll-auto { scroll-behavior: auto; }
.overscroll-none { overscroll-behavior: none; }
.overscroll-contain { overscroll-behavior: contain; }

.desktop-only {
  display: none !important;
}

.safe-top { padding-top: var(--safe-area-inset-top); }
.safe-bottom { padding-bottom: var(--safe-area-inset-bottom); }
.safe-left { padding-left: var(--safe-area-inset-left); }
.safe-right { padding-right: var(--safe-area-inset-right); }
