/*
 * VinSnap Mobile Optimization CSS
 * Add this to your main stylesheet or include separately
 */

/* ============================================
   MOBILE-FIRST BASE STYLES
   ============================================ */

/* Better touch targets (minimum 44x44px) - WCAG 2.1 Level AAA */
button,
a,
input,
select,
.clickable,
.btn,
.btn-icon,
.btn-ghost,
.btn-link,
.mobile-nav-item,
[role="button"],
.card {
  min-height: 44px;
  min-width: 44px;
}

/* Ensure minimum padding for touch targets on smaller components */
.btn-icon,
.btn-ghost,
.btn-link {
  min-height: 44px !important;
  min-width: 44px !important;
}

/* Links and text elements need minimum touch target */
a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* Prevent text size adjustment on orientation change */
html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Better tap highlighting */
* {
  -webkit-tap-highlight-color: rgba(139, 92, 246, 0.2);
}

/* Remove 300ms click delay on mobile */
a, button, input, select, textarea {
  touch-action: manipulation;
}

/* ============================================
   SAFE AREA INSETS (iPhone notch, etc.)
   ============================================ */

body {
  /* Safe-area for notched devices only */
  padding-top: max(0px, env(safe-area-inset-top));
  padding-bottom: max(0px, env(safe-area-inset-bottom));
  padding-left: max(0px, env(safe-area-inset-left));
  padding-right: max(0px, env(safe-area-inset-right));
}

/* Additional safe-area handling for specific elements */
@supports (padding: max(0px)) {
  .safe-area-top {
    padding-top: max(16px, env(safe-area-inset-top));
  }

  .safe-area-bottom {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .safe-area-left {
    padding-left: max(16px, env(safe-area-inset-left));
  }

  .safe-area-right {
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

/* ============================================
   PWA MODE SPECIFIC STYLES
   ============================================ */

.pwa-mode {
  /* Hide browser UI elements when in PWA mode */
}

.pwa-mode .desktop-only {
  display: none !important;
}

/* ============================================
   RESPONSIVE CONTAINERS
   ============================================ */

.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding-left: 8px;
  padding-right: 8px;
}

@media (min-width: 768px) {
  .container {
    padding-left: 24px;
    padding-right: 24px;
  }
}

@media (min-width: 1024px) {
  .container {
    padding-left: 32px;
    padding-right: 32px;
  }
}

/* ============================================
   MOBILE NAVIGATION
   ============================================ */

/* Bottom navigation for mobile (better thumb reach) */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card, #1a2332);
  border-top: 1px solid var(--border-color, #334155);
  /* Fallback padding for devices without safe-area support */
  padding: 8px 0;
  padding-bottom: 8px;
  /* Modern safe-area support with max() for fallback */
  padding-bottom: max(8px, calc(8px + env(safe-area-inset-bottom)));
  z-index: 1000;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
  /* Ensure minimum height for touch targets */
  min-height: 60px;
  /* Hardware acceleration */
  will-change: transform;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

@media (max-width: 768px) {
  .mobile-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
  }

  /* Hide desktop sidebar on mobile */
  .sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: var(--sidebar-bg, #1a2332);
    transition: left 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 999;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-right: 1px solid var(--border-color, #334155);
  }

  /* Show sidebar when toggled */
  .sidebar.visible {
    left: 0;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.5);
  }

  /* Hamburger menu button - hidden on mobile (bottom nav handles navigation) */
  .sidebar-toggle,
  #sidebarToggle {
    display: none !important;
  }

  .sidebar-toggle:active,
  #sidebarToggle:active {
    background: rgba(139, 92, 246, 0.3);
    transform: scale(0.95);
  }

  /* Backdrop when sidebar is visible */
  .sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    opacity: 0;
    pointer-events: none;
    z-index: 997;
    transition: background-color 0.3s ease, opacity 0.3s ease;
    backdrop-filter: blur(0px);
  }

  .sidebar-backdrop.visible {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 1;
    pointer-events: auto;
  }

  /* Always show header action buttons on mobile */
  .garage-header-actions {
    display: flex !important;
    gap: 0.75rem;
    flex-direction: column;
    width: 100%;
  }

  /* Full-width buttons for mobile touch targets */
  .garage-header-actions button {
    width: 100%;
    min-height: 44px;
    padding: 0.75rem 1rem;
  }

  /* Adjust main content for bottom nav */
  .main-content {
    padding-bottom: 80px;
    padding-top: 0;
  }

  /* Adjust main content when sidebar is visible */
  .sidebar.visible ~ .main-content {
    margin-left: 0;
  }

  /* Disable card hover effects on mobile to prevent layout shift */
  .card:hover {
    transform: none;
  }

  /* Disable service card hover effects on mobile */
  .service-record-card:hover {
    transform: none;
  }
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  color: var(--text-secondary, #94a3b8);
  text-decoration: none;
  transition: all 0.2s ease;
  border-radius: 8px;
  min-width: 60px;
}

.mobile-nav-item:active {
  background: rgba(139, 92, 246, 0.1);
  transform: scale(0.95);
}

.mobile-nav-item.active {
  color: var(--accent-purple, #8b5cf6);
}

.mobile-nav-icon {
  font-size: 24px;
}

.mobile-nav-label {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

/* ============================================
   FLOATING ACTION BUTTON (FAB)
   ============================================ */

.mobile-nav-item.fab {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  padding: 0;
  background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4),
              0 8px 24px rgba(59, 130, 246, 0.2);
  transform: translateY(-12px);
  z-index: 1001;
  border: 3px solid var(--primary-bg, #070c16);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  cursor: pointer;
  min-width: auto;
  font-size: 28px;
  color: white;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mobile-nav-item.fab:active {
  transform: translateY(-12px) scale(0.92);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.mobile-nav-item.fab:hover:not(:active) {
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5),
              0 10px 28px rgba(59, 130, 246, 0.25);
}

.mobile-nav-item.fab .mobile-nav-icon {
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-nav-item.fab .mobile-nav-icon svg {
  width: 28px;
  height: 28px;
  stroke: white;
  stroke-width: 2.5;
  fill: none;
}

.mobile-nav-item.fab .mobile-nav-label {
  display: none;
}

/* ============================================
   MOBILE NAVIGATION BADGES
   ============================================ */

.mobile-nav-item {
  position: relative;
}

.mobile-nav-item .nav-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  white-space: nowrap;
  display: none;
  animation: badgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  transition: all 0.2s ease;
}

.nav-badge.badge-count {
  background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
  color: white;
  font-weight: 700;
}

.nav-badge.badge-new {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
  font-weight: 700;
  border: 1px solid rgba(34, 197, 94, 0.5);
}

.nav-badge.badge-alert {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  font-weight: 700;
  border: 1px solid rgba(239, 68, 68, 0.5);
  animation: badgePulse 1.5s ease-in-out infinite, badgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.nav-badge.badge-beta {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  font-weight: 700;
  border: 1px solid rgba(245, 158, 11, 0.5);
}

@keyframes badgePop {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes badgePulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.15);
  }
}

/* ============================================
   MOBILE-OPTIMIZED CARDS
   ============================================ */

.card {
  background: var(--bg-card, #1a2332);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border-color, #334155);
}

@media (min-width: 768px) {
  .card {
    padding: 24px;
    border-radius: 16px;
  }
}

/* ============================================
   MOBILE-FRIENDLY FORMS
   ============================================ */

input,
select,
textarea {
  font-size: 16px; /* Prevents zoom on iOS */
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color, #334155);
  background: var(--bg-secondary, #111827);
  color: var(--text-primary, #f1f5f9);
  width: 100%;
  transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-purple, #8b5cf6);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Input focus state */
input.input-focused,
textarea.input-focused,
select.input-focused {
  border-color: var(--accent-purple, #8b5cf6);
  background: var(--input-bg, #0a101c);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}

/* Input valid state */
input.input-valid,
textarea.input-valid {
  border-color: var(--accent-green, #22d3a6);
  background: rgba(34, 211, 166, 0.05);
}

/* Input invalid/error state */
input.input-error,
input.input-invalid,
textarea.input-error,
textarea.input-invalid {
  border-color: var(--accent-red, #f87171);
  background: rgba(248, 113, 113, 0.05);
}

/* Input disabled state */
input.input-disabled,
textarea.input-disabled,
select.input-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg-secondary, #111827);
}

/* Error message styling */
.input-error-message {
  display: none;
  font-size: 12px;
  color: var(--accent-red, #f87171);
  margin-top: 4px;
  padding: 0 4px;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Larger text inputs on mobile - Prevents iOS auto-zoom on focus */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  input[type="url"],
  input[type="search"],
  textarea,
  select {
    font-size: 16px !important; /* Critical: prevents zoom on iOS */
  }
}

/* Override all relative font-sizes on inputs for iOS compatibility */
input,
textarea,
select {
  font-size: 16px !important;
}

/* Ensure input fields don't scale below 16px anywhere */
@media (max-width: 375px) {
  input,
  textarea,
  select {
    font-size: 16px !important;
    min-height: 44px !important;
    padding: 12px 16px !important;
  }
}

/* ============================================
   FONT SIZE OPTIMIZATION FOR SMALL SCREENS
   ============================================ */

@media (max-width: 375px) {
  /* Reduce heading sizes slightly */
  h1 {
    font-size: 1.75rem;
    line-height: 1.2;
  }

  h2 {
    font-size: 1.4rem;
    line-height: 1.3;
  }

  h3 {
    font-size: 1.1rem;
    line-height: 1.4;
  }

  h4,
  h5,
  h6 {
    font-size: 1rem;
  }

  /* Adjust body font size */
  body {
    font-size: 14px;
    line-height: 1.5;
  }

  /* Optimize button text */
  .btn,
  button {
    font-size: 14px;
    padding: 10px 16px;
    min-height: 40px;
  }

  /* Small badge and label optimizations */
  .badge,
  .label,
  .tag {
    font-size: 0.7rem;
    padding: 0.375rem 0.75rem;
  }

  /* Card and container padding */
  .card {
    padding: 1rem;
  }

  /* Reduce spacing */
  .mb-1,
  .mt-1 { margin: 4px 0; }
  .mb-2,
  .mt-2 { margin: 8px 0; }
  .mb-3,
  .mt-3 { margin: 12px 0; }

  /* Smaller icons */
  .icon-small {
    font-size: 1.25rem;
  }

  .icon-medium {
    font-size: 1.5rem;
  }

  .icon-large {
    font-size: 2rem;
  }

  /* Modal adjustments */
  .modal-content {
    padding: 1rem;
  }

  .modal-header {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
  }

  .modal-body {
    font-size: 0.9rem;
  }

  /* Form field label */
  .input-label {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
  }

  .input-hint {
    font-size: 0.75rem;
  }
}

/* ============================================
   MOBILE-OPTIMIZED BUTTONS
   ============================================ */

.btn {
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
  color: white;
}

.btn-secondary {
  background: var(--bg-secondary, #111827);
  color: var(--text-primary, #f1f5f9);
  border: 1px solid var(--border-color, #334155);
}

.btn-full {
  width: 100%;
}

@media (max-width: 768px) {
  .btn {
    padding: 14px 20px;
    font-size: 16px;
  }

  /* Make buttons full-width on mobile */
  .btn-mobile-full {
    width: 100%;
  }
}

/* ============================================
   MOBILE-OPTIMIZED MODALS
   ============================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card, #1a2332);
  border-radius: 16px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.3s ease;
}

@media (max-width: 768px) {
  .modal-content {
    max-height: 95vh;
    border-radius: 16px 16px 0 0;
    margin-top: auto;
  }

  /* Slide up from bottom on mobile */
  .modal {
    align-items: flex-end;
    padding: 0;
  }
}

/* ============================================
   BOTTOM SHEET COMPONENT
   ============================================ */

.bottom-sheet-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  z-index: 9998;
  transition: background-color 0.3s ease, backdrop-filter 0.3s ease;
  opacity: 0;
}

.bottom-sheet-backdrop.active {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  opacity: 1;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card, #1a2332);
  border-radius: 20px 20px 0 0;
  z-index: 9999;
  max-height: 95vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  -webkit-transform: translateY(100%);
  -webkit-transition: -webkit-transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.bottom-sheet.active {
  transform: translateY(0);
  -webkit-transform: translateY(0);
}

.bottom-sheet.bottom-sheet-half {
  max-height: 50vh;
}

.bottom-sheet.bottom-sheet-full {
  max-height: 100vh;
  border-radius: 0;
}

.bottom-sheet-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bottom-sheet-drag-handle {
  flex-shrink: 0;
  padding: 12px 0;
  display: flex;
  justify-content: center;
  cursor: grab;
  user-select: none;
}

.bottom-sheet-drag-handle:active {
  cursor: grabbing;
}

.drag-indicator {
  width: 32px;
  height: 4px;
  background: var(--border-color, #334155);
  border-radius: 2px;
  opacity: 0.5;
}

.bottom-sheet-header {
  flex-shrink: 0;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color, #334155);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.bottom-sheet-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary, #f1f5f9);
  flex: 1;
}

.bottom-sheet-close {
  background: none;
  border: none;
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
  min-width: 44px;
  min-height: 44px;
}

.bottom-sheet-close:active {
  background: rgba(139, 92, 246, 0.1);
  transform: scale(0.95);
}

.bottom-sheet-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bottom-sheet-footer {
  flex-shrink: 0;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color, #334155);
  display: flex;
  gap: 12px;
  padding-bottom: max(16px, calc(16px + env(safe-area-inset-bottom)));
}

.bottom-sheet-btn {
  flex: 1;
  padding: 12px 24px;
  border-radius: 8px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-sheet-btn:active {
  transform: scale(0.97);
}

.bottom-sheet-btn-cancel {
  background: var(--bg-secondary, #111827);
  color: var(--text-primary, #f1f5f9);
  border: 1px solid var(--border-color, #334155);
}

.bottom-sheet-btn-cancel:active {
  background: rgba(139, 92, 246, 0.1);
}

.bottom-sheet-btn-confirm {
  background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
  color: white;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ============================================
   QUICK ACTIONS COMPONENT
   ============================================ */

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 8px 0;
}

@media (min-width: 500px) {
  .quick-actions-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  background: var(--bg-secondary, #111827);
  border: 1px solid var(--border-color, #334155);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 120px;
  font-family: inherit;
  font-weight: 600;
}

.quick-action-btn:active {
  transform: scale(0.95);
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--accent-purple, #8b5cf6);
}

.action-icon {
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 8px;
}

.action-icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--accent-purple, #8b5cf6);
  fill: none;
}

.action-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary, #f1f5f9);
  text-align: center;
}

.action-description {
  font-size: 11px;
  color: var(--text-secondary, #94a3b8);
  font-weight: 400;
  text-align: center;
}

/* Vehicle Selector List */
.vehicle-selector-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}

.vehicle-selector-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-secondary, #111827);
  border: 1px solid var(--border-color, #334155);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-align: left;
}

.vehicle-selector-item:active {
  transform: scale(0.98);
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--accent-purple, #8b5cf6);
}

.vehicle-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.vehicle-name {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary, #f1f5f9);
  font-size: 15px;
}

.vehicle-nickname {
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
  font-weight: 400;
}

/* ============================================
   CAMERA/FILE INPUT OPTIMIZATION
   ============================================ */

.file-input-wrapper {
  position: relative;
  overflow: hidden;
  display: inline-block;
  width: 100%;
}

.file-input-wrapper input[type="file"] {
  position: absolute;
  left: -9999px;
}

.file-input-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
  color: white;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
  min-height: 56px;
}

.file-input-label:active {
  transform: scale(0.98);
}

.camera-icon {
  font-size: 24px;
}

/* ============================================
   VIN SCANNER MOBILE OPTIMIZATION
   ============================================ */

.vin-scanner {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scanner-frame {
  width: 80%;
  height: 40%;
  border: 3px solid #8b5cf6;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
  position: relative;
}

.scanner-corners {
  position: absolute;
  width: 100%;
  height: 100%;
}

.scanner-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 3px solid #8b5cf6;
}

.scanner-corner.top-left {
  top: -3px;
  left: -3px;
  border-right: none;
  border-bottom: none;
}

.scanner-corner.top-right {
  top: -3px;
  right: -3px;
  border-left: none;
  border-bottom: none;
}

.scanner-corner.bottom-left {
  bottom: -3px;
  left: -3px;
  border-right: none;
  border-top: none;
}

.scanner-corner.bottom-right {
  bottom: -3px;
  right: -3px;
  border-left: none;
  border-top: none;
}

/* ============================================
   LOADING STATES
   ============================================ */

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color, #334155);
  border-top-color: var(--accent-purple, #8b5cf6);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary, #111827) 0%,
    var(--bg-card, #1a2332) 50%,
    var(--bg-secondary, #111827) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ============================================
   LAZY LOADING
   ============================================ */

/* Image lazy loading states */
img[data-lazy-src] {
  background: linear-gradient(
    90deg,
    var(--bg-secondary, #111827) 0%,
    var(--bg-card, #1a2332) 50%,
    var(--bg-secondary, #111827) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  min-height: 100px;
}

img[data-lazy-src].lazy-loading {
  opacity: 0.5;
}

img[data-lazy-src].lazy-loaded {
  animation: fadeIn 0.3s ease;
  background: none;
}

img[data-lazy-src].lazy-error {
  background: var(--bg-secondary, #111827);
  opacity: 0.5;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Picture element lazy loading */
picture img[data-lazy-src] {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

/* ============================================
   SWIPE GESTURES
   ============================================ */

.swipeable {
  touch-action: pan-y;
  user-select: none;
}

/* ============================================
   PULL TO REFRESH
   ============================================ */

.pull-to-refresh {
  position: absolute;
  top: -60px;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary, #94a3b8);
  transition: transform 0.3s ease;
}

.pull-to-refresh.pulling {
  transform: translateY(60px);
}

.pull-to-refresh-indicator {
  position: absolute;
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary, #94a3b8);
  transition: transform 0.3s ease;
  pointer-events: none;
}

.pull-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-purple, #8b5cf6);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.pull-icon svg {
  width: 100%;
  height: 100%;
  stroke: var(--accent-purple, #8b5cf6);
}

.pull-to-refresh-indicator.ready .pull-icon {
  color: var(--accent-purple, #8b5cf6);
}

.pull-to-refresh-indicator.refreshing .pull-icon {
  animation: spin 0.8s linear infinite;
}

.pull-text {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.pull-to-refresh-indicator.ready .pull-text {
  opacity: 1;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card, #1a2332);
  color: var(--text-primary, #f1f5f9);
  padding: 12px 24px;
  border-radius: 50px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 10000;
  animation: slideUp 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  max-width: 90%;
  text-align: center;
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
}

/* ============================================
   MOBILE GRID LAYOUTS
   ============================================ */

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid-sm-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .grid-md-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-md-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid-lg-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  .grid-lg-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only {
    display: block;
  }
  .desktop-only {
    display: none;
  }
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.p-4 { padding: 32px; }

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--accent-purple, #8b5cf6);
  outline-offset: 2px;
}

/* Skip to main content */
.skip-to-main {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--accent-purple, #8b5cf6);
  color: white;
  padding: 12px 24px;
  z-index: 10001;
  transition: top 0.2s ease;
}

.skip-to-main:focus {
  top: 0;
}

/* Screen reader only content */
.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;
}

/* ============================================
   HARDWARE ACCELERATION FOR ANIMATIONS
   ============================================ */

/* GPU acceleration for smooth animations on mobile */
.btn,
.btn:active {
  will-change: transform;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.mobile-nav-item,
.mobile-nav-item:active {
  will-change: transform, background-color;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.modal,
.modal-content {
  will-change: opacity, transform;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Optimize scrolling performance */
[style*="overflow-y: auto"],
.scrollable {
  will-change: scroll-position;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-overflow-scrolling: touch;
}

/* Smooth transitions for interactive elements */
a,
button,
.clickable {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* ============================================
   CRITICAL FIX: 320PX DEVICE COMPATIBILITY
   ============================================ */

@media (max-width: 360px) {
  /* Fix grid overflow on ultra-small devices (320px) */
  .grid,
  [class*="grid-"],
  [style*="display: grid"] {
    grid-template-columns: 1fr !important;
  }

  /* Force minmax to use single column on 320px */
  [style*="repeat(auto"] {
    grid-template-columns: 1fr !important;
  }

  /* Ensure cards stack vertically */
  .card {
    width: 100%;
    margin-right: 0;
  }

  /* Fix padding on ultra-small screens */
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* Reduce font sizes slightly */
  body {
    font-size: 14px;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  h3 {
    font-size: 1.1rem;
  }
}

/* ============================================
   MORE MENU COMPONENT
   ============================================ */

.more-menu-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}

.more-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-secondary, #111827);
  border: 1px solid var(--border-color, #334155);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-align: left;
  font-weight: 500;
}

.more-menu-item:active {
  transform: scale(0.98);
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--accent-purple, #8b5cf6);
}

.menu-icon {
  font-size: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 8px;
}

.menu-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--accent-purple, #8b5cf6);
  fill: none;
}

.menu-label {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #f1f5f9);
}

.menu-chevron {
  font-size: 20px;
  flex-shrink: 0;
  color: var(--text-secondary, #94a3b8);
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-chevron svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-secondary, #94a3b8);
  fill: none;
}

.menu-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.5);
}

/* About content styling */
.about-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 0;
}

.about-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 12px;
}

.about-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary, #f1f5f9);
}

.about-version {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
  font-weight: 500;
}

.about-description {
  font-size: 14px;
  color: var(--text-primary, #f1f5f9);
  line-height: 1.6;
  margin: 0;
  padding: 0 16px;
}

.about-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}

.about-links a {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-secondary, #111827);
  border: 1px solid var(--border-color, #334155);
  border-radius: 12px;
  color: var(--accent-purple, #8b5cf6);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
  min-height: 44px;
}

.about-links a:active {
  transform: scale(0.98);
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--accent-purple, #8b5cf6);
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .no-print,
  .mobile-nav,
  .sidebar,
  button,
  .btn {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .card {
    border: 1px solid #000;
    break-inside: avoid;
  }
}
