/* classify.css — Upload form, result page, and PWA install banner */

/* ─── Hidden file inputs ─────────────────────────────────────────── */
.file-input-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}

/* ─── App shell ─────────────────────────────────────────────────── */
.app-page {
  background: var(--bg, #f9fafb);
  min-height: 100vh;
}

/* ─── Upload Page ────────────────────────────────────────────────── */
.classify-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 1rem 5rem;
}

.upload-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07), 0 8px 24px rgba(0,0,0,.06);
  padding: 1.5rem;
}

.upload-title {
  font-family: 'Instrument Serif', serif;
  font-size: 1.75rem;
  font-weight: 400;
  margin: 0 0 .3rem;
  color: #111;
}

.upload-subtitle {
  color: #6b7280;
  margin: 0 0 1.25rem;
  font-size: .9rem;
}

.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #b91c1c;
  padding: .75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: .9rem;
}

/* ─── Mobile-first camera action buttons ─────────────────────────── */
.camera-actions {
  display: flex;
  gap: .75rem;
  margin-bottom: 1rem;
}

.btn-camera,
.btn-gallery {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .85rem .5rem;
  border-radius: 10px;
  border: none;
  font-size: .95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, transform .1s;
  /* min 44px touch target */
  min-height: 52px;
}

.btn-camera {
  background: #16a34a;
  color: #fff;
}
.btn-camera:hover { background: #15803d; }
.btn-camera:active { transform: scale(.97); }

.btn-gallery {
  background: #f3f4f6;
  color: #374151;
}
.btn-gallery:hover { background: #e5e7eb; }
.btn-gallery:active { transform: scale(.97); }

.btn-icon { font-size: 1.1rem; }

/* ─── Desktop drop zone ──────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.drop-zone:hover,
.drop-zone:focus,
.drop-zone.drag-over {
  border-color: #22c55e;
  background: #f0fdf4;
  outline: none;
}

.drop-zone-content {
  text-align: center;
  padding: 1.5rem;
  pointer-events: none;
}
.drop-icon { font-size: 2rem; margin-bottom: .4rem; }
.drop-label { color: #374151; font-weight: 500; margin: 0 0 .25rem; font-size: .9rem; }
.drop-link { color: #16a34a; text-decoration: underline; }
.drop-hint { color: #9ca3af; font-size: .78rem; margin: 0; }

.drop-preview { width: 100%; position: relative; }
.drop-preview img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  display: block;
}
.preview-remove {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: rgba(0,0,0,.6);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .4rem .7rem;
  font-size: .8rem;
  cursor: pointer;
  /* 44px touch target */
  min-height: 44px;
  min-width: 44px;
}

/* ─── Location field ─────────────────────────────────────────────── */
.location-field { margin-top: 1.1rem; }
.location-field label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: .4rem;
}
.location-field .optional { color: #9ca3af; font-weight: 400; }
.location-field input {
  width: 100%;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  padding: .7rem .9rem;
  font-size: 1rem; /* ≥16px prevents iOS auto-zoom */
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
  box-sizing: border-box;
  /* 44px touch target */
  min-height: 44px;
}
.location-field input:focus { border-color: #22c55e; }

/* ─── Submit button ──────────────────────────────────────────────── */
.btn-classify {
  margin-top: 1.25rem;
  width: 100%;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .9rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s, transform .1s;
  /* 44px+ touch target */
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}
.btn-classify:hover:not(:disabled) { background: #15803d; }
.btn-classify:active:not(:disabled) { transform: scale(.98); }
.btn-classify:disabled { opacity: .55; cursor: not-allowed; }

.btn-spinner {
  display: none;
  align-items: center;
  gap: .5rem;
}

/* Spinning indicator */
.spinner-icon {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.classify-hint {
  text-align: center;
  font-size: .78rem;
  color: #9ca3af;
  margin: .5rem 0 0;
}

/* ─── Full-screen loading overlay ────────────────────────────────── */
.classify-overlay {
  position: fixed;
  inset: 0;
  background: rgba(249,250,251,.93);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.overlay-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 4px 32px rgba(0,0,0,.12);
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 300px;
  width: 90%;
}

.overlay-spinner {
  width: 52px; height: 52px;
  border: 4px solid #dcfce7;
  border-top-color: #16a34a;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 1.25rem;
}

.overlay-title {
  font-weight: 600;
  color: #111;
  font-size: 1rem;
  margin: 0 0 1.1rem;
}

.progress-bar-wrap {
  background: #e5e7eb;
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  margin-bottom: .75rem;
}

.progress-bar {
  height: 100%;
  background: #16a34a;
  border-radius: 999px;
  width: 0%;
  transition: width .6s ease-out;
}

.overlay-hint {
  font-size: .8rem;
  color: #9ca3af;
  margin: 0;
  transition: opacity .3s;
}

/* ─── Recent scans ───────────────────────────────────────────────── */
.recent-section { margin-top: 2rem; }
.recent-title {
  font-size: .95rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 .75rem;
}
.recent-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
}
.recent-card {
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  text-decoration: none;
  transition: transform .15s, box-shadow .15s;
  /* 44px min touch target (grid handles width) */
  min-height: 44px;
}
.recent-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.recent-img-wrap { aspect-ratio: 1; overflow: hidden; background: #f3f4f6; }
.recent-img-wrap img { width: 100%; height: 100%; object-fit: cover; }
.recent-meta { padding: .45rem .55rem; }
.recent-sub { display: block; font-size: .72rem; color: #6b7280; margin-top: .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Category badges ────────────────────────────────────────────── */
.recent-category,
.result-category {
  display: inline-block;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 600;
  padding: .2rem .55rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.category-PET-plastic, .category-pet-plastic     { background: #dbeafe; color: #1d4ed8; }
.category-HDPE-plastic, .category-hdpe-plastic   { background: #ede9fe; color: #6d28d9; }
.category-glass                                   { background: #cffafe; color: #0e7490; }
.category-paper                                   { background: #fef9c3; color: #a16207; }
.category-cardboard                               { background: #ffedd5; color: #c2410c; }
.category-metal                                   { background: #e5e7eb; color: #374151; }
.category-organic                                 { background: #dcfce7; color: #166534; }
.category-e-waste                                 { background: #fce7f3; color: #9d174d; }
.category-other                                   { background: #f3f4f6; color: #6b7280; }

/* ─── Result Page ────────────────────────────────────────────────── */
.result-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1rem 5rem;
}

/* Mobile: stacked. Desktop (≥600px): side-by-side */
.result-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07), 0 8px 24px rgba(0,0,0,.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.result-image-wrap { background: #f3f4f6; }
/* Mobile: image fills width, capped height */
.result-image {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  display: block;
}

.result-body { padding: 1.25rem; flex: 1; }

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}

.result-id { min-width: 0; flex: 1; }

.result-item-name {
  font-family: 'Instrument Serif', serif;
  /* Fluid type: 1.5rem on 375px, 1.75rem on larger */
  font-size: clamp(1.4rem, 4vw, 1.75rem);
  font-weight: 400;
  margin: .3rem 0 0;
  color: #111;
  /* Prevent overflow on very long item names */
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Confidence ring — readable at small sizes */
.result-confidence { text-align: center; flex-shrink: 0; }
.confidence-ring {
  position: relative;
  width: 60px; height: 60px;
  color: #16a34a;
}
.confidence-svg { width: 100%; height: 100%; }
.confidence-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 700;
  color: #111;
}
.confidence-text { font-size: .68rem; color: #9ca3af; margin: .2rem 0 0; }

.result-location { font-size: .82rem; color: #6b7280; margin: 0 0 1rem; }

.disposal-section { border-top: 1px solid #f3f4f6; padding-top: 1rem; }
.disposal-title { font-size: .95rem; font-weight: 600; color: #111; margin: 0 0 .6rem; }
.disposal-body {
  font-size: .88rem;
  color: #374151;
  line-height: 1.7;
}

/* CTA buttons — stacked on mobile by default */
.result-actions {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  margin-top: 1.5rem;
}
.btn-primary {
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .75rem 1.25rem;
  font-size: .95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s;
  text-align: center;
  display: block;
  /* 44px touch target */
  min-height: 48px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-primary:hover { background: #15803d; }
.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: none;
  border-radius: 8px;
  padding: .75rem 1.25rem;
  font-size: .95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s;
  /* 44px touch target */
  min-height: 48px;
}
.btn-secondary:hover { background: #e5e7eb; }

/* Feedback */
.result-feedback {
  margin-top: 1.25rem;
  text-align: center;
  color: #9ca3af;
  font-size: .85rem;
}
.result-feedback p { margin: 0 0 .5rem; }
.feedback-btns { display: flex; gap: .5rem; justify-content: center; }
.feedback-btn {
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  padding: .5rem 1.1rem;
  font-size: .85rem;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s;
  /* 44px touch target */
  min-height: 44px;
}
.feedback-btn:hover { background: #f3f4f6; border-color: #d1d5db; }
.feedback-btn:disabled { opacity: .6; cursor: default; }
.feedback-selected { background: #f0fdf4; border-color: #86efac; }

/* ─── PWA Install banner ─────────────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -4px 24px rgba(0,0,0,.1);
  z-index: 900;
  padding: 0;
  animation: slideUp .3s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.install-banner-inner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .9rem 1rem;
  max-width: 560px;
  margin: 0 auto;
}

.install-icon { font-size: 1.75rem; flex-shrink: 0; }

.install-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.install-text strong { font-size: .88rem; color: #111; line-height: 1.3; }
.install-text span   { font-size: .78rem; color: #6b7280; line-height: 1.3; }

.install-btn {
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .55rem 1.1rem;
  font-size: .88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  min-height: 44px;
}
.install-dismiss {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  padding: .4rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Responsive breakpoints ─────────────────────────────────────── */
/* 375px and below — smallest iPhone SE */
@media (max-width: 375px) {
  .upload-title { font-size: 1.5rem; }
  .camera-actions { gap: .5rem; }
  .btn-camera, .btn-gallery { font-size: .85rem; padding: .75rem .4rem; }
  .recent-grid { grid-template-columns: repeat(2, 1fr); }
  .result-body { padding: 1rem; }
  .result-actions { gap: .5rem; }
}

/* 480px — compact phones */
@media (max-width: 480px) {
  .recent-grid { grid-template-columns: repeat(2, 1fr); }
  .upload-card { padding: 1.25rem; }
}

/* 600px and above — tablet / desktop */
@media (min-width: 600px) {
  .classify-main { padding: 2rem 1rem 4rem; }
  .upload-card { padding: 2rem 2rem 2.5rem; }
  .upload-title { font-size: 2rem; }

  /* Side-by-side result layout */
  .result-card { flex-direction: row; }
  .result-image-wrap { flex: 0 0 260px; }
  .result-image { max-height: 100%; height: 100%; }
  .result-body { padding: 1.75rem 2rem; }
  .result-actions { flex-direction: row; }
  .btn-primary, .btn-secondary { flex: 1; }

  /* Drop zone more prominent on desktop */
  .drop-zone { min-height: 160px; }

  /* Desktop: hide camera action buttons (they can use the drop zone) */
  /* Actually keep them — some desktop users prefer clicking vs drag */
}

/* Large desktop */
@media (min-width: 960px) {
  .result-image-wrap { flex: 0 0 300px; }
}
