/* Mobile-specific styles for Barcode Validator App */

/* Touch-friendly interface */
@media (max-width: 768px) {
  /* Ensure minimum touch target size of 44px */
  .btn,
  .nav-link,
  .form-control,
  .tab-pane button {
    min-height: 44px;
    min-width: 44px;
  }

  /* Larger tap targets for primary actions */
  .btn-lg {
    min-height: 56px;
    font-size: 1.1rem;
    padding: 1rem 1.5rem;
  }

  /* Navigation adjustments */
  .navbar {
    padding: 0.75rem 0;
  }

  .navbar-brand {
    font-size: 1.1rem;
  }

  .nav-link {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }

  /* Content spacing */
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .content-section {
    padding-top: 1rem;
    padding-bottom: 2rem;
  }

  /* Home section mobile optimizations */
  #home-section .col-6 {
    margin-bottom: 1rem;
  }

  /* Results table mobile optimizations */
  .compact-validation-table {
    table-layout: fixed;
    width: 100% !important;
    max-width: 100vw;
  }

  .compact-validation-table th,
  .compact-validation-table td {
    white-space: normal !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    line-height: 1.3 !important;
    padding: 0.25rem !important;
    vertical-align: top !important;
  }

  .table-responsive {
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent horizontal scrolling */
  body {
    overflow-x: hidden;
  }

  #home-section .btn-lg {
    min-height: 100px;
    border-radius: 12px;
  }

  #home-section .btn-lg i {
    font-size: 1.5rem;
  }

  /* Image preview mobile adjustments */
  #image-preview {
    margin: 1rem 0;
  }

  #preview-img {
    max-height: 250px;
    border-radius: 8px;
  }

  /* Processing indicator mobile */
  #processing-indicator {
    padding: 2rem 1rem;
    margin: 1rem 0;
  }

  /* Results container mobile */
  #results-container {
    margin-top: 1rem;
  }

  /* Settings mobile optimizations */
  .nav-tabs {
    border-bottom: none;
    margin-bottom: 1rem;
  }

  .nav-tabs .nav-link {
    border-radius: 6px;
    margin: 0 0.25rem 0.5rem 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  .tab-content {
    padding: 0;
  }

  .tab-pane {
    padding: 1rem 0;
  }

  /* Form mobile adjustments */
  .form-control {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.75rem;
  }

  .form-label {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
  }

  .settings-form {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  /* History mobile optimizations */
  .history-item {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
  }

  .history-item h6 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }

  .history-item p {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
  }

  /* Help section mobile */
  #help-section .card {
    margin-bottom: 1rem;
  }

  #help-section .card-body {
    padding: 1rem;
  }

  /* Modal mobile adjustments */
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }

  .modal-content {
    border-radius: 12px;
  }

  .modal-header {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-footer {
    padding: 1rem;
    border-top: 1px solid #dee2e6;
  }

  /* Camera modal specific */
  #cameraModal .modal-dialog {
    max-width: 100%;
    height: 100%;
    margin: 0;
  }

  #cameraModal .modal-content {
    height: 100%;
    border-radius: 0;
  }

  #camera-video {
    width: 100%;
    height: auto;
    max-height: 60vh;
    object-fit: cover;
  }

  /* Scanning overlay mobile */
  .scanning-frame {
    width: 180px;
    height: 100px;
    margin: 1rem auto;
  }

  /* Alert mobile adjustments */
  .alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
  }

  /* Badge mobile sizing */
  .badge {
    font-size: 0.7rem;
    padding: 0.4rem 0.6rem;
  }

  /* Spinner mobile */
  .spinner-border {
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 576px) {
  /* Even more compact spacing */
  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  /* Navigation for small screens */
  .navbar-brand {
    font-size: 1rem;
  }

  .navbar-brand i {
    font-size: 1rem;
  }

  /* Home section extra small */
  #home-section h1 {
    font-size: 1.75rem;
  }

  #home-section p {
    font-size: 0.9rem;
  }

  #home-section .btn-lg {
    min-height: 90px;
    font-size: 0.9rem;
  }

  #home-section .btn-lg i {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
  }

  /* Settings tabs extra small */
  .nav-tabs .nav-link {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
  }

  /* Form extra small */
  .form-control {
    padding: 0.6rem;
  }

  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }

  /* History extra small */
  .history-item {
    padding: 0.75rem;
  }

  .history-item h6 {
    font-size: 0.95rem;
  }

  .history-item p {
    font-size: 0.85rem;
  }

  /* Modal extra small */
  .modal-header h5 {
    font-size: 1.1rem;
  }

  .modal-body {
    padding: 0.75rem;
  }

  .modal-footer {
    padding: 0.75rem;
  }

  .modal-footer .btn {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
  }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
  .content-section {
    padding-top: 0.5rem;
    padding-bottom: 1rem;
  }

  #home-section .btn-lg {
    min-height: 80px;
  }

  #camera-video {
    max-height: 50vh;
  }

  .scanning-frame {
    width: 160px;
    height: 90px;
  }
}

/* iOS specific adjustments */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari specific styles */
  .form-control {
    font-size: 16px; /* Prevents zoom */
    border-radius: 8px;
  }

  .btn {
    border-radius: 8px;
  }

  /* iOS safe area adjustments */
  .navbar {
    padding-top: env(safe-area-inset-top, 0.5rem);
  }

  .content-section {
    padding-bottom: env(safe-area-inset-bottom, 1rem);
  }
}

/* Android specific adjustments */
@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: 0.001dpcm) {
  /* Android Chrome specific styles */
  .form-control:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Sharper borders and shadows for retina displays */
  .card {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  }

  .btn {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  }

  .alert {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  }
}

/* Dark mode support (if device prefers dark) */
@media (prefers-color-scheme: dark) {
  /* This will be implemented later if needed */
  /* For now, we'll stick with light theme */
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .scanning-frame::before {
    animation: none;
  }
}
