@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Global styles for Oasis Ocean Conservation Platform */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'liga' 1, 'kern' 1;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 
               'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 
               'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

#root {
  min-height: 100vh;
  width: 100%;
}

/* Ocean theme CSS custom properties */

:root {
  /* Ocean colors */
  --ocean-primary: #00bcd4;
  --ocean-primary-light: #4dd0e1;
  --ocean-primary-dark: #00838f;
  --ocean-secondary: #ff6b35;
  --ocean-secondary-light: #ff8a65;
  --ocean-secondary-dark: #d84315;
  
  /* Ocean backgrounds */
  --ocean-bg-primary: #001122;
  --ocean-bg-secondary: #001a26;
  --ocean-bg-tertiary: #003344;
  
  /* Ocean surface effects */
  --ocean-surface: rgba(0, 188, 212, 0.1);
  --ocean-depth: rgba(0, 17, 34, 0.9);
  --ocean-bubble: rgba(77, 208, 225, 0.2);
  
  /* Land colors */
  --land-primary: #8bc34a;
  --land-secondary: #795548;
  --land-bg-primary: #1a2e1a;
  --land-bg-secondary: #1e2f1e;
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-xxl: 48px;
  
  /* Border radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
  
  /* Ocean-specific shadows */
  --ocean-shadow-sm: 0 2px 8px rgba(0, 188, 212, 0.1);
  --ocean-shadow-md: 0 4px 16px rgba(0, 188, 212, 0.15);
  --ocean-shadow-lg: 0 8px 32px rgba(0, 188, 212, 0.2);
}

/* Scrollbar styling for ocean theme */

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--ocean-bg-secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--ocean-primary), var(--ocean-primary-dark));
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--ocean-primary-light), var(--ocean-primary));
}

/* Focus styles for accessibility */

*:focus {
  outline: 2px solid var(--ocean-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Selection styling */

::selection {
  background: var(--ocean-primary);
  color: white;
}

::-moz-selection {
  background: var(--ocean-primary);
  color: white;
}

/* Utility classes */

.ocean-gradient {
  background: linear-gradient(135deg, #001122 0%, #002244 50%, #003366 100%);
}

.land-gradient {
  background: linear-gradient(135deg, #1a2e1a 0%, #2e4a2e 50%, #1a2e1a 100%);
}

.glass-effect {
  background: rgba(0, 26, 38, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(77, 208, 225, 0.1);
}

.water-ripple {
  position: relative;
  overflow: hidden;
}

.water-ripple::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(77, 208, 225, 0.2), transparent);
  animation: ripple 2s infinite;
}

@keyframes ripple {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Loading animations */

.ocean-pulse {
  animation: oceanPulse 2s ease-in-out infinite;
}

@keyframes oceanPulse {
  0%, 100% {
    opacity: 0.6;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

.wave-animation {
  animation: wave 3s ease-in-out infinite;
}

@keyframes wave {
  0%, 100% {
    transform: translateY(0px);
  }
  25% {
    transform: translateY(-10px);
  }
  50% {
    transform: translateY(-5px);
  }
  75% {
    transform: translateY(-15px);
  }
}

/* Responsive breakpoints */

@media (max-width: 768px) {
  :root {
    --spacing-xs: 2px;
    --spacing-sm: 4px;
    --spacing-md: 8px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;
    --spacing-xxl: 32px;
  }
}

/* Print styles */

@media print {
  * {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  .no-print {
    display: none !important;
  }
}

/* High contrast mode support */

@media (prefers-contrast: high) {
  :root {
    --ocean-primary: #00ffff;
    --ocean-secondary: #ff4500;
    --ocean-bg-primary: #000000;
    --ocean-bg-secondary: #111111;
  }
}

/* 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;
    scroll-behavior: auto !important;
  }
  
  .water-ripple::before,
  .ocean-pulse,
  .wave-animation {
    animation: none !important;
  }
}

/* Dark mode adjustments */

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
  }
}

/* Cesium controls positioning fixes */

.cesium-viewer .cesium-viewer-toolbar {
  top: auto !important;
  bottom: 10px !important;
  right: 10px !important;
  left: auto !important;
}

.cesium-viewer .cesium-viewer-bottom {
  bottom: 10px !important;
}

/* Mobile and landscape specific Cesium adjustments */

@media (max-width: 768px), (orientation: landscape) and (max-height: 600px) {
  .cesium-viewer .cesium-viewer-toolbar {
    bottom: 60px !important;
    right: 10px !important;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  
  .cesium-viewer .cesium-viewer-toolbar > .cesium-toolbar-button {
    margin: 0 !important;
  }
  
  .cesium-viewer .cesium-viewer-bottom {
    bottom: 5px !important;
    left: 5px !important;
    right: auto !important;
  }
  
  .cesium-viewer .cesium-widget-credits {
    display: none !important;
  }
  
  /* Move scene mode picker (2D/3D toggle) */
  .cesium-sceneModePicker-wrapper {
    position: absolute !important;
    bottom: 120px !important;
    right: 10px !important;
    top: auto !important;
    left: auto !important;
  }
  
  /* Ensure FAB doesn't overlap */
  .cesium-viewer .cesium-viewer-toolbar {
    margin-bottom: 80px !important;
  }
}

/* Landscape-specific adjustments */

@media (orientation: landscape) and (max-height: 600px) {
  .cesium-viewer .cesium-viewer-toolbar {
    right: 70px !important;
    bottom: 10px !important;
  }
  
  .cesium-sceneModePicker-wrapper {
    bottom: 10px !important;
    right: 130px !important;
  }
}

/* Fix for overlapping controls */

.cesium-viewer {
  position: relative !important;
}

.cesium-viewer .cesium-viewer-cesiumWidgetContainer {
  position: absolute !important;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Mobile UI Fixes for Biodiversity Tracker and Navigation */

@media (max-width: 768px) {
  /* Fix bottom navigation positioning */
  .MuiBottomNavigation-root {
    z-index: 1300 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: rgba(0, 17, 34, 0.95) !important;
    backdropFilter: blur(10px) !important;
    /* Ensure clickability */
    pointer-events: auto !important;
    touch-action: manipulation !important;
  }
  
  /* Fix drawer position to not cover bottom nav */
  .MuiDrawer-paperAnchorBottom {
    max-height: calc(100vh - 56px) !important;
    bottom: 56px !important;
  }
  
  /* BiodiversityTracker specific tabs positioning */
  .biodiversity-mobile-tabs {
    position: fixed !important;
    bottom: 56px !important; /* Above main bottom nav */
    left: 0 !important;
    right: 0 !important;
    z-index: 1200 !important;
  }
  
  /* Add padding to main content so it's not hidden behind bottom nav */
  .main-content,
  main,
  #root > div {
    padding-bottom: 120px !important; /* Extra space for tabs + nav */
  }
  
  /* Dialog fixes for mobile */
  .MuiDialog-paperFullScreen {
    padding-bottom: 56px !important; /* Account for bottom nav */
  }
  
  /* Speed dial positioning above tabs and nav */
  .MuiSpeedDial-root {
    bottom: 140px !important; /* Higher above tabs + nav for better visibility */
    z-index: 99999 !important; /* Ultra-high z-index */
    position: fixed !important;
    right: 16px !important;
    /* Force visibility */
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Ensure SpeedDial FAB is always clickable */
  .MuiSpeedDial-fab {
    z-index: 99999 !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    user-select: none !important;
  }
  
  /* SpeedDial actions should also be clickable */
  .MuiSpeedDialAction-fab {
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
  }
  
  /* Safe area for iOS devices */
  @supports (padding-bottom: env(safe-area-inset-bottom)) {
    .MuiBottomNavigation-root {
      padding-bottom: env(safe-area-inset-bottom) !important;
      height: calc(56px + env(safe-area-inset-bottom)) !important;
    }
    
    .MuiDrawer-paperAnchorBottom {
      bottom: calc(56px + env(safe-area-inset-bottom)) !important;
    }
    
    .biodiversity-mobile-tabs {
      bottom: calc(56px + env(safe-area-inset-bottom)) !important;
    }
  }
}