/* Mobile-first approach */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prevent zoom on iOS */
input, select, textarea {
  font-size: 16px !important;
}

/* Touch-friendly tap targets (min 44px) */
button, a, input[type="submit"] {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Bottom navigation (thumb-friendly) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: white;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 1000;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 8px;
  text-decoration: none;
  color: #6b7280;
  transition: color 0.2s;
}

.bottom-nav a.active {
  color: #3b82f6;
}

/* Safe area for notch devices */
.safe-area-top {
  padding-top: env(safe-area-inset-top);
}

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

/* Content spacing for bottom nav */
.main-content {
  padding-bottom: 80px;
}

/* Responsive table */
@media (max-width: 640px) {
  .responsive-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Swipeable cards */
.swipeable {
  touch-action: pan-y;
}

/* Pull to refresh indicator */
.pull-to-refresh {
  position: fixed;
  top: -50px;
  left: 0;
  right: 0;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  transition: top 0.3s;
}

.pull-to-refresh.active {
  top: 0;
}

/* Loading spinner */
.spinner {
  border: 3px solid #f3f4f6;
  border-top: 3px solid #3b82f6;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Offline indicator */
.offline-indicator {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: #ef4444;
  color: white;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 14px;
  z-index: 1001;
  display: none;
}

.offline-indicator.show {
  display: block;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Print styles */
@media print {
  .print:hidden, .no-print {
    display: none !important;
  }
  
  body {
    background: white;
  }
  
  @page {
    margin: 2cm;
  }
}

/* Mobile optimization for 320px - 428px */
@media (min-width: 320px) and (max-width: 428px) {
  /* Ensure text is readable */
  body {
    font-size: 14px;
  }
  
  /* Optimize form inputs */
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important;
    padding: 12px;
  }
  
  /* Optimize buttons */
  button {
    padding: 12px 16px;
    font-size: 16px;
  }
  
  /* Optimize cards */
  .card {
    padding: 16px;
    margin-bottom: 16px;
  }
  
  /* Optimize tables */
  table {
    font-size: 12px;
  }
  
  /* Optimize spacing */
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
}
