/* Mobile-Responsive Design */

@media (max-width: 768px) {
  html,
  body,
  #app {
    min-height: 100%;
    height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Layout adjustments */
  .shell {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .app-brand-banner {
    flex-shrink: 0;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
  }

  .app-brand-copy h1 {
    display: none;
  }

  .app-brand-copy .eyebrow {
    margin: 0;
    letter-spacing: 0.08em;
  }

  .app-brand-meta {
    gap: 8px;
  }

  .shell-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
  }

  /* Bottom tab navigation */
  .tab-navigation,
  .tab-bar.is-mobile {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background: var(--card-background);
    border-top: 1px solid var(--border-subtle);
    z-index: 100;
    height: 60px;
    padding: 8px 0;
  }

  .tab-button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    min-height: 44px;
    position: relative;
  }

  .tab-button:hover {
    color: var(--primary-color);
  }

  .tab-button.active,
  .tab-button.is-active {
    color: var(--primary-color);
    font-weight: 700;
  }

  .tab-button.active::after,
  .tab-button.is-active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-color);
  }

  .tab-icon {
    font-size: 24px;
  }

  .tab-label {
    font-size: 11px;
  }

  /* Add padding to content to avoid overlap with bottom nav */
  .tab-content,
  .shell {
    padding-bottom: 60px;
  }

  /* Cards and spacing */
  .card {
    margin: 8px;
    border-radius: 12px;
    padding: 12px;
  }

  .card-elevated {
    margin: 8px;
    border-radius: 12px;
    padding: 12px;
  }

  .card-highlighted {
    margin: 8px;
    border-radius: 12px;
    padding: 12px;
  }

  /* Buttons */
  .btn-primary,
  .btn-secondary,
  .btn-urgent,
  .btn-ready {
    width: 100%;
    min-height: 44px;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
  }

  /* Modal adjustments */
  .modal-overlay {
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* List items - full width touch targets */
  .list-item {
    min-height: 50px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-subtle);
  }

  .list-item:active {
    background: rgba(0, 122, 255, 0.05);
  }

  /* Form inputs */
  input[type='text'],
  input[type='password'],
  input[type='email'],
  input[type='number'],
  textarea,
  select {
    width: 100%;
    min-height: 44px;
    padding: 12px;
    font-size: 16px;
    border: 1px solid var(--border-medium);
    border-radius: 12px;
  }

  /* Headers */
  h1 {
    font-size: 24px;
    font-weight: 700;
  }

  h2 {
    font-size: 20px;
    font-weight: 700;
  }

  h3 {
    font-size: 16px;
    font-weight: 700;
  }

  /* Typography sizing */
  p {
    font-size: 14px;
    line-height: 1.5;
  }

  .text-small {
    font-size: 12px;
  }

  .text-large {
    font-size: 16px;
  }

  /* Alert handling */
  .alert-preview {
    min-height: 50px;
    padding: 12px;
    margin: 4px 0;
  }

  /* Badge adjustments */
  .badge {
    font-size: 12px;
    padding: 4px 8px;
  }

  /* Sidebar to tab conversion */
  .sidebar {
    display: none !important;
  }

  .main-content {
    width: 100%;
  }

  /* Tab icon styling */
  .tab-button span {
    word-break: break-word;
    width: 100%;
  }

  /* Tab label abbreviations */
  .tab-button[data-tab="autospeech"]::before {
    content: '??';
    display: block;
    font-size: 20px;
  }

  .tab-button[data-tab="advisor"]::before {
    content: '??';
    display: block;
    font-size: 20px;
  }

  .tab-button[data-tab="walkthrough"]::before {
    content: '??';
    display: block;
    font-size: 20px;
  }

  .tab-button[data-tab="technician"]::before {
    content: '??';
    display: block;
    font-size: 20px;
  }

  .tab-button[data-tab="communication"]::before {
    content: '??';
    display: block;
    font-size: 20px;
  }

  .tab-button[data-tab="finance"]::before {
    content: '??';
    display: block;
    font-size: 20px;
  }

  .tab-button[data-tab="recon"]::before {
    content: '??';
    display: block;
    font-size: 20px;
  }

  .tab-button[data-tab="loaner"]::before {
    content: '??';
    display: block;
    font-size: 20px;
  }

  .tab-button[data-tab="parts"]::before {
    content: '??';
    display: block;
    font-size: 20px;
  }

  .tab-button[data-tab="reporting"]::before {
    content: '??';
    display: block;
    font-size: 20px;
  }

  .tab-button[data-tab="admin"]::before {
    content: '??';
    display: block;
    font-size: 20px;
  }

  /* Prevent horizontal scroll */
  body,
  html {
    overflow-x: hidden;
  }

  /* Ensure images are responsive */
  img {
    max-width: 100%;
    height: auto;
  }

  /* Touch-friendly spacing */
  .panel {
    margin: 8px;
    padding: 16px;
  }

  .panel-actions {
    gap: 8px;
    display: flex;
    flex-direction: column;
  }

  .panel-actions button {
    width: 100%;
  }
}

/* Extra large mobile (landscape) */
@media (max-width: 1024px) and (orientation: landscape) {
  .tab-navigation {
    height: 50px;
  }

  .tab-button {
    min-height: 50px;
  }

  .tab-content {
    padding-bottom: 50px;
  }

  .modal {
    max-height: 95vh;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  html,
  body,
  #app {
    min-height: 100%;
    height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .shell {
    min-height: 100dvh;
    height: auto;
    overflow: visible;
  }

  .card {
    padding: 14px;
  }

  .btn-primary,
  .btn-secondary,
  .btn-urgent,
  .btn-ready {
    padding: 12px 22px;
  }
}

/* Ensure proper display on all devices */
@supports (padding: max(0px)) {
  .safe-area-top {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .safe-area-bottom {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .tab-navigation {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
}

/* Walkaround Tab Styles */
@media (max-width: 768px) {
  [data-test-id="walkaround-header"] {
    background: linear-gradient(135deg, #0066cc 0%, #004499 100%);
    color: white;
    padding: 1.25rem 1rem;
    border-radius: 0;
    font-size: 18px;
    font-weight: bold;
    letter-spacing: -0.5px;
  }

  [data-appt-id],
  [data-ro-id] {
    background: #f9fafb;
    padding: 0.875rem;
    border-left: 4px solid #0066cc;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 0.75rem;
  }

  [data-appt-id]:hover,
  [data-ro-id]:hover {
    background-color: #f3f4f6;
    box-shadow: 0 4px 6px rgba(0, 102, 204, 0.1);
  }

  [data-appt-id]:active,
  [data-ro-id]:active {
    background-color: #e5e7eb;
  }

  .appointment-card {
    background: #f9fafb;
    padding: 0.875rem;
    border-left: 4px solid #0066cc;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 0.75rem;
  }

  .appointment-card:hover {
    background-color: #f3f4f6;
    box-shadow: 0 4px 6px rgba(0, 102, 204, 0.1);
  }

  .appointment-card:active {
    background-color: #e5e7eb;
  }
}

/* Walkaround Camera Styles */
.walkaround-camera-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
}

.walkaround-camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.walkaround-camera-timer {
  color: white;
  font-size: 14px;
  text-align: center;
  opacity: 0.7;
}

.walkaround-camera-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.walkaround-record-button {
  background: #ff0000;
  color: white;
  border: none;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.walkaround-record-button:hover:not(:disabled) {
  opacity: 0.9;
}

.walkaround-record-button:active:not(:disabled) {
  transform: scale(0.95);
}

.walkaround-record-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.walkaround-close-button {
  background: #ddd;
  color: #333;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.walkaround-close-button:hover {
  background-color: #bbb;
}

.walkaround-close-button:active {
  background-color: #999;
}

/* Camera Permission Error Styles */
.camera-permission-error {
  color: #d32f2f;
  padding: 1rem;
  text-align: center;
}

.camera-permission-button {
  margin-top: 1rem;
  background: #0066cc;
  color: white;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* Walkaround Review Screen Styles */
.walkaround-review-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 0;
}

.walkaround-review-video-container {
  width: 100%;
  background: #000000;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  margin-bottom: 1rem;
}

.walkaround-review-video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.walkaround-review-info {
  padding: 1.5rem 1rem;
  background: #fff;
  flex: 1;
  overflow-y: auto;
}

.walkaround-review-title {
  margin: 0 0 1rem 0;
  font-size: 20px;
  font-weight: 700;
  color: #333;
}

.walkaround-review-duration {
  margin: 0.5rem 0;
  font-size: 14px;
  color: #666;
}

.walkaround-review-file-size {
  margin: 0.5rem 0;
  font-size: 14px;
  color: #666;
}

.walkaround-review-attach-note {
  margin: 1rem 0 0 0;
  font-size: 12px;
  color: #999;
  font-style: italic;
}

.walkaround-review-buttons {
  display: flex;
  flex-direction: row;
  gap: 0;
  padding: 1rem 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
}

.walkaround-review-keep-btn,
.walkaround-review-rerecord-btn {
  flex: 1;
  padding: 14px 20px;
  min-height: 48px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.walkaround-review-keep-btn {
  background: #4CAF50;
  color: white;
  border-radius: 0;
}

.walkaround-review-keep-btn:hover {
  opacity: 0.9;
}

.walkaround-review-keep-btn:active {
  transform: scale(0.98);
}

.walkaround-review-rerecord-btn {
  background: #888888;
  color: white;
  border-radius: 0;
}

.walkaround-review-rerecord-btn:hover {
  opacity: 0.9;
}

.walkaround-review-rerecord-btn:active {
  transform: scale(0.98);
}
