/* Solar Panel Analyzer - Enhanced Styles */
:root{
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --secondary: #10b981;
  --accent: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --card: #ffffff;
  --muted: #64748b;
  --text: #0f172a;
  --border: #e2e8f0;
  --glass: rgba(255,255,255,0.85);
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* App Layout */
.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 0;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  max-width: 100%;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
}

.logo i {
  font-size: 28px;
  color: var(--accent);
}

.powered-by {
  font-size: 13px;
  opacity: 0.9;
  white-space: nowrap;
}

/* Header Search */
.header-search {
  flex: 0 1 450px;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 8px 12px;
  gap: 10px;
  position: relative;
  margin-right: auto;
}

.header-search i {
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
}

.header-search input {
  flex: 1;
  border: 0;
  outline: none;
  font-size: 14px;
  background: transparent;
  color: white;
  padding: 6px;
}

.header-search input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.header-search .btn {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.header-search .btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Search Results Dropdown */
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 8px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow-xl);
  max-height: 300px;
  overflow-y: auto;
  display: none;
  z-index: 10000;
}

.search-results.show {
  display: block;
}

.search-result-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--bg);
}

.search-result-item i {
  color: var(--primary);
  font-size: 14px;
}

.search-result-text {
  flex: 1;
  font-size: 14px;
}

/* Header Dropdown */
.header-dropdown {
  position: relative;
}

.dropdown-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.dropdown-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.dropdown-btn i.fa-chevron-down {
  font-size: 12px;
  transition: transform 0.2s;
}

.dropdown-btn.active i.fa-chevron-down {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow-xl);
  min-width: 220px;
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 10000;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  border-bottom: 1px solid var(--border);
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background: var(--bg);
  color: var(--primary);
}

.dropdown-item i {
  color: var(--primary);
  width: 20px;
  text-align: center;
}

/* Analysis Overlay */
.analysis-overlay {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 480px;
  max-height: 70vh;
  background: var(--card);
  box-shadow: var(--shadow-xl);
  border-radius: 12px 12px 0 0;
  z-index: 5000;
  transform: translateY(100%);
  transition: transform 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
}

.analysis-overlay.show {
  transform: translateY(0);
}

.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 2px solid var(--border);
  background: var(--bg);
}

.overlay-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.overlay-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.overlay-close:hover {
  background: var(--border);
  color: var(--text);
}

.overlay-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.overlay-content .section {
  display: none;
}

.overlay-content .section.active {
  display: block;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 480px;
  gap: 0;
  overflow: hidden;
}

/* Map Container */
#map {
  position: relative;
  height: 100%;
  width: 100%;
  background: #e5e7eb;
}

/* Map Controls - Left Side */
.map-controls-left {
  position: fixed;
  left: 20px;
  top: 80px;
  z-index: 1000;
  max-width: 250px;
}

.map-type-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* Google Places Autocomplete Styling */
.pac-container {
  z-index: 10000 !important;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  margin-top: 4px;
  font-family: "Inter", system-ui, sans-serif;
}

.pac-item {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
}

.pac-item:hover {
  background: var(--bg);
}

.pac-icon {
  display: none;
}

.pac-item-query {
  font-size: 14px;
  color: var(--text);
}

/* Buttons */
.btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--primary);
}


.control-group {
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow-lg);
}

.control-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: block;
}


.btn-map-type {
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

.btn-map-type:hover {
  background: var(--card);
  border-color: var(--primary);
}

.btn-map-type.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-map-type i {
  font-size: 14px;
}


.layer-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.layer-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.layer-option:hover {
  background: var(--bg);
}

.layer-option input[type="checkbox"] {
  cursor: pointer;
}

.layer-option span {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.layer-option i {
  font-size: 14px;
  color: var(--primary);
}

/* Map Hint */
.map-hint {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--glass);
  backdrop-filter: blur(10px);
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  z-index: 10000;
  pointer-events: none;
}

.map-hint i {
  color: var(--primary);
}

/* Side Panel */
.panel {
  background: var(--card);
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card) 0%, var(--bg) 100%);
}

.header-main {
  margin-bottom: 16px;
}

.title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.title i {
  color: var(--primary);
}

.subtitle {
  font-size: 13px;
  color: var(--muted);
}

.header-location {
  background: var(--bg);
  padding: 12px;
  border-radius: 8px;
}

.location-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.location-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* KPIs Section */
#kpisSection {
  display: none; /* Will be changed to 'grid' by JavaScript */
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border-radius: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--card);
  padding: 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  flex-shrink: 0;
}

.kpi-icon.blue {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.kpi-icon.green {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.kpi-icon.orange {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.kpi-icon.teal {
  background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
}

.kpi-content {
  flex: 1;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  padding: 16px 24px 0;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
}

.tab {
  padding: 12px 16px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  transition: all 0.2s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.tab:hover {
  background: var(--bg);
  color: var(--text);
}

.tab.active {
  background: var(--primary);
  color: white;
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}

/* Tab Content */
#tabContent {
  flex: 1;
  overflow-y: auto;
}

.section {
  padding: 24px;
}

.section-header {
  margin-bottom: 20px;
}

.section-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-header h3 i {
  color: var(--primary);
}

.section-header .muted {
  margin: 0;
  font-size: 13px;
}

/* Info Grid */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.info-item {
  background: var(--bg);
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.info-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-label i {
  color: var(--primary);
}

.info-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

/* Quality Indicator */
.quality-indicator {
  background: var(--bg);
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.quality-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quality-label i {
  color: var(--secondary);
}

.quality-bar {
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

.quality-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary) 0%, var(--primary) 100%);
  transition: width 0.5s ease;
  border-radius: 6px;
}

.quality-text {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 10px;
}

.action-buttons .btn {
  flex: 1;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

/* Configurations List */
.configs-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.config-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.config-card.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(37, 99, 235, 0.1) 100%);
}

.config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.config-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.config-badge {
  background: var(--primary);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.config-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.config-stat {
  display: flex;
  flex-direction: column;
}

.config-stat-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.config-stat-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

/* Financial Content */
.financial-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.financial-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--border);
}

.financial-card h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.financial-card h4 i {
  color: var(--primary);
}

.financial-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.financial-row:last-child {
  border-bottom: 0;
}

.financial-label {
  font-size: 13px;
  color: var(--muted);
}

.financial-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.financial-value.positive {
  color: var(--secondary);
}

.financial-value.negative {
  color: var(--danger);
}

/* Roof Segments List */
.roof-segments-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.roof-segment-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.roof-segment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.segment-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.segment-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.segment-stat {
  text-align: center;
}

.segment-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.segment-stat-label {
  font-size: 11px;
  color: var(--muted);
}

/* Imagery Content */
.imagery-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.imagery-preview {
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.imagery-preview img {
  width: 100%;
  height: auto;
  display: block;
}

.imagery-info {
  padding: 12px;
}

.imagery-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.imagery-description {
  font-size: 12px;
  color: var(--muted);
}

/* Utilities */
.muted {
  color: var(--muted);
}

/* Scrollbar Styling */
.panel::-webkit-scrollbar,
#tabContent::-webkit-scrollbar {
  width: 8px;
}

.panel::-webkit-scrollbar-track,
#tabContent::-webkit-scrollbar-track {
  background: var(--bg);
}

.panel::-webkit-scrollbar-thumb,
#tabContent::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.panel::-webkit-scrollbar-thumb:hover,
#tabContent::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Responsive Design */
@media (max-width: 1200px) {
  .main-content {
    grid-template-columns: 1fr 420px;
  }
}

@media (max-width: 980px) {
  .main-content {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 50vh;
  }
  
  .search {
    min-width: 300px;
  }
  
  .kpis {
    grid-template-columns: 1fr 1fr;
  }
  
  .map-controls,
  .layer-controls {
    right: 10px;
  }
  
  .top-controls {
    left: 10px;
    top: 10px;
  }
}

@media (max-width: 640px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .search {
    min-width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  
  .search .btn {
    width: 100%;
    justify-content: center;
  }
  
  .kpis {
    grid-template-columns: 1fr;
  }
  
  .info-grid {
    grid-template-columns: 1fr;
  }
  
  .tabs {
    font-size: 11px;
  }
  
  .tab {
    padding: 10px 12px;
  }
}
