/* ============================================
   MOBILE-FIRST NATIVE APP CSS
   Makes the site feel like a native mobile app
   ============================================ */

/* ============================================
   1. MOBILE-FIRST BASE RESET
   ============================================ */

/* Prevent text size adjustment on orientation change */
html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Improve touch scrolling */
  -webkit-overflow-scrolling: touch;
}

/* Native app-like body */
body {
  /* Prevent overscroll bounce */
  overscroll-behavior: none;
  /* Improve text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Prevent pull-to-refresh on mobile */
  overscroll-behavior-y: contain;
}

/* Disable user selection on interactive elements for app-like feel */
button,
.btn,
.nav-link,
.sidebar-link,
[role="button"] {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ============================================
   2. TOUCH-FRIENDLY SIZING (2.75rem minimum)
   ============================================ */

/* All clickable elements should be at least 44x2.75rem */
button,
.btn,
input[type="submit"],
input[type="button"],
input[type="reset"],
a.btn,
.nav-link,
.dropdown-item,
.list-group-item-action {
  min-height: 2.75rem;
  min-width: 2.75rem;
}

/* Primary Buttons - Large touch targets */
.btn {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--brand-radius-md, 0.75rem);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  line-height: 1.4;
  /* Prevent double-tap zoom */
  touch-action: manipulation;
}

/* Button size variants */
.btn-sm {
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  min-height: 2.5rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
  min-height: 3.25rem;
}

/* Full-width buttons on mobile */
.btn-block,
.btn-mobile-full {
  width: 100%;
}

/* Icon-only buttons */
.btn-icon {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--brand-radius-md, 0.75rem);
}

.btn-icon-sm {
  width: 2.25rem;
  height: 2.25rem;
  font-size: 0.875rem;
}

.btn-icon-lg {
  width: 3.25rem;
  height: 3.25rem;
  font-size: 1.25rem;
}

/* ============================================
   3. NATIVE APP-LIKE INPUTS
   ============================================ */

/* Form controls - Larger touch targets */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
textarea,
select,
.form-control,
.form-select {
  min-height: 3rem;
  padding: 0.75rem 1rem;
  font-size: 1rem; /* Prevents iOS zoom on focus */
  border-radius: var(--brand-radius-md, 0.75rem);
  border: 0.125rem solid var(--brand-grey-300, #dcdcdc);
  background-color: var(--brand-white, #fff);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  /* Remove default iOS styling */
  -webkit-appearance: none;
  appearance: none;
}

/* Input focus state - App-like highlight */
input:focus,
textarea:focus,
select:focus,
.form-control:focus,
.form-select:focus {
  border-color: var(--brand-primary, #f7c000);
  box-shadow: 0 0 0 0.25rem rgba(247, 192, 0, 0.15);
  outline: none;
}

/* Select dropdown arrow */
select,
.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23555' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1rem 0.75rem;
  padding-right: 2.5rem;
}

/* Textarea */
textarea,
textarea.form-control {
  min-height: 7.5rem;
  resize: vertical;
}

/* Search input with icon */
.search-input-wrapper {
  position: relative;
}

.search-input-wrapper input {
  padding-left: 2.75rem;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--brand-grey-500, #888);
  pointer-events: none;
}

/* Checkbox and Radio - Larger touch targets */
input[type="checkbox"],
input[type="radio"] {
  width: 1.5rem;
  height: 1.5rem;
  margin-right: 0.75rem;
  cursor: pointer;
  accent-color: var(--brand-primary, #f7c000);
}

.form-check {
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  padding-left: 0;
}

.form-check-input {
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0;
  margin-right: 0.75rem;
  flex-shrink: 0;
}

.form-check-label {
  font-size: 1rem;
  line-height: 1.4;
  cursor: pointer;
}

/* ============================================
   4. NATIVE APP TYPOGRAPHY
   ============================================ */

/* Mobile-optimized font sizes */
h1, .h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

h2, .h2 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.625rem;
}

h3, .h3 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

h4, .h4 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.5rem;
}

h5, .h5, h6, .h6 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.375rem;
}

/* Body text */
p, .body-text {
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

/* Small text */
small, .text-small, .text-sm {
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Extra small text */
.text-xs {
  font-size: 0.75rem;
  line-height: 1.4;
}

/* ============================================
   5. NATIVE APP CARDS
   ============================================ */

.card,
.app-card {
  background: var(--brand-white, #fff);
  border-radius: var(--brand-radius-lg, 1.125rem);
  border: none;
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.06);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-body,
.app-card-body {
  padding: 1.25rem;
}

.card-header,
.app-card-header {
  padding: 1rem 1.25rem;
  background: var(--brand-grey-100, #fafafa);
  border-bottom: 1px solid var(--brand-grey-200, #f0f0f0);
  font-weight: 600;
}

.card-footer,
.app-card-footer {
  padding: 1rem 1.25rem;
  background: var(--brand-grey-100, #fafafa);
  border-top: 1px solid var(--brand-grey-200, #f0f0f0);
}

/* Tappable card */
.card-tappable,
.app-card-tappable {
  cursor: pointer;
  touch-action: manipulation;
}

.card-tappable:active,
.app-card-tappable:active {
  transform: scale(0.98);
  box-shadow: 0 1px 0.25rem rgba(0, 0, 0, 0.08);
}

/* ============================================
   6. NATIVE APP NAVIGATION
   ============================================ */

/* Bottom navigation bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4rem;
  background: var(--brand-white, #fff);
  border-top: 1px solid var(--brand-grey-200, #f0f0f0);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 0.5rem;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 1000;
  box-shadow: 0 -0.125rem 0.625rem rgba(0, 0, 0, 0.05);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 4rem;
  min-height: 3rem;
  padding: 0.5rem;
  color: var(--brand-grey-500, #888);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  transition: color 0.2s ease;
  touch-action: manipulation;
}

.bottom-nav-item i {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.bottom-nav-item.active,
.bottom-nav-item:active {
  color: var(--brand-primary, #f7c000);
}

.bottom-nav-item.active i {
  transform: scale(1.1);
}

/* Top app bar */
.app-bar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 3.5rem;
  background: var(--brand-white, #fff);
  border-bottom: 1px solid var(--brand-grey-200, #f0f0f0);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  z-index: 1000;
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.04);
}

.app-bar-title {
  flex: 1;
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
  text-align: center;
}

.app-bar-action {
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-grey-700, #333);
  border-radius: var(--brand-radius-md, 0.75rem);
  transition: background 0.2s ease;
}

.app-bar-action:active {
  background: var(--brand-grey-100, #fafafa);
}

/* ============================================
   7. LIST ITEMS (Native App Style)
   ============================================ */

.list-item,
.app-list-item {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  min-height: 3.5rem;
  background: var(--brand-white, #fff);
  border-bottom: 1px solid var(--brand-grey-200, #f0f0f0);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
  touch-action: manipulation;
}

.list-item:active,
.app-list-item:active {
  background: var(--brand-grey-100, #fafafa);
}

.list-item-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--brand-radius-md, 0.75rem);
  background: var(--brand-grey-100, #fafafa);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 1rem;
  flex-shrink: 0;
  color: var(--brand-primary, #f7c000);
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--brand-grey-800, #1f1f1f);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-subtitle {
  font-size: 0.875rem;
  color: var(--brand-grey-500, #888);
  margin: 0.125rem 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-action {
  margin-left: 0.75rem;
  color: var(--brand-grey-400, #b0b0b0);
}

/* ============================================
   8. STATUS BADGES & CHIPS
   ============================================ */

.badge,
.app-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6.25rem;
  line-height: 1;
  white-space: nowrap;
}

.chip,
.app-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6.25rem;
  background: var(--brand-grey-100, #fafafa);
  color: var(--brand-grey-700, #333);
  border: 1px solid var(--brand-grey-300, #dcdcdc);
  min-height: 2.25rem;
  touch-action: manipulation;
}

.chip.active,
.app-chip.active {
  background: var(--brand-primary, #f7c000);
  color: var(--brand-grey-800, #1f1f1f);
  border-color: var(--brand-primary, #f7c000);
}

.chip-closable {
  padding-right: 0.5rem;
}

.chip-close {
  width: 1.25rem;
  height: 1.25rem;
  margin-left: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  font-size: 0.75rem;
}

/* ============================================
   9. FLOATING ACTION BUTTON (FAB)
   ============================================ */

.fab {
  position: fixed;
  bottom: 5rem; /* Above bottom nav */
  right: 1rem;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-primary, #f7c000) 0%, var(--brand-primary-dark, #f4c20d) 100%);
  color: var(--brand-grey-800, #1f1f1f);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 0.25rem 1rem rgba(247, 192, 0, 0.4);
  border: none;
  cursor: pointer;
  z-index: 999;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  touch-action: manipulation;
}

.fab:active {
  transform: scale(0.95);
  box-shadow: 0 0.125rem 0.5rem rgba(247, 192, 0, 0.3);
}

.fab-extended {
  width: auto;
  border-radius: 1.75rem;
  padding: 0 1.5rem;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

/* ============================================
   10. PULL-TO-REFRESH INDICATOR
   ============================================ */

.pull-indicator {
  position: absolute;
  top: -3.75rem;
  left: 50%;
  transform: translateX(-50%);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--brand-white, #fff);
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.pull-indicator.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(3.75rem);
}

.pull-indicator .spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 0.1875rem solid var(--brand-grey-200, #f0f0f0);
  border-top-color: var(--brand-primary, #f7c000);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================
   11. MODAL & BOTTOM SHEET
   ============================================ */

/* Bottom sheet (native app-like modal) */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--brand-white, #fff);
  border-radius: 1.5rem 1.5rem 0 0;
  box-shadow: 0 -0.25rem 1.5rem rgba(0, 0, 0, 0.12);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1050;
  max-height: 90vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-sheet.show {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 2.5rem;
  height: 0.25rem;
  background: var(--brand-grey-300, #dcdcdc);
  border-radius: 0.125rem;
  margin: 0.75rem auto;
}

.bottom-sheet-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--brand-grey-200, #f0f0f0);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bottom-sheet-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
}

.bottom-sheet-body {
  padding: 1.5rem;
}

/* Modal backdrop */
.modal-backdrop-app {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1040;
}

.modal-backdrop-app.show {
  opacity: 1;
}

/* ============================================
   12. TOAST NOTIFICATIONS
   ============================================ */

.toast-container-app {
  position: fixed;
  bottom: 5rem; /* Above bottom nav */
  left: 1rem;
  right: 1rem;
  z-index: 1100;
  pointer-events: none;
}

.toast-app {
  background: var(--brand-grey-800, #1f1f1f);
  color: var(--brand-white, #fff);
  padding: 1rem 1.25rem;
  border-radius: var(--brand-radius-md, 0.75rem);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.2);
  transform: translateY(6.25rem);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: auto;
}

.toast-app.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-app.success {
  background: #059669;
}

.toast-app.error {
  background: #dc2626;
}

.toast-app.warning {
  background: #d97706;
}

/* ============================================
   13. LOADING STATES
   ============================================ */

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg,
    var(--brand-grey-100, #fafafa) 0%,
    var(--brand-grey-200, #f0f0f0) 50%,
    var(--brand-grey-100, #fafafa) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--brand-radius-sm, 0.5rem);
}

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

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-text-sm {
  height: 0.75rem;
}

.skeleton-avatar {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
}

.skeleton-card {
  height: 7.5rem;
}

/* Full page loading */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner-lg {
  width: 3rem;
  height: 3rem;
  border: 0.25rem solid var(--brand-grey-200, #f0f0f0);
  border-top-color: var(--brand-primary, #f7c000);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================
   14. SAFE AREA SPACING
   ============================================ */

/* Account for notch/safe areas on iOS */
.safe-area-top {
  padding-top: env(safe-area-inset-top, 0);
}

.safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.safe-area-left {
  padding-left: env(safe-area-inset-left, 0);
}

.safe-area-right {
  padding-right: env(safe-area-inset-right, 0);
}

/* Content area with bottom nav */
.has-bottom-nav {
  padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0));
}

/* ============================================
   15. GESTURE HINTS
   ============================================ */

/* Swipeable indicator */
.swipe-hint {
  position: relative;
}

.swipe-hint::after {
  content: '';
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 2.5rem;
  height: 0.25rem;
  background: var(--brand-grey-300, #dcdcdc);
  border-radius: 0.125rem;
}

/* ============================================
   16. TABLET ENHANCEMENTS (48rem+)
   ============================================ */

@media (min-width: 768px) {
  /* Larger typography */
  h1, .h1 { font-size: 2rem; }
  h2, .h2 { font-size: 1.75rem; }
  h3, .h3 { font-size: 1.5rem; }
  h4, .h4 { font-size: 1.25rem; }

  /* Wider cards */
  .card-body, .app-card-body {
    padding: 1.5rem;
  }

  /* Side-by-side buttons */
  .btn-group-mobile {
    display: flex;
    gap: 1rem;
  }

  .btn-group-mobile .btn {
    flex: 1;
  }

  /* Larger FAB */
  .fab {
    width: 4rem;
    height: 4rem;
    font-size: 1.75rem;
    right: 1.5rem;
    bottom: 1.5rem;
  }

  /* Grid layouts */
  .card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  /* Bottom sheet max width */
  .bottom-sheet {
    max-width: 30rem;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border-radius: 1.5rem 1.5rem 0 0;
  }

  .bottom-sheet.show {
    transform: translateX(-50%) translateY(0);
  }
}

/* ============================================
   17. DESKTOP ENHANCEMENTS (62rem+)
   ============================================ */

@media (min-width: 992px) {
  /* Hide bottom nav on desktop */
  .bottom-nav {
    display: none;
  }

  .has-bottom-nav {
    padding-bottom: 0;
  }

  /* Hover states for desktop */
  .btn:hover {
    transform: translateY(-0.125rem);
    box-shadow: var(--brand-shadow-md, 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1));
  }

  .card:hover,
  .app-card:hover {
    transform: translateY(-0.25rem);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.1);
  }

  .list-item:hover,
  .app-list-item:hover {
    background: var(--brand-grey-100, #fafafa);
  }

  /* 3-column grid */
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }

  /* FAB position */
  .fab {
    right: 2rem;
    bottom: 2rem;
  }
}

/* ============================================
   18. ANIMATION UTILITIES
   ============================================ */

/* Tap feedback */
.tap-feedback {
  position: relative;
  overflow: hidden;
}

.tap-feedback::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.1);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tap-feedback:active::after {
  opacity: 1;
}

/* Slide animations */
.slide-up {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(1.25rem);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.slide-in-right {
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from {
    transform: translateX(1.25rem);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Fade animations */
.fade-in {
  animation: fadeIn 0.2s ease-out;
}

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

/* Scale animation for buttons/cards */
.scale-on-tap:active {
  transform: scale(0.97);
}

/* ============================================
   19. ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 0.1875rem solid var(--brand-primary, #f7c000);
  outline-offset: 0.125rem;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .btn {
    border: 0.125rem solid currentColor;
  }

  input,
  textarea,
  select {
    border-width: 0.1875rem;
  }
}

/* ============================================
   20. LIGHT MODE ONLY
   Dark mode disabled - site uses light theme exclusively
   ============================================ */
