/* ==========================================================================
   EcoPlate Analyzer — Stylesheet
   Primary color: Teal #009688
   ========================================================================== */

/* ---------- Reset / Base ---------- */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------- Header ---------- */

header {
  background: #009688;
  color: #fff;
  padding: 0.75rem 1.5rem 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding-bottom: 0.5rem;
}

/* ---------- Tab Navigation ---------- */

nav {
  display: flex;
  gap: 4px;
}

.tab-btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  background: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.85);
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.tab-btn.active {
  background: #f5f5f5;
  color: #009688;
}

/* ---------- Tab Content ---------- */

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
}

.tab-content {
  display: none;
}

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

/* ---------- Ecoplate Grid (8 rows x 12 cols) ---------- */

#ecoplate-grid {
  margin: 1rem 0;
}

.ecoplate-table {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2px;
  max-width: 100%;
}

.ecoplate-cell {
  border: 2px solid rgba(0, 150, 136, 0.9);
  border-radius: 4px;
  padding: 0.35rem 0.25rem;
  text-align: center;
  font-size: 0.78rem;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
  min-height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ecoplate-cell:hover {
  background: rgba(0, 150, 136, 0.1);
}

.ecoplate-cell.highlighted {
  background: rgba(0, 150, 136, 0.2);
}

.ecoplate-cell.selected {
  background: rgba(0, 150, 136, 0.35);
  font-weight: 600;
}

.ecoplate-cell.disabled {
  opacity: 0.4;
  cursor: default;
}

.ecoplate-row-label,
.ecoplate-col-label {
  font-weight: 600;
  font-size: 0.8rem;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Metadata Form (3-column layout) ---------- */

#metadata-form {
  margin: 1rem 0;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.metadata-panel {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1rem;
}

.metadata-panel h3 {
  font-size: 0.95rem;
  color: #009688;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid rgba(0, 150, 136, 0.25);
  padding-bottom: 0.4rem;
}

/* ---------- Form Elements ---------- */

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #555;
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.88rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  color: #333;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 0.6rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #009688;
  box-shadow: 0 0 0 2px rgba(0, 150, 136, 0.2);
}

input[type="checkbox"] {
  accent-color: #009688;
  width: 1rem;
  height: 1rem;
  vertical-align: middle;
  margin-right: 0.35rem;
}

textarea {
  resize: vertical;
  min-height: 3rem;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #009688;
  color: #fff;
}

.btn-primary:hover {
  background: #00796b;
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover {
  background: #bdbdbd;
}

.btn-danger {
  background: #e53935;
  color: #fff;
}

.btn-danger:hover {
  background: #c62828;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#load-actions {
  margin: 1rem 0;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ---------- Messages ---------- */

.message {
  padding: 0.6rem 1rem;
  border-radius: 4px;
  font-size: 0.88rem;
  font-weight: 500;
  margin: 0.75rem 0;
  animation: msg-fade-in 0.25s ease;
}

.message.success {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}

.message.error {
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
}

.message.info {
  background: #e0f2f1;
  color: #00695c;
  border: 1px solid #80cbc4;
}

.message.fade-out {
  animation: msg-fade-out 0.4s ease forwards;
}

@keyframes msg-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes msg-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ---------- Filter Lists (multi-select, 8 columns) ---------- */

.filter-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filter-list {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.5rem;
  max-height: 220px;
  overflow-y: auto;
}

.filter-list h4 {
  font-size: 0.8rem;
  color: #009688;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.filter-list label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  padding: 0.15rem 0;
  cursor: pointer;
}

.filter-list label:hover {
  color: #009688;
}

/* ---------- Results Tables ---------- */

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0.75rem 0;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.results-table thead th {
  background: #009688;
  color: #fff;
  padding: 0.55rem 0.7rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

.results-table tbody td {
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid #eee;
}

.results-table tbody tr:nth-child(even) {
  background: #f9f9f9;
}

.results-table tbody tr:hover {
  background: rgba(0, 150, 136, 0.06);
}

/* ---------- Record Cards ---------- */

.record-card {
  background: #fff;
  border: 1px solid #ddd;
  border-left: 4px solid #009688;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.6rem;
  transition: box-shadow 0.2s;
}

.record-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.record-card .card-title {
  font-weight: 600;
  color: #009688;
  margin-bottom: 0.3rem;
}

.record-card .card-meta {
  font-size: 0.82rem;
  color: #777;
}

/* ---------- Scroll Areas ---------- */

.scroll-area {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.75rem;
  background: #fff;
}

.scroll-area::-webkit-scrollbar {
  width: 6px;
}

.scroll-area::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 3px;
}

.scroll-area::-webkit-scrollbar-thumb {
  background: #009688;
  border-radius: 3px;
}

/* ---------- Chart Container ---------- */

.chart-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 1rem auto;
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chart-container canvas {
  width: 100% !important;
  height: auto !important;
  max-height: 450px;
}

/* ---------- File Selector ---------- */

#file-selector {
  margin-bottom: 1rem;
}

.file-drop-zone {
  border: 2px dashed rgba(0, 150, 136, 0.5);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  color: #777;
  background: #fff;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.file-drop-zone:hover,
.file-drop-zone.drag-over {
  border-color: #009688;
  background: rgba(0, 150, 136, 0.05);
}

.file-drop-zone p {
  margin-bottom: 0.5rem;
}

/* ---------- Utility ---------- */

.text-teal { color: #009688; }
.text-muted { color: #999; font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none !important; }

/* ---------- Section headings inside tabs ---------- */

.section-heading {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid rgba(0, 150, 136, 0.3);
}

/* ---------- Responsive (>= 1024px target) ---------- */

@media (max-width: 1200px) {
  .filter-row {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---------- About Page ---------- */

.about-page {
  max-width: 900px;
}

.about-intro {
  font-size: 0.95rem;
  color: #555;
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.about-card {
  background: #fff;
  border: 1px solid #ddd;
  border-left: 4px solid #009688;
  border-radius: 6px;
  padding: 1rem 1.25rem;
}

.about-card h3 {
  font-size: 0.95rem;
  color: #009688;
  margin-bottom: 0.4rem;
}

.about-card p {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.6;
}

.data-card {
  padding: 0;
  overflow: hidden;
}

.data-card h3,
.data-card p,
.data-card .about-link {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.data-card h3 {
  padding-top: 1rem;
}

.data-card .about-link {
  padding-bottom: 1rem;
}

.data-card-banner {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.data-card-banner svg {
  width: 100%;
  height: 100%;
}

.data-card-meta {
  display: flex;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem 0;
}

.popularity-badge,
.sentiment-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  letter-spacing: 0.02em;
}

.popularity-badge.high {
  background: #fef3c7;
  color: #92400e;
}

.popularity-badge.medium {
  background: #e0f2fe;
  color: #075985;
}

.popularity-badge.low {
  background: #f1f5f9;
  color: #64748b;
}

.sentiment-badge.positive {
  background: #dcfce7;
  color: #166534;
}

.sentiment-badge.neutral {
  background: #f1f5f9;
  color: #475569;
}

.data-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.25rem 1.25rem 0.5rem;
}

.data-card-tags .tag {
  display: inline-block;
  background: #e2e8f0;
  color: #475569;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
}

.about-link {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: #009688;
  font-weight: 500;
  text-decoration: none;
}

.about-link:hover {
  text-decoration: underline;
}

.about-explainer {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.explainer-step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.explainer-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.explainer-icon svg {
  width: 36px;
  height: 36px;
}

.explainer-step h4 {
  font-size: 0.95rem;
  color: #2d3748;
  margin-bottom: 0.2rem;
}

.explainer-step p {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.6;
}

/* ---------- Learning Carousel ---------- */

.carousel-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.carousel-track {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0;
  scrollbar-width: none;
}

.carousel-track::-webkit-scrollbar {
  display: none;
}

.carousel-slide {
  flex: 0 0 280px;
  scroll-snap-align: start;
  background: #fff;
  border: 1px solid #ddd;
  border-top: 4px solid var(--accent, #009688);
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 260px;
  transition: box-shadow 0.2s;
}

.carousel-slide:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.slide-icon {
  width: 40px;
  height: 40px;
  color: var(--accent, #009688);
  margin-bottom: 0.6rem;
}

.slide-icon svg {
  width: 100%;
  height: 100%;
}

.slide-type {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent, #009688);
  margin-bottom: 0.25rem;
}

.carousel-slide h3 {
  font-size: 0.95rem;
  color: #2d3748;
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

.carousel-slide p {
  font-size: 0.82rem;
  color: #555;
  line-height: 1.5;
  flex: 1;
}

.slide-link {
  display: inline-block;
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--accent, #009688);
  font-weight: 600;
  text-decoration: none;
}

.slide-link:hover {
  text-decoration: underline;
}

.carousel-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid #ddd;
  border-radius: 50%;
  background: #fff;
  font-size: 1.4rem;
  line-height: 1;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.carousel-btn:hover {
  background: #009688;
  color: #fff;
  border-color: #009688;
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ddd;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s;
}

.carousel-dot.active {
  background: #009688;
}

.learning-type {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #009688;
  margin-bottom: 0.25rem;
}

.about-note {
  background: #e0f2f1;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  font-size: 0.85rem;
  color: #00695c;
  line-height: 1.6;
}

.about-note a {
  color: #00695c;
  font-weight: 600;
}

@media (max-width: 1024px) {
  main {
    padding: 1rem;
  }

  .metadata-grid {
    grid-template-columns: 1fr 1fr;
  }

  .filter-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  header h1 {
    font-size: 1.2rem;
  }

  .tab-btn {
    font-size: 0.82rem;
    padding: 0.4rem 0.9rem;
  }
}
