/**
 * PowerZoner Application Styles
 * Purple-themed styling for PowerZoner satellite NDVI zone management
 */

/* ==========================================
   POWERZONER PURPLE BRAND COLORS
   ========================================== */

:root {
  --powerzoner-primary: #7c3aed;       /* Purple */
  --powerzoner-secondary: #6d28d9;     /* Dark Purple */
  --powerzoner-accent: #a78bfa;        /* Light Purple */
  --powerzoner-hover: #8b5cf6;         /* Medium Purple */
}

/* ==========================================
   HEADER - PREMIUM STYLING
   ========================================== */

#appHeader {
  background: linear-gradient(135deg, var(--powerzoner-primary) 0%, var(--powerzoner-secondary) 100%);
  color: white;
  padding: 20px 16px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

#appHeader i {
  font-size: 24px;
  margin-right: 12px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* ==========================================
   TAB BUTTONS - FULL WIDTH, PURPLE THEME
   ========================================== */

.tab-btn {
  flex: 1;
  padding: 8px 4px;
  background: #e5e7eb;
  border: none;
  border-bottom: 3px solid transparent;
  font-weight: 600;
  font-size: 10px;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 0;
  white-space: normal;
  text-align: center;
  line-height: 1.2;
}

@media (max-width: 400px) {
  .tab-btn {
    padding: 6px 2px;
    font-size: 9px;
  }
}

.tab-btn.active {
  background: white;
  border-bottom-color: var(--powerzoner-primary);
  color: var(--powerzoner-primary);
}

.tab-btn:hover:not(.active) {
  background: #d1d5db;
  color: var(--powerzoner-secondary);
}

/* ==========================================
   BUTTONS - PURPLE THEME
   ========================================== */

.btn {
  background: linear-gradient(135deg, var(--powerzoner-primary), var(--powerzoner-hover)) !important;
  color: white !important;
  border: none !important;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.2) !important;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4) !important;
  background: linear-gradient(135deg, var(--powerzoner-hover), var(--powerzoner-primary)) !important;
}

.btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  opacity: 0.6;
}

/* ==========================================
   STEP HEADERS - PURPLE ACCENT
   ========================================== */

.step-number {
  background: linear-gradient(135deg, var(--powerzoner-primary), var(--powerzoner-secondary));
  color: white;
}

.step-title {
  color: var(--powerzoner-primary);
}

/* ==========================================
   PROGRESS BAR
   ========================================== */

.fetch-progress {
  margin-top: 20px;
  display: none;
}

.fetch-progress.active {
  display: block;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.progress-title {
  font-weight: 600;
  color: var(--powerzoner-primary);
  font-size: 14px;
}

.progress-count {
  font-size: 13px;
  color: #6b7280;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--powerzoner-primary), var(--powerzoner-accent));
  width: 0%;
  transition: width 0.3s ease;
}

/* ==========================================
   YEAR LIST
   ========================================== */

.year-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  background: #f9fafb;
  border-radius: 6px;
}

.year-item {
  padding: 8px;
  border-radius: 4px;
  font-size: 12px;
  text-align: center;
  transition: all 0.2s ease;
}

.year-item.pending {
  background: white;
  border: 1px solid #e5e7eb;
  color: #9ca3af;
}

.year-item.fetching {
  background: var(--powerzoner-accent);
  color: white;
  animation: pulse 1.5s ease-in-out infinite;
}

.year-item.completed {
  background: var(--powerzoner-primary);
  color: white;
}

.year-item.error {
  background: #fee2e2;
  border: 1px solid #ef4444;
  color: #dc2626;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ==========================================
   YEAR PREVIEW PLACEHOLDER
   ========================================== */

#yearPreviewContainer {
  padding: 20px;
}

.preview-message {
  text-align: center;
  padding: 40px;
  color: #6b7280;
}

.preview-message i {
  font-size: 48px;
  color: var(--powerzoner-accent);
  margin-bottom: 16px;
}

/* ==========================================
   TOOLTIP STYLING
   ========================================== */

.param-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--powerzoner-primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  font-style: normal;
  cursor: help;
  margin-left: 6px;
  position: relative;
  transition: all 0.2s ease;
}

.param-info-icon:hover {
  background: var(--powerzoner-secondary);
  transform: scale(1.1);
}

.tooltip-container {
  position: fixed;
  z-index: 999999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tooltip-container.active {
  opacity: 1;
}

.tooltip-content {
  background: rgba(31, 41, 55, 0.95);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  width: 280px;
  max-width: 90vw;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  position: relative;
}

.tooltip-arrow {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(31, 41, 55, 0.95);
}

/* ==========================================
   TAB SYSTEM
   ========================================== */

.workflow-tabs {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.tab-buttons {
  display: flex;
  background: #f3f4f6;
  border-bottom: 2px solid #e5e7eb;
}

.tab-content {
  flex: 1;
  padding: 8px;
  background: white;
  overflow-y: auto;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Ensure tab panes have flex layout to push attribution to bottom */
.tab-pane {
  display: none;
  min-height: 100%;
  flex-direction: column;
}

.tab-pane.active {
  display: flex;
}

/* ==========================================
   COPERNICUS ATTRIBUTION FOOTER
   ========================================== */

.copernicus-attribution {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(255,255,255,0.98) 0%, rgba(255,255,255,0.95) 100%);
  border-top: 1px solid #e5e7eb;
  padding: 10px 16px;
  margin-top: auto;
  backdrop-filter: blur(4px);
  z-index: 100;
}

.attribution-text {
  font-size: 10px;
  color: #6b7280;
  text-align: center;
  line-height: 1.4;
  font-weight: 500;
}

/* ==========================================
   POWERZONER-SPECIFIC MAP OVERRIDES
   ========================================== */

/* PowerZoner: Move map tools button to left side */
.tools-float-btn {
  left: 15px !important;
  right: auto !important;
}

.tools-popover {
  left: 15px !important;
  right: auto !important;
}

/* PowerZoner: Position manual button above map tools (position 2 in vertical stack) */
.manual-float-btn {
  left: 15px !important; /* Same left position as tools button */
  bottom: 63px !important; /* 15px + 44px (button height) + 4px (gap) */
  right: auto !important;
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%) !important; /* PowerZoner purple background */
  border: none !important;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4) !important;
}

.manual-float-btn i {
  color: white !important; /* White icon on purple background */
}

.manual-float-btn:hover {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%) !important; /* Lighter purple on hover */
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.5) !important;
  transform: scale(1.05) !important;
}

/* ==========================================
   OPENLAYERS RENDERING FIX
   ========================================== */

/* Force smooth image rendering for all OpenLayers canvases (fixes blocky raster display) */
.ol-layer canvas {
  image-rendering: auto !important;
  image-rendering: -webkit-optimize-contrast !important;
  image-rendering: optimize-quality !important;
  -ms-interpolation-mode: bicubic !important;
}

/* ==========================================
   LEFT FLOATING BUTTONS (VERTICAL STACK)
   ========================================== */

.left-floating-buttons {
  position: absolute;
  bottom: 15px;
  left: 15px;
  display: flex !important; /* Force display */
  flex-direction: row;
  gap: 4px;
  z-index: 1001;
  pointer-events: auto; /* Ensure clickable */
  visibility: visible !important; /* Force visible */
  opacity: 1 !important; /* Force opaque */
}

/* ==========================================
   SOIL SAMPLING FLOATING BUTTON
   ========================================== */

.soil-sampling-float-btn {
  position: relative; /* For badge positioning */
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%); /* PowerZoner purple background */
  backdrop-filter: blur(10px);
  border: none;
  border-radius: 50%;
  display: flex !important; /* Force visible */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
  transition: all 0.2s ease;
  visibility: visible !important;
  opacity: 1 !important;
}

.soil-sampling-float-btn:hover {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); /* Lighter purple on hover */
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.5);
  transform: scale(1.05);
}

.soil-sampling-float-btn i {
  font-size: 16px;
  color: white; /* White icon on purple background */
  transition: color 0.2s ease;
}

.soil-sampling-float-btn:hover i {
  color: white; /* Keep white on hover */
}

/* Experimental badge on soil sampling button */
.experimental-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 4px;
  border-radius: 3px;
  border: 1.5px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  z-index: 1;
}

/* ==========================================
   PRESCRIPTION (Rx) FLOATING BUTTON
   ========================================== */

.floating-rx-button {
  position: relative;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  backdrop-filter: blur(10px);
  border: none;
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
  transition: all 0.2s ease;
  visibility: visible !important;
  opacity: 1 !important;
}

.floating-rx-button:hover {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.5);
  transform: scale(1.05);
}

.floating-rx-button i {
  font-size: 16px;
  color: white;
  transition: color 0.2s ease;
}

.floating-rx-button:hover i {
  color: white;
}

/* ==========================================
   FLOATING 3D VIEW BUTTON
   ========================================== */

.floating-3d-button {
  position: absolute;
  bottom: 70px !important;
  right: 20px;
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  z-index: 1001;
  transition: all 0.3s ease;
}

.floating-3d-button .beta-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  background: rgba(255, 255, 255, 0.3);
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: -2px;
}

.floating-3d-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(124, 58, 237, 0.5);
}

.floating-3d-button:active {
  transform: translateY(-1px);
}

.floating-3d-button i {
  font-size: 16px;
}

/* ==========================================
   CESIUM 3D VIEWER OVERRIDES
   ========================================== */

/* PowerZoner: Override Zoner purple gradient for Cesium modal header */
.cesium-modal-header {
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%) !important;
}

/* ==========================================
   MOUSE POSITION DISPLAY (LAT/LON)
   ========================================== */

#mouse-position {
  position: absolute !important;
  bottom: 30px !important;
  right: 8px !important;
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(4px);
  padding: 6px 12px !important;
  border-radius: 4px !important;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace !important;
  font-size: 12px !important;
  color: #374151 !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
  z-index: 1002 !important;
  pointer-events: none;
  min-width: 180px;
  text-align: center;
  line-height: 1.4 !important;
  display: inline-block;
}

#mouse-position:empty,
#mouse-position:not(:has(*)):empty {
  display: none !important;
}

/* Ensure any child elements inside mouse position inherit styles */
#mouse-position * {
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
  position: static !important;
  display: inline !important;
}

/* Move OpenLayers attribution to not overlap */
#map .ol-attribution {
  bottom: 4px;
  right: 4px;
}
