/* Modern CSS with improved styling */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700&display=swap');

/* Base variables available to entire site */
:root {
  --primary-color: #0c8a56;
  --secondary-color: #1c7293;
  --accent-color: #00a896;
  --light-color: #f0f7f4;
  --dark-color: #2b303a;
  --recyclable-color: #2e933c;
  --energy-recyclable-color: #ff9f40;
  --organic-color: #8B4513;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --border-radius: 8px;
  --transition: all 0.3s ease;
}

/* Helper classes for text colors */
.text-recyclable {
    color: var(--recyclable-color);
}
.text-energy-recyclable {
    color: var(--energy-recyclable-color);
}
.text-organic {
    color: var(--organic-color);
}

/* Scope all other styles inside the waste-explorer-app class */
.waste-explorer-app {
  /* Reset inside our app container */
  box-sizing: border-box;
  font-family: 'Nunito', sans-serif;
  line-height: 1.6;
  position: relative;
}

.waste-explorer-app *,
.waste-explorer-app *::before,
.waste-explorer-app *::after {
  box-sizing: border-box;
}

/* Loading overlay */
.waste-explorer-app .loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  flex-direction: column;
}

.waste-explorer-app .loading-overlay.visible {
  display: flex;
}

.waste-explorer-app .spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #4CAF50;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.waste-explorer-app .loading-overlay p {
  margin-top: 20px;
  font-size: 18px;
}

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

/* Filter summary styles */
.waste-explorer-app .filter-summary {
  background-color: #f0f7f4;
  padding: 10px 15px;
  margin-bottom: 20px;
  border-radius: 8px;
  border-left: 4px solid #0c8a56;
}

.waste-explorer-app .filter-summary p {
  margin: 0;
  font-weight: 600;
  color: #2b303a;
}

/* Filter buttons styles */
.waste-explorer-app .filter-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-grow: 1;
  flex-basis: calc(33.333% - 2rem);
  margin-top: 1rem;
}

.waste-explorer-app #applyFiltersBtn {
  background-color: #0c8a56;
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  min-height: 44px;
}

.waste-explorer-app #applyFiltersBtn:hover {
  background-color: #097047;
  transform: translateY(-2px);
}

.waste-explorer-app .error-container {
  background: white;
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow);
  max-width: 80%;
  text-align: center;
  display: none;
  margin: 20px auto;
  border-left: 4px solid var(--energy-recyclable-color);
}

.waste-explorer-app .error-message-container {
  background: white;
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
  margin: 20px auto;
  max-width: 80%;
  border-left: 4px solid var(--energy-recyclable-color);
}

.waste-explorer-app .error-icon {
  color: var(--energy-recyclable-color);
  font-size: 48px;
  margin-bottom: 15px;
}

.waste-explorer-app .error-message {
  margin-bottom: 15px;
  font-size: 16px;
  color: var(--dark-color);
  line-height: 1.5;
}

.waste-explorer-app .error-refresh,
.waste-explorer-app .error-message-container button {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  margin-top: 10px;
}

.waste-explorer-app .error-refresh:hover,
.waste-explorer-app .error-message-container button:hover {
  background-color: #155e7a;
  transform: translateY(-2px);
}

/* Filter section */
.waste-explorer-app #filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 2rem;
  background: white;
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  align-items: flex-end;
  justify-content: space-between;
}

.waste-explorer-app #filters > div {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  flex-basis: calc(33.333% - 2rem);
  min-width: 220px;
  margin-bottom: 1rem;
}

.waste-explorer-app #filters label {
  font-weight: 600;
  color: var(--dark-color);
  margin-bottom: 0.6rem;
  position: relative;
  display: block;
  font-size: 0.95rem;
}

.waste-explorer-app #filters label i {
  margin-right: 8px;
  width: 18px;
  text-align: center;
  color: var(--primary-color);
}

.waste-explorer-app #filters label::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent-color);
  transition: var(--transition);
}

.waste-explorer-app #filters label:hover::after {
  width: 100%;
}

.waste-explorer-app #filters select, 
.waste-explorer-app #filters input {
  padding: 0.75rem 1rem;
  border: 1px solid #ccd1d9;
  border-radius: 6px;
  font-size: 1rem;
  transition: var(--transition);
  width: 100%;
  background-color: #fdfdfe;
  color: var(--dark-color);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg fill="%232b303a" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.2em;
  padding-right: 3rem;
}

.waste-explorer-app #filters input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
  background-image: none;
  padding-right: 1rem;
}

.waste-explorer-app #filters select:focus, 
.waste-explorer-app #filters input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(0, 168, 150, 0.25);
}

.waste-explorer-app #resetBtn {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  min-height: 44px;
  position: relative;
  overflow: hidden;
}

.waste-explorer-app #resetBtn i {
  margin-right: 5px;
}

.waste-explorer-app #resetBtn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.5s, height 0.5s;
}

.waste-explorer-app #resetBtn:hover {
  background-color: #155e7a;
  transform: translateY(-2px);
}

.waste-explorer-app #resetBtn:active::before {
  width: 300px;
  height: 300px;
}

/* Card-based grid layout */
.waste-explorer-app #dataGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
  min-height: 200px;
  position: relative;
}

.waste-explorer-app .data-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #999;
}

.waste-explorer-app .card {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  animation: cardFadeIn 0.6s ease-out;
}

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

.waste-explorer-app .card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.waste-explorer-app .card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.1));
  opacity: 0;
  transition: var(--transition);
  pointer-events: none;
}

.waste-explorer-app .card:hover::after {
  opacity: 1;
}

.waste-explorer-app .card-header {
  padding: 1.2rem;
  background-color: #308A34; /* Default green for cards */
  color: white;
  position: relative;
  overflow: hidden;
}

.waste-explorer-app .card-header::before {
  content: '';
  position: absolute;
  right: -50px;
  top: -50px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.1);
  transition: transform 0.5s ease-out;
}

.waste-explorer-app .card:hover .card-header::before {
  transform: scale(2.5);
}

.waste-explorer-app .recyclable {
  background-color: #308A34; /* Green for recyclable */
}

.waste-explorer-app .non-recyclable {
  background-color: var(--energy-recyclable-color);
}

.waste-explorer-app .card-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  position: relative;
  z-index: 1;
  color: white;
}

.waste-explorer-app .card-subtitle {
  font-size: 1rem;
  opacity: 0.9;
  position: relative;
  z-index: 1;
  color: white;
}

.waste-explorer-app .card-body {
  padding: 1.2rem;
}

.waste-explorer-app .card-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.waste-explorer-app .info-label {
  font-weight: 600;
  color: var(--dark-color);
}

.waste-explorer-app .info-value {
  text-align: right;
}

.waste-explorer-app .materials-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.waste-explorer-app .material-pill {
  background-color: #e9f7f5;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--accent-color);
  font-weight: 600;
  transition: var(--transition);
}

.waste-explorer-app .material-pill:hover {
  background-color: var(--accent-color);
  color: white;
  transform: translateY(-2px);
}

/* Detail page styling */
.waste-explorer-app #backBtn {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  padding: 0.7rem 1.5rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
}

.waste-explorer-app #backBtn:hover {
  background-color: #155e7a;
  transform: translateX(-5px);
}

.waste-explorer-app #brandName {
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  color: var(--dark-color);
  font-weight: 700;
  position: relative;
  display: inline-block;
}

.waste-explorer-app #brandName::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 0;
  width: 50px;
  height: 3px;
  background-color: var(--accent-color);
  transition: width 0.3s ease;
}

.waste-explorer-app #brandName:hover::after {
  width: 100%;
}

.waste-explorer-app .detail-container {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  animation: fadeIn 0.8s ease;
  margin-bottom: 3rem;
}

.waste-explorer-app .product-image {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  height: 350px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 15px;
}

.waste-explorer-app .product-image::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(0,0,0,0.05) 0%, rgba(255,255,255,0) 50%);
}

.waste-explorer-app .product-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.4s ease;
  border-radius: 4px;
}

.waste-explorer-app .product-image:hover img {
  transform: scale(1.05);
}

.waste-explorer-app #stats {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex: 1;
  width: 100%;
}

.waste-explorer-app .stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  width: 100%;
  justify-content: space-between;
}

.waste-explorer-app .stats-row .stat-card {
  flex: 1;
  min-width: 180px;
}

.waste-explorer-app .stat-card {
  background: white;
  padding: 1.2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  display: flex;
  gap: 1rem;
  align-items: center;
  transition: var(--transition);
}

.waste-explorer-app .stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.waste-explorer-app .stat-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-color);
  color: white;
  border-radius: 50%;
  font-size: 1.2rem;
  transition: var(--transition);
}

.waste-explorer-app .stat-card:hover .stat-icon {
  transform: rotate(360deg);
}

.waste-explorer-app .stat-text {
  display: flex;
  flex-direction: column;
}

.waste-explorer-app .stat-label {
  font-size: 0.9rem;
  color: #677;
}

.waste-explorer-app .stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--dark-color);
}

.waste-explorer-app .charts {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-bottom: 2rem;
  align-items: center;
  margin-top: 2rem;
}

.waste-explorer-app .chart-container {
  width: 75%;
  max-width: 800px;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  transition: var(--transition);
}

.waste-explorer-app .chart-container:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.waste-explorer-app .chart-title {
  text-align: center;
  margin-bottom: 1rem;
  color: var(--dark-color);
  font-weight: 600;
  position: relative;
  padding-bottom: 0.5rem;
}

.waste-explorer-app .chart-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 2px;
  background-color: var(--accent-color);
  transition: width 0.3s ease;
}

.waste-explorer-app .chart-container:hover .chart-title::after {
  width: 100px;
}

.waste-explorer-app .charts canvas {
  max-width: 100%;
  max-height: 400px;
  height: 350px !important;
  margin: 0 auto;
  transition: var(--transition);
}

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

/* Hide the table since we're switching to cards */
.waste-explorer-app #dataTable {
  display: none;
}

/* Styles moved from explorer.js */
.waste-explorer-app .active-filter {
  color: var(--accent-color) !important;
  font-weight: 700 !important;
}

.waste-explorer-app .active-filter::after {
  width: 100% !important;
}

.waste-explorer-app .small-btn {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  margin-top: 1rem;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
}

.waste-explorer-app .small-btn:hover {
  background-color: #155e7a;
  transform: translateY(-2px);
}

/* Styles for Emissions Table (moved from waste_explorer_detail.php) */
.waste-explorer-app .emissions-table-container {
  overflow-x: auto;
  margin-top: 20px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  border-radius: 8px;
}

.waste-explorer-app .emissions-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Nunito', sans-serif;
}

.waste-explorer-app .emissions-table th,
.waste-explorer-app .emissions-table td {
  padding: 12px 15px;
  text-align: center;
  border: 1px solid #ddd;
}

.waste-explorer-app .emissions-table th {
  background-color: #f8f9fa;
  font-weight: 700;
  color: #333;
}

.waste-explorer-app .emissions-table tr:first-child td {
  background-color: #f8f9fa;
  font-weight: 700;
}

.waste-explorer-app .emissions-table td.compliant {
  background-color: #e6ffed;
  color: #006400;
}

.waste-explorer-app .emissions-table td.non-compliant {
  background-color: #ffe6e6;
  color: #c00;
  font-weight: bold;
}

.waste-explorer-app .emissions-table td.not-applicable {
  background-color: #f0f0f0;
  color: #555;
}

.waste-explorer-app .emissions-table tr:nth-child(even) {
  background-color: #f9f9f9;
}

.waste-explorer-app #cpcbStandards td:first-child,
.waste-explorer-app #productEmissions td:first-child {
  text-align: left;
  font-weight: bold;
  background-color: #f0f0f0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .waste-explorer-app {
    padding: 0;
  }
  
  .waste-explorer-app #filters {
    flex-direction: column;
    padding: 1rem;
    gap: 0.8rem;
  }
  
  .waste-explorer-app #filters > div {
    width: 100%;
    margin-bottom: 0.8rem;
  }
  
  .waste-explorer-app #filters select, 
  .waste-explorer-app #filters input {
    width: 100%;
    font-size: 0.9rem;
    padding: 0.5rem;
  }
  
  .waste-explorer-app .filter-buttons {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
  }
  
  .waste-explorer-app #applyFiltersBtn,
  .waste-explorer-app #resetBtn {
    width: calc(50% - 5px);
    padding: 0.5rem;
    font-size: 0.9rem;
  }
  
  .waste-explorer-app .detail-container {
    flex-direction: column;
  }
  
  .waste-explorer-app #stats {
    width: 100%;
    padding: 1rem;
  }
  
  .waste-explorer-app .charts {
    flex-direction: column;
  }
  
  .waste-explorer-app .card-info {
    flex-direction: column;
  }
  
  .waste-explorer-app .info-value {
    margin-left: 0;
  }
  
  .waste-explorer-app #brandName {
    font-size: 1.8rem;
  }
  
  .waste-explorer-app .stats-row {
    flex-direction: column;
  }
  
  .waste-explorer-app .chart-container {
    width: 100%;
    margin-bottom: 20px;
  }

  .waste-explorer-app .emissions-table th,
  .waste-explorer-app .emissions-table td {
    padding: 8px 10px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .waste-explorer-app #stats {
    grid-template-columns: 1fr;
  }
  
  .waste-explorer-app .card-title {
    font-size: 1.2rem;
  }
}

/* Legend container next to buttons */
.waste-explorer-app .filter-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  flex-grow: 2;
  flex-basis: calc(66.666% - 2rem);
  min-width: 220px;
  margin-bottom: 1rem;
}

.waste-explorer-app .legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--dark-color);
}

.waste-explorer-app .legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}

.waste-explorer-app .legend-color.recyclable {
  background-color: #308A34;
}

.waste-explorer-app .legend-color.energy {
  background-color: var(--energy-recyclable-color);
}
  