/* CSS Variables */
:root {
  --primary-color: #0d6efd;
  --secondary-color: #0a58ca;
  --accent-color: #0dcaf0;
  --light-bg: #f8f9fa;
  --dark-bg: #084298;
  --border-color: #e9ecef;
}

/* Base Styles */
body {
  background-color: var(--light-bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.container {
  padding: 1rem 0;
}

/* Accessibility */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.sr-only-focusable:focus {
  position: static !important;
  width: auto !important;
  height: auto !important;
  padding: inherit !important;
  margin: inherit !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Skip to main content link */
.sr-only-focusable:focus {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 9999;
  padding: 0.5rem 1rem;
  background-color: var(--primary-color);
  color: white;
  text-decoration: none;
  border-radius: 0 0 4px 0;
}

/* Focus styles for better accessibility */
*:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Touch Device Optimizations */
.touch-device {
  /* Improve touch scrolling */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.touch-device .btn,
.touch-device .nav-link,
.touch-device .list-group-item {
  /* Ensure minimum touch target size */
  min-height: 44px;
  min-width: 44px;
}

.touch-device .card {
  /* Add subtle touch feedback */
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.touch-device .card:active {
  transform: scale(0.98);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
  /* Improve text readability on mobile */
  body {
    font-size: 16px; /* Prevent zoom on iOS */
    line-height: 1.5;
  }
  
  /* Optimize touch targets */
  .btn,
  .nav-link,
  .list-group-item,
  .dropdown-item {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 0.35em; /* Prevent icon+text from touching when flex collapses whitespace */
  }
  
  /* Improve scrolling performance */
  .table-responsive {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  
  /* Optimize form elements */
  select,
  input,
  textarea {
    font-size: 16px; /* Prevent zoom on iOS */
  }
  
  /* Improve modal and dropdown positioning */
  .dropdown-menu {
    max-height: 50vh;
    overflow-y: auto;
  }
  
  /* Optimize chart containers */
  #statusChart,
  #categoryChart,
  #countryChart {
    touch-action: manipulation;
  }
}

/* High DPI Display Optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .card {
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  }
  
  #map {
    border-width: 0.5px;
  }
  
  .btn {
    border-width: 0.5px;
  }
}

/* Landscape Mobile Optimizations */
@media (max-width: 768px) and (orientation: landscape) {
  .navbar {
    padding: 0.25rem 0;
  }
  
  .navbar-brand {
    font-size: 1rem;
  }
  
  #map {
    height: 250px;
  }
  
  #statusChart,
  #categoryChart,
  #countryChart {
    height: 150px !important;
  }
  
  .card-body {
    padding: 0.5rem;
  }
}

/* TomSelect Customization */
.ts-dropdown {
  text-align: left;
}

.ts-wrapper {
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.ts-wrapper .ts-control {
  border-radius: 6px;
  padding: 0.5rem;
}

/* Mobile TomSelect optimizations */
@media (max-width: 768px) {
  .ts-wrapper .ts-control {
    min-height: 44px;
    padding: 0.75rem;
    font-size: 16px;
  }
  
  .ts-dropdown {
    max-height: 200px;
    overflow-y: auto;
  }
  
  .ts-dropdown .option {
    padding: 0.75rem;
    min-height: 44px;
  }
}

/* Google Charts Tooltip */
.google-visualization-tooltip {
  pointer-events: none;
  border-radius: 6px !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

/* Mobile chart optimizations */
@media (max-width: 768px) {
  .google-visualization-tooltip {
    font-size: 12px;
    max-width: 200px;
  }
}

/* Animations */
@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: translateY(10px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

.tab-pane {
  animation: fadeIn 0.3s ease-out;
}

/* Loading states for mobile */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--primary-color);
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Print styles */
@media print {
  .navbar,
  .btn-group,
  #clearFilters,
  .sticky-card {
    display: none !important;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  #map {
    height: 400px;
    page-break-inside: avoid;
  }
  
  #trialsTable {
    font-size: 12px;
  }
  
  .container {
    max-width: none;
    padding: 0;
  }
}

/* Map fullscreen control (matches Leaflet zoom bar) */
.leaflet-control-fullscreen {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-size: 1rem;
  text-decoration: none;
  color: #333;
}
.leaflet-control-fullscreen:hover {
  color: #000;
} 