/* Global Styles & Design System */
:root {
  /* Color Palette - Eco Dark Theme */
  --bg-primary: #050d0a;
  --bg-secondary: #0a1611;
  --bg-card: rgba(14, 28, 22, 0.6);
  --bg-card-hover: rgba(20, 38, 30, 0.8);
  --border-color: rgba(52, 211, 153, 0.15);
  --border-color-hover: rgba(52, 211, 153, 0.4);
  
  --text-primary: #f0fdf4;
  --text-secondary: #a7f3d0;
  --text-muted: #6ee7b7;
  
  --accent-emerald: #10b981;
  --accent-mint: #34d399;
  --accent-glow: rgba(52, 211, 153, 0.25);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 20px rgba(52, 211, 153, 0.1);
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-thai: 'Sarabun', sans-serif;
  --font-eng: 'Outfit', sans-serif;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-thai);
  line-height: 1.6;
  min-height: 100vh;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(52, 211, 153, 0.03) 0%, transparent 45%);
  background-attachment: fixed;
}

/* App Container Layout */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header Styling */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 16px 28px;
  border-radius: 20px;
  box-shadow: var(--shadow-md);
}

.header-logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-logo {
  height: 65px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(52, 211, 153, 0.3));
  transition: var(--transition-smooth);
}

.header-logo:hover {
  transform: scale(1.05);
}

.header-title {
  text-align: center;
  flex-grow: 1;
  padding: 0 20px;
}

.header-title h1 {
  font-family: var(--font-eng);
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-mint) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
}

.header-title p {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 300;
  letter-spacing: 0.5px;
}

.header-decor {
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-logo-decor {
  height: 65px;
  object-fit: contain;
  opacity: 0.9;
  filter: drop-shadow(0 0 8px rgba(52, 211, 153, 0.3));
}

/* KPI Dashboard Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 24px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-md);
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-mint);
  opacity: 0.8;
}

.kpi-card:hover {
  transform: translateY(-5px);
  border-color: var(--border-color-hover);
  box-shadow: var(--shadow-lg);
}

.kpi-icon {
  font-size: 2.8rem;
  background: rgba(52, 211, 153, 0.1);
  padding: 12px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.kpi-info h3 {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: 2px;
}

.kpi-value {
  font-family: var(--font-eng);
  font-size: 2.6rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
  text-shadow: 0 0 10px var(--accent-glow);
}

.kpi-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 300;
}

/* Navigation Tabs */
.tab-navigation {
  display: flex;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 8px;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  gap: 8px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 12px 24px;
  font-family: var(--font-thai);
  font-size: 1rem;
  font-weight: 500;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.tab-btn:hover {
  background: rgba(52, 211, 153, 0.08);
  color: #fff;
}

.tab-btn.active {
  background: var(--accent-mint);
  color: var(--bg-primary);
  font-weight: 600;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* Content Area */
.main-content {
  min-height: 500px;
}

.tab-content {
  display: none;
  animation: fadeIn 0.4s ease;
}

.tab-content.active {
  display: block;
}

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

/* Charts Card Layout */
.charts-grid-top {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 24px;
  border-radius: 20px;
  box-shadow: var(--shadow-md);
}

.chart-card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 20px;
  border-left: 4px solid var(--accent-mint);
  padding-left: 12px;
}

.chart-container {
  position: relative;
  height: 320px;
  width: 100%;
}

.chart-container-ranking {
  position: relative;
  height: 400px;
  width: 100%;
}

/* Overview Summary Card */
.overview-summary-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 28px;
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  display: grid;
  grid-template-columns: 1.2fr 2fr;
  gap: 32px;
}

.summary-text-content h2 {
  font-size: 1.5rem;
  color: #fff;
  margin-bottom: 12px;
  border-left: 4px solid var(--accent-mint);
  padding-left: 12px;
}

.summary-text-content p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  text-align: justify;
}

.summary-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.summary-detail-item {
  background: rgba(10, 22, 17, 0.8);
  border: 1px solid rgba(52, 211, 153, 0.1);
  padding: 16px;
  border-radius: 12px;
  transition: var(--transition-smooth);
}

.summary-detail-item:hover {
  border-color: var(--accent-mint);
  background: var(--bg-card-hover);
}

.summary-detail-item h4 {
  color: var(--accent-mint);
  font-family: var(--font-eng);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.summary-detail-item p {
  font-size: 0.85rem;
  color: var(--text-primary);
  opacity: 0.85;
}

/* Map View Styles */
.map-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 24px;
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.map-header h2 {
  font-size: 1.3rem;
  color: #fff;
  border-left: 4px solid var(--accent-mint);
  padding-left: 12px;
}

.map-header p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-left: 16px;
  margin-top: 4px;
}

.map-wrapper {
  height: 600px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(52, 211, 153, 0.2);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

#leaflet-map {
  width: 100%;
  height: 100%;
  background: #0d1e18;
}

/* Custom styled leaflet popups */
.leaflet-popup-content-wrapper {
  background: #0a1611 !important;
  color: #fff !important;
  border: 1px solid var(--accent-mint) !important;
  border-radius: 12px !important;
  box-shadow: 0 0 15px rgba(52, 211, 153, 0.2) !important;
  font-family: var(--font-thai) !important;
}

.leaflet-popup-tip {
  background: #0a1611 !important;
  border-left: 1px solid var(--accent-mint) !important;
  border-right: 1px solid var(--accent-mint) !important;
}

.map-popup-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-mint);
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(52, 211, 153, 0.2);
  padding-bottom: 4px;
}

.map-popup-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.map-popup-body {
  max-height: 140px;
  overflow-y: auto;
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.map-popup-activity-item {
  padding: 4px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.map-popup-offset-total {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid rgba(52, 211, 153, 0.3);
  padding-top: 6px;
  margin-top: 4px;
}

/* Ranking and Data Table Layout */
.ranking-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.ranking-chart-card {
  width: 100%;
}

.table-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 24px;
  border-radius: 20px;
  box-shadow: var(--shadow-md);
}

.table-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.table-actions h2 {
  font-size: 1.2rem;
  color: #fff;
  border-left: 4px solid var(--accent-mint);
  padding-left: 12px;
}

.search-filter-container {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

#table-search {
  background: rgba(10, 22, 17, 0.7);
  border: 1px solid rgba(52, 211, 153, 0.2);
  border-radius: 10px;
  padding: 10px 16px;
  color: #fff;
  font-family: var(--font-thai);
  font-size: 0.9rem;
  width: 280px;
  transition: var(--transition-smooth);
}

#table-search:focus {
  outline: none;
  border-color: var(--accent-mint);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.2);
}

#filter-year {
  background: rgba(10, 22, 17, 0.7);
  border: 1px solid rgba(52, 211, 153, 0.2);
  border-radius: 10px;
  padding: 10px 16px;
  color: #fff;
  font-family: var(--font-thai);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

#filter-year:focus {
  outline: none;
  border-color: var(--accent-mint);
}

/* Custom Styled Table */
.table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid rgba(52, 211, 153, 0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background-color: rgba(10, 22, 17, 0.9);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  transition: var(--transition-smooth);
  border-bottom: 2px solid rgba(52, 211, 153, 0.2);
  white-space: nowrap;
}

th:hover {
  background-color: rgba(52, 211, 153, 0.1);
  color: #fff;
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  vertical-align: top;
}

tr:nth-child(even) td {
  background-color: rgba(255, 255, 255, 0.01);
}

tr:hover td {
  background-color: rgba(52, 211, 153, 0.04);
}

.col-activities {
  max-width: 400px;
  font-size: 0.85rem;
}

.table-activity-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  margin-right: 6px;
  margin-bottom: 4px;
  font-weight: 500;
}

.badge-clean-air {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-green-village {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.badge-zero-waste {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.badge-clean-energy {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.activities-list-cell {
  list-style: none;
}

.activities-list-cell li {
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.activities-list-cell li:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

/* Upload View Styles */
.upload-container {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
}

.upload-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 32px;
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.upload-icon {
  font-size: 4rem;
  margin-bottom: 8px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

.upload-card h2 {
  color: #fff;
  font-size: 1.4rem;
}

.upload-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 500px;
}

.drag-drop-zone {
  border: 2px dashed rgba(52, 211, 153, 0.3);
  background: rgba(10, 22, 17, 0.5);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.drag-drop-zone:hover, .drag-drop-zone.dragover {
  border-color: var(--accent-mint);
  background: rgba(52, 211, 153, 0.05);
  box-shadow: 0 0 15px rgba(52, 211, 153, 0.1);
}

.drop-text {
  font-size: 1rem;
  color: var(--text-secondary);
}

.file-label {
  background: var(--accent-mint);
  color: var(--bg-primary);
  font-weight: 600;
  padding: 10px 24px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 12px rgba(52, 211, 153, 0.2);
}

.file-label:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(52, 211, 153, 0.4);
  background: #4ade80;
}

.file-info-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid var(--accent-mint);
  padding: 8px 16px;
  border-radius: 10px;
  margin-top: 8px;
}

.file-name {
  font-family: var(--font-eng);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent-mint);
}

.btn-clear-file {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition-smooth);
}

.btn-clear-file:hover {
  background: rgba(239, 68, 68, 0.15);
}

.upload-status {
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-top: 12px;
  width: 100%;
  max-width: 500px;
  text-align: center;
  font-weight: 500;
  animation: fadeIn 0.3s ease;
}

.status-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
  color: #10b981;
}

.status-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
  color: #f87171;
}

.instructions-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 28px;
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  height: fit-content;
}

.instructions-card h3 {
  color: #fff;
  font-size: 1.15rem;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(52, 211, 153, 0.2);
  padding-bottom: 8px;
}

.instructions-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.instructions-card li {
  font-size: 0.9rem;
  color: var(--text-primary);
  opacity: 0.9;
  position: relative;
  padding-left: 20px;
}

.instructions-card li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent-mint);
  font-weight: bold;
}

/* Footer Styling */
.main-footer {
  text-align: center;
  padding: 20px 0;
  color: var(--text-primary);
  opacity: 0.4;
  font-size: 0.8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 12px;
}

/* Custom Scrollbar for popups and lists */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
  background: rgba(52, 211, 153, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-mint);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .overview-summary-card {
    grid-template-columns: 1fr;
  }
  .upload-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .main-header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
    padding: 16px;
  }
  
  .header-logo-decor {
    display: none;
  }
  
  .header-title h1 {
    font-size: 1.6rem;
  }
  
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  
  .charts-grid-top {
    grid-template-columns: 1fr;
  }
  
  .search-filter-container {
    width: 100%;
  }
  
  #table-search {
    width: 100%;
  }
}
