html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* Weather Map Styles */
.weather-popup {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-width: 50px;
}

.weather-popup h6 {
  color: #0d6efd;
  margin-bottom: 10px;
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 5px;
}

.weather-popup.error h6 {
  color: #dc3545;
}

.weather-popup p {
  margin-bottom: 5px;
  font-size: 14px;
}

.weather-popup .fas {
  margin-right: 5px;
}

/* Loading spinner customization */
#loading {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  padding: 20px;
  margin: auto;
  max-width: 300px;
}

/* Responsive map adjustments */
@media (max-width: 768px) {
  #map {
    height: 65vh !important;
    margin: 0 8px 0 8px;
    border-radius: 8px;
  }
  .navbar, .navbar-brand {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
  .container-fluid {
    padding-left: 8px;
    padding-right: 8px;
  }
  .weather-popup {
    min-width: 120px;
    max-width: 95vw;
    font-size: 13px;
    padding: 8px 6px;
  }
  .weather-popup * {
    font-size: 13px !important;
  }
  .weather-popup h6 {
    font-size: 15px !important;
    padding-bottom: 3px;
    margin-bottom: 8px;
  }
  .weather-popup p {
    font-size: 13px;
    margin-bottom: 4px;
  }
  .weather-popup table {
    font-size: 12px !important;
  }
  .weather-popup .btn, .weather-popup button {
    font-size: 13px !important;
    padding: 6px 12px !important;
  }
  #export-csv-btn, #export-xlsx-btn {
    padding: 6px 12px !important;
    font-size: 13px !important;
  }
}

@media (max-width: 400px) {
  .weather-popup {
    min-width: 10px;
    max-width: 98vw;
    font-size: 9px;
    padding: 2px 2px;
  }
  .weather-popup * {
    font-size: 9px !important;
  }
  .weather-popup h6 {
    font-size: 10px !important;
    padding-bottom: 0;
    margin-bottom: 2px;
  }
  .weather-popup p {
    font-size: 8px;
    margin-bottom: 1px;
  }
  .weather-popup table {
    font-size: 7px !important;
  }
  .weather-popup .btn, .weather-popup button {
    font-size: 8px !important;
    padding: 1px 2px !important;
  }
  #export-csv-btn, #export-xlsx-btn {
    padding: 1px 2px !important;
    font-size: 8px !important;
  }
}

/* PWA Specific Styles */
@media (display-mode: standalone) {
  /* Hide address bar when running as PWA */
  body {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Add top padding for status bar on mobile */
  .navbar {
    padding-top: env(safe-area-inset-top);
  }
}

/* Loading improvements for PWA */
.pwa-loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

/* PWA Styles */
/* Hide scrollbars in standalone mode */
@media (display-mode: standalone) {
  body {
    overflow-x: hidden;
  }
  
  /* Add padding for safe area (notch) */
  .navbar, .container-fluid {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  
  /* Adjust for bottom safe area */
  .footer {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  /* Better header styling in standalone */
  .navbar {
    border-bottom: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }
}

/* PWA Install Button */
.pwa-install-button {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 50px;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: bold;
  box-shadow: 0 8px 20px rgba(0,123,255,0.4);
  z-index: 1000;
  transition: all 0.3s ease;
  display: none;
  min-width: 140px;
  text-align: center;
}

.pwa-install-button:hover {
  background: #0056b3;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,123,255,0.4);
}

.pwa-install-button.show {
  display: block;
  animation: slideUp 0.3s ease;
}

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

/* Network status indicator */
.network-status {
  position: fixed;
  top: 10px;
  right: 10px;
  background: #28a745;
  color: white;
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 12px;
  z-index: 1001;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.network-status.offline {
  background: #dc3545;
}

.network-status.show {
  opacity: 1;
}

/* Better touch targets for mobile */
@media (max-width: 768px) {
  .btn, .dropdown-toggle, .nav-link {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
  }
  
  .dropdown-toggle {
    min-height: 44px;
  }
  
  .leaflet-control-zoom a {
    width: 44px !important;
    height: 44px !important;
    line-height: 42px !important;
  }
  
  /* PWA specific mobile improvements */
  .pwa-install-button {
    bottom: 80px; /* Above potential home indicator */
    right: 15px;
  }
}

/* Dark mode PWA adjustments */
body.dark-mode .pwa-install-button {
  background: #0d6efd;
  color: #fff;
}

body.dark-mode .pwa-install-button:hover {
  background: #0b5ed7;
}

body.dark-mode .network-status {
  background: #198754;
}

body.dark-mode .network-status.offline {
  background: #dc3545;
}

/* Improve PWA splash screen appearance */
@media (display-mode: standalone) {
  .navbar-brand {
    font-weight: 600;
    color: #0d6efd !important;
  }
  
  /* Hide install button when already installed */
  .pwa-install-button {
    display: none !important;
  }
}

@media (max-width: 768px) {
  #theme-toggle-btn,
  #langDropdown,
  #langDropdown + .dropdown-menu {
    display: none !important;
  }
}

.navbar, .navbar-header, .navbar-brand {
  color: #000000 !important;
}

.navbar .navbar-brand, .navbar .nav-link, .navbar .navbar-text {
  color: #000000 !important;
}

/* Leaflet popup mobile fix */
.leaflet-popup {
    margin-bottom: 54px !important;
}
.leaflet-popup-content-wrapper, 
.leaflet-popup-tip {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
.leaflet-container a.leaflet-popup-close-button {
    width: 30px !important;
    height: 30px !important;
    font-size: 20px !important;
    padding: 5px !important;
    line-height: 20px !important;
}
.leaflet-popup-pane {
    pointer-events: auto !important;
}
.leaflet-popup-content {
    margin: 14px 20px !important;
    min-width: 200px !important;
}
@media (max-width: 768px) {
    .leaflet-popup-content {
        min-width: 160px !important;
    }
}

/* Dark mode styles */
body.dark-mode {
    background-color: #181a1b !important;
    color: #e0e0e0 !important;
}

body.dark-mode .navbar, 
body.dark-mode .footer, 
body.dark-mode .container-fluid, 
body.dark-mode .card, 
body.dark-mode .modal-content {
    background-color: #23272b !important;
    color: #e0e0e0 !important;
}

body.dark-mode .navbar, 
body.dark-mode .navbar * {
    background-color: #23272b !important;
    color: #e0e0e0 !important;
    border-color: #23272b !important;
}

body.dark-mode .navbar .navbar-brand, 
body.dark-mode .navbar .nav-link, 
body.dark-mode .navbar .navbar-text, 
body.dark-mode .navbar .dropdown-menu, 
body.dark-mode .navbar .dropdown-item {
    color: #e0e0e0 !important;
}

body.dark-mode .navbar .dropdown-menu {
    background-color: #23272b !important;
}

body.dark-mode .table {
    color: #e0e0e0;
    background-color: #23272b;
}

body.dark-mode .btn-outline-secondary, 
body.dark-mode .btn-outline-primary, 
body.dark-mode .btn-outline-success {
    border-color: #888;
    color: #e0e0e0;
    background-color: transparent;
}

body.dark-mode .btn-outline-secondary:hover, 
body.dark-mode .btn-outline-primary:hover, 
body.dark-mode .btn-outline-success:hover {
    background: #444;
    color: #fff;
}

body.dark-mode .leaflet-popup-content-wrapper {
    background: #23272b;
    color: #e0e0e0;
}

body.dark-mode .leaflet-popup-tip {
    background: #23272b;
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6,
body.dark-mode p,
body.dark-mode span,
body.dark-mode label,
body.dark-mode th,
body.dark-mode td,
body.dark-mode .dropdown-menu,
body.dark-mode .leaflet-popup-content,
body.dark-mode .form-label,
body.dark-mode .form-control,
body.dark-mode .form-check-label,
body.dark-mode .text-muted,
body.dark-mode .text-secondary,
body.dark-mode .text-center,
body.dark-mode .list-group-item,
body.dark-mode .dropdown-item,
body.dark-mode .leaflet-control-attribution {
    color: #e0e0e0 !important;
}

body.dark-mode .form-control {
    background-color: #333;
    border-color: #555;
    color: #e0e0e0;
}

body.dark-mode .form-control::placeholder {
    color: #b0b0b0 !important;
}

body.dark-mode .input-group-text,
body.dark-mode .btn-outline-secondary {
  background-color: #23272b !important;
  color: #e0e0e0 !important;
  border-color: #444 !important;
}

body.dark-mode .form-control:focus {
    background-color: #444;
    border-color: #777;
    color: #e0e0e0;
}

body.dark-mode .dropdown-item.active, 
body.dark-mode .dropdown-item:active {
    background-color: #444 !important;
    color: #fff !important;
}

body.dark-mode .leaflet-control-attribution {
    background: transparent !important;
}

body.dark-mode #loading {
    background: rgba(35, 39, 43, 0.9);
    color: #e0e0e0;
}

body.dark-mode .weather-popup {
    background: #23272b;
    color: #e0e0e0;
}

body.dark-mode .weather-popup h6 {
    color: #4dabf7;
    border-bottom-color: #444;
}

body.dark-mode .weather-popup.error h6 {
    color: #ff6b6b;
}

/* Custom styles for marker numbers in dark mode */
body.dark-mode .leaflet-marker-count {
    color: #000000 !important; /* Black color for dark mode */
    font-weight: bold !important; /* Make the font bold */
}

#install-info {
    border-left: 4px solid #007bff;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    animation: fadeInUp 0.5s ease;
}

body.dark-mode #install-info {
    background: linear-gradient(135deg, #23272b 0%, #2c3034 100%);
    border-left-color: #0d6efd;
    color: #e0e0e0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
