/* ========================================
   MODERN DESIGN SYSTEM FOR RENEWABLE ENERGY CALCULATOR
   Created with Vanilla CSS - Professional Edition
   ======================================== */

/* ========================================
   DESIGN TOKENS & CSS VARIABLES
   ======================================== */
:root {
  /* Colors - Professional Green Energy Theme */
  --color-primary: #2E7D32;
  --color-primary-hover: #1B5E20;
  --color-primary-light: #4CAF50;
  --color-secondary: #0288D1;
  --color-accent: #FFA726;
  --color-success: #4CAF50;
  --color-danger: #D32F2F;
  --color-warning: #FFA000;
  
  /* Energy Type Colors */
  --color-solar-start: #FFA726;
  --color-solar-end: #FF6F00;
  --color-wind-start: #42A5F5;
  --color-wind-end: #1976D2;
  --color-geo-start: #EF5350;
  --color-geo-end: #D32F2F;
  
  /* Neutrals */
  --color-bg-primary: #FFFFFF;
  --color-bg-secondary: #F5F5F5;
  --color-bg-tertiary: #FAFAFA;
  --color-border: #E0E0E0;
  --color-border-hover: #BDBDBD;
  --color-text-primary: #212121;
  --color-text-secondary: #757575;
  --color-text-muted: #9E9E9E;
  
  /* Typography */
  --font-family-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-family-heading: 'Poppins', 'Inter', sans-serif;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.15), 0 10px 10px rgba(0,0,0,0.04);
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
}

/* ========================================
   RESET & BASE STYLES
   ======================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-family-primary);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   LAYOUT
   ======================================== */
.container {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.sidebar {
  width: 420px;
  padding: var(--space-lg);
  background: linear-gradient(to bottom, #fafafa 0%, #f5f5f5 100%);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 2px 0 8px rgba(0,0,0,0.05);
}

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

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-hover);
}

#map {
  flex: 1;
  position: relative;
}

/* ========================================
   BRANDING
   ======================================== */
.brand-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #ffffff 0%, #f7fbf7 100%);
  box-shadow: var(--shadow-sm);
}

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: #fff;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-family: var(--font-family-heading);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text-primary);
}

.brand-subtitle {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.backend-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.backend-status:hover {
  box-shadow: var(--shadow-sm);
}

.backend-status-dot {
  font-size: 10px;
}

.backend-status.status-up {
  color: #1b5e20;
  border-color: #bfe5c3;
  background: #f1fbf2;
}

.backend-status.status-down {
  color: #8e1a1a;
  border-color: #f2c1c1;
  background: #fff3f3;
}

.backend-status.status-checking {
  color: #7a5a0a;
  border-color: #f3dc9d;
  background: #fff9e8;
}

/* ========================================
   PANELS
   ======================================== */
.panel {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  background: var(--color-bg-primary);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  animation: fadeIn 0.3s ease;
}

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

.panel:hover {
  box-shadow: var(--shadow-md);
}

.panel.hidden {
  display: none;
}

.panel .title {
  font-family: var(--font-family-heading);
  font-weight: 700;
  font-size: 24px;
  margin-bottom: var(--space-lg);
  color: var(--color-text-primary);
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ========================================
   PROGRESS STEPPER
   ======================================== */
.progress-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  padding: var(--space-md);
  background: linear-gradient(135deg, rgba(46, 125, 50, 0.05) 0%, rgba(46, 125, 50, 0.02) 100%);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.stepper-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
  position: relative;
  flex: 1;
}

.stepper-circle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  background: var(--color-bg-primary);
  transition: all var(--transition-base);
  z-index: 2;
}

.stepper-step.active .stepper-circle {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: white;
  box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.1);
  transform: scale(1.1);
}

.stepper-step.completed .stepper-circle {
  border-color: var(--color-success);
  background: var(--color-success);
  color: white;
}

.stepper-label {
  font-size: 11px;
  margin-top: var(--space-xs);
  color: var(--color-text-muted);
  font-weight: 500;
  text-align: center;
}

.stepper-step.active .stepper-label {
  color: var(--color-primary);
  font-weight: 600;
}

.stepper-line {
  position: absolute;
  top: 18px;
  left: 50%;
  right: -50%;
  height: 2px;
  background: var(--color-border);
  z-index: 1;
}

.stepper-step:last-child .stepper-line {
  display: none;
}

.stepper-step.completed .stepper-line {
  background: var(--color-success);
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
label {
  display: block;
  font-weight: 500;
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

.country-region {
  font-style: italic;
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: rgba(46, 125, 50, 0.05);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-sm);
}

/* ========================================
   KPI STRIP
   ======================================== */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
  margin: 0 0 var(--space-md);
}

.kpi-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #ffffff 0%, #f7fbf7 100%);
}

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-text-muted);
  font-weight: 600;
}

.kpi-value {
  font-size: 13px;
  color: var(--color-text-primary);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========================================
   FORM ELEMENTS
   ======================================== */
input, select {
  width: 100%;
  margin-bottom: var(--space-md);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  font-size: 15px;
  font-family: inherit;
  transition: all var(--transition-base);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

input:disabled {
  background: var(--color-bg-secondary);
  cursor: not-allowed;
  opacity: 0.7;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
}

/* ========================================
   BUTTONS
   ======================================== */
.big-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
  color: #fff;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: var(--space-sm);
  margin-right: var(--space-sm);
  min-width: 140px;
  box-shadow: 0 2px 4px rgba(46, 125, 50, 0.2);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  font-family: inherit;
}

.big-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.big-button:hover::before {
  left: 100%;
}

.big-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

.big-button:active {
  transform: translateY(0);
}

.big-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.big-button.loading {
  pointer-events: none;
  color: transparent;
}

.big-button.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin-left: -10px;
  margin-top: -10px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.red-button {
  background: linear-gradient(135deg, var(--color-danger) 0%, #C62828 100%) !important;
  box-shadow: 0 2px 4px rgba(211, 47, 47, 0.2) !important;
}

.red-button:hover {
  box-shadow: 0 4px 12px rgba(211, 47, 47, 0.3) !important;
}

button[style*="background-color: #777"] {
  background: var(--color-bg-secondary) !important;
  color: var(--color-text-primary) !important;
  box-shadow: none !important;
}

button[style*="background-color: #777"]:hover {
  background: var(--color-border) !important;
}

/* ========================================
   FINAL ACTION BAR
   ======================================== */
.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg) !important;
  padding: var(--space-sm);
  border-top: 1px solid var(--color-border);
  background: linear-gradient(to top, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.88));
  backdrop-filter: blur(3px);
}

.sticky-actions .big-button {
  flex: 1;
  margin: 0;
}

/* ========================================
   CHECKBOXES
   ======================================== */
.checkbox-row {
  display: flex;
  align-items: center;
  margin: var(--space-md) 0;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  margin-right: var(--space-sm);
  cursor: pointer;
}

.checkbox-row label {
  margin: 0;
  font-weight: normal;
  cursor: pointer;
}

/* ========================================
   TOOLTIPS
   ======================================== */
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: help;
  margin-left: var(--space-xs);
  transition: all var(--transition-fast);
  text-decoration: none;
}

.tooltip-icon:hover {
  transform: scale(1.15);
  background: var(--color-primary-hover);
}

/* ========================================
   INFO AREAS & DETAILS
   ======================================== */
.info-area {
  background: var(--color-bg-tertiary);
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-top: var(--space-md);
  display: none;
}

details {
  margin-top: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  background: var(--color-bg-tertiary);
}

summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-primary);
  padding: var(--space-sm);
  margin: calc(-1 * var(--space-md));
  margin-bottom: var(--space-md);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  transition: background var(--transition-fast);
}

summary:hover {
  background: rgba(46, 125, 50, 0.05);
}

details[open] summary {
  margin-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

/* ========================================
   SPINNER / LOADING
   ======================================== */
.spinner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  transform: none;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 0;
  text-align: center;
  font-size: 16px;
  z-index: 9999;
}

.spinner-circle {
  width: 60px;
  height: 60px;
  border: 4px solid var(--color-bg-secondary);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

.spinner-text {
  margin-top: var(--space-lg);
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text-primary);
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 400px;
}

.toast {
  background: white;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  white-space: pre-line;
  transform: translateX(calc(100% + 24px));
  transition: transform var(--transition-base);
  border-left: 4px solid var(--color-primary);
}

.toast.show {
  transform: translateX(0);
}

.toast.success {
  border-left-color: var(--color-success);
}

.toast.error {
  border-left-color: var(--color-danger);
}

.toast.warning {
  border-left-color: var(--color-warning);
}

.toast.info {
  border-left-color: var(--color-secondary);
}

/* ========================================
   ENERGY TYPE HEADERS
   ======================================== */
.energy-header {
  font-size: 2em;
  font-weight: bold;
  margin: var(--space-lg) 0;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.energy-header img {
  vertical-align: middle;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* ========================================
   METRICS & CARDS
   ======================================== */
.metric-card {
  background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin: var(--space-md) 0;
}

.metric-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-xs);
  font-weight: 500;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
}

/* ========================================
   MOBILE TOGGLE
   ======================================== */
#toggleSidebar {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1100;
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}

#toggleSidebar:hover {
  background: var(--color-primary-hover);
  transform: scale(1.05);
}

/* ========================================
   MAPBOX CUSTOMIZATION
   ======================================== */
.mapbox-gl-draw_ctrl-icon {
  width: 40px;
  height: 40px;
}

.mapbox-gl-draw_ctrl-draw-btn {
  background-size: 40px 40px;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }

  .sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 90%;
    max-width: 400px;
    height: 100%;
    background: #fafafa;
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    z-index: 1000;
    padding: var(--space-lg);
    box-shadow: var(--shadow-xl);
  }

  #map {
    height: 100%;
  }

  #toggleSidebar {
    display: block;
  }

  .big-button {
    width: 100%;
    margin-right: 0;
    margin-bottom: var(--space-sm);
  }

  .panel .title {
    font-size: 20px;
  }

  .kpi-strip {
    grid-template-columns: 1fr;
  }

  .brand-header {
    padding: var(--space-sm) var(--space-md);
  }

  .brand-logo {
    width: 40px;
    height: 40px;
  }

  .stepper-step {
    min-width: 50px;
  }

  .stepper-circle {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  .stepper-label {
    font-size: 10px;
  }

  .sticky-actions {
    flex-direction: column;
  }

  .sticky-actions .big-button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 85%;
  }

  .panel {
    padding: var(--space-md);
  }

  input, select {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .energy-header {
    font-size: 1.5em;
  }

  .energy-header img {
    width: 32px;
    height: 32px;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 100;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  top: 0;
}

*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline-offset: -2px;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.mb-0 { margin-bottom: 0 !important; }
.mt-lg { margin-top: var(--space-lg); }
.hidden { display: none !important; }
