/* ===================================================
   CitrusScan — Stylesheet
   Theme: Jeruk Keprok — Deep Reddish-Orange
   =================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Pastikan atribut hidden selalu menang atas CSS display */
[hidden] { display: none !important; }

:root {
  /* ── Keprok Orange Palette ───────────────────────── */
  --orange:        #F07A1A;   /* Oranye murni cerah */
  --orange-light:  #F59A3A;
  --orange-dark:   #D05F08;
  --orange-pale:   #FCCF9A;
  --peach-bg:      #FFF5E8;
  --peach-mid:     #FFE8C8;
  --green-ready:   #22C55E;
  --text-dark:     #1C1409;
  --text-mid:      #5A3D18;
  --text-light:    #A87840;
  --white:         #FFFFFF;
  --card-bg:       rgba(255,255,255,0.88);
  --card-border:   rgba(240,122,26,0.14);
  --shadow-sm:     0 2px 8px rgba(240,122,26,0.1);
  --shadow-md:     0 8px 32px rgba(240,122,26,0.14);
  --shadow-lg:     0 24px 64px rgba(240,122,26,0.18);
  --radius:        16px;
  --radius-sm:     10px;
  --transition:    0.25s cubic-bezier(0.4,0,0.2,1);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background: linear-gradient(145deg, #fff5e8 0%, #ffe8c8 30%, #ffd9a8 60%, #fff0e0 100%);
  min-height: 100vh;
  color: var(--text-dark);
  overflow-x: hidden;
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--peach-bg); }
::-webkit-scrollbar-thumb { background: var(--orange-pale); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--orange-light); }

/* ============ NAVBAR ============ */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(249,115,22,0.1);
  transition: box-shadow var(--transition);
}

.navbar.scrolled {
  box-shadow: 0 4px 24px rgba(249,115,22,0.1);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-dark);
  transition: opacity var(--transition);
}

.nav-logo:hover { opacity: 0.8; }

.logo-icon {
  font-size: 1.4rem;
  filter: drop-shadow(0 2px 4px rgba(249,115,22,0.3));
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}

.nav-link {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  text-decoration: none;
  color: var(--text-mid);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  transition: color var(--transition), background var(--transition);
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 2px; left: 50%; right: 50%;
  height: 2px;
  background: var(--orange);
  border-radius: 2px;
  transition: left var(--transition), right var(--transition);
}

.nav-link.active,
.nav-link:hover { color: var(--orange); }

.nav-link.active::after { left: 0.9rem; right: 0.9rem; }

.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-dark);
  border-radius: 2px;
  transition: var(--transition);
}

/* ============ HERO ============ */
.hero {
  padding: 140px 2rem 60px;
  text-align: center;
  position: relative;
}

.hero::before {
  content: '';
  position: absolute;
  top: 80px; left: 50%; transform: translateX(-50%);
  width: 600px; height: 300px;
  background: radial-gradient(ellipse, rgba(240,122,26,0.1) 0%, transparent 70%);
  pointer-events: none;
}

.hero-content {
  max-width: 720px;
  margin: 0 auto;
  position: relative;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text-dark);
  margin-bottom: 1rem;
}

.hero-highlight {
  color: var(--orange);
}

.hero-subtitle {
  font-size: 0.95rem;
  color: var(--text-mid);
  line-height: 1.7;
  font-weight: 400;
}

.hero-subtitle strong {
  color: var(--text-dark);
  font-weight: 600;
}

/* Mobile quick-action buttons */
.hero-mobile-actions {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.mobile-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 0.5rem;
  border-radius: 14px;
  border: 1.5px solid rgba(240,122,26,0.18);
  background: var(--white);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dark);
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(240,122,26,0.07);
}

.mobile-action-btn svg {
  transition: transform var(--transition);
}

.mobile-action-upload {
  color: var(--orange-dark);
}

.mobile-action-upload svg {
  color: var(--orange);
}

.mobile-action-camera {
  color: #166534;
}

.mobile-action-camera svg {
  color: #16A34A;
}

.mobile-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(240,122,26,0.14);
}

.mobile-action-btn:active {
  transform: scale(0.97);
}

.mobile-action-upload:hover {
  background: #FFF7ED;
  border-color: var(--orange);
}

.mobile-action-camera:hover {
  background: #F0FDF4;
  border-color: #16A34A;
  box-shadow: 0 6px 18px rgba(22,163,74,0.12);
}


/* ============ CONTAINER ============ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ============ DETEKSI SECTION ============ */
.deteksi-section {
  padding: 0 0 80px;
}

/* Action Bar */
.action-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
}

.model-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  color: #15803D;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.9rem;
  border-radius: 99px;
  white-space: nowrap;
  transition: all var(--transition);
}

.model-status.loading {
  background: #FFF7ED;
  border-color: var(--orange-pale);
  color: var(--orange-dark);
}

.model-status.error {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #DC2626;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s infinite;
}

.model-status.loading .status-dot {
  animation: spin-dot 1s linear infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.7); }
}

@keyframes spin-dot {
  0%   { box-shadow: 2px 0 0 currentColor; }
  50%  { box-shadow: -2px 0 0 currentColor; }
  100% { box-shadow: 2px 0 0 currentColor; }
}

.action-buttons {
  display: flex;
  gap: 0.75rem;
  margin-left: auto;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.2rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
}

.btn-primary {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 4px 12px rgba(249,115,22,0.35);
}

.btn-primary:hover {
  background: var(--orange-dark);
  box-shadow: 0 6px 20px rgba(249,115,22,0.45);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--white);
  color: var(--text-dark);
  border: 1.5px solid rgba(0,0,0,0.1);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  border-color: var(--orange-pale);
  color: var(--orange);
  box-shadow: 0 4px 12px rgba(249,115,22,0.1);
  transform: translateY(-1px);
}

.btn-danger {
  background: #FEF2F2;
  color: #DC2626;
  border: 1.5px solid #FECACA;
}

.btn-danger:hover {
  background: #DC2626;
  color: #fff;
  transform: translateY(-1px);
}

.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.8rem; border-radius: 8px; }

.btn-icon {
  background: rgba(255,255,255,0.9);
  color: var(--text-dark);
  border: 1.5px solid rgba(0,0,0,0.1);
  box-shadow: var(--shadow-sm);
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 8px;
}

.btn-icon:hover {
  border-color: var(--orange-pale);
  color: var(--orange);
  background: #FFF7ED;
  transform: translateY(-1px);
}

.btn-flip-active {
  background: var(--orange) !important;
  color: #fff !important;
  border-color: var(--orange) !important;
}

/* Main Panel */
.main-panel {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  align-items: start;
}

/* Canvas Panel */
.canvas-panel {
  background: var(--card-bg);
  border: 1.5px dashed rgba(249,115,22,0.3);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.dropzone {
  position: relative;
  min-height: 380px;
  display: flex;
  flex-direction: column; /* Ensure vertical stacking */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.dropzone.drag-over {
  background: rgba(249,115,22,0.06);
}

.dropzone-placeholder {
  text-align: center;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  pointer-events: none;
  width: 100%;
  margin: auto; /* Force perfect centering if parent is larger */
}

.drop-icon-wrapper {
  width: 88px; height: 88px;
  background: linear-gradient(135deg, #FFF7ED, #FFEDD5);
  border: 1.5px solid var(--orange-pale);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

.drop-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
}

.drop-sub {
  font-size: 0.85rem;
  color: var(--text-light);
}

#detection-canvas {
  max-width: 100%;
  max-height: 480px;
  display: block;
  object-fit: contain;
  border-radius: calc(var(--radius) - 2px);
}

#detection-canvas[hidden] {
  display: none !important;
}

#camera-feed {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  border-radius: calc(var(--radius) - 2px);
  display: block;
  position: relative;
  z-index: 1;
}

#camera-feed[hidden] {
  display: none !important;
}

/* Overlay canvas di atas video untuk deteksi real-time */
#overlay-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  max-height: 480px;
  pointer-events: none;
  border-radius: calc(var(--radius) - 2px);
  z-index: 2;
  object-fit: cover;
}

#overlay-canvas[hidden] {
  display: none !important;
}

.camera-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: rgba(249,115,22,0.04);
  border-top: 1px solid rgba(249,115,22,0.08);
}

/* Indikator LIVE */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #DC2626;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 0.25rem 0.7rem;
  border-radius: 99px;
  box-shadow: 0 2px 8px rgba(220,38,38,0.4);
}

.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: live-pulse 1.1s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.3; transform: scale(0.6); }
}

.image-controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  padding: 0.6rem 1rem;
  background: rgba(220,38,38,0.04);
  border-top: 1px solid rgba(220,38,38,0.08);
  animation: fade-in 0.25s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Result Panel */
.result-panel {
  background: var(--white);
  border: 1px solid rgba(249,115,22,0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.25rem 0.75rem;
}

.result-icon { font-size: 1.25rem; }

.result-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
}

.result-divider {
  height: 1px;
  background: linear-gradient(90deg, var(--orange-pale), transparent);
  margin: 0 1.25rem;
}

.result-body {
  padding: 1rem 1.25rem;
  flex: 1;
  min-height: 180px;
  display: flex;
  flex-direction: column;
}

.result-empty {
  color: var(--text-light);
  font-size: 0.88rem;
  text-align: center;
  margin: auto;
  font-style: italic;
}

/* Result Items */
.result-items {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--peach-bg);
  border: 1px solid var(--orange-pale);
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  animation: slide-in 0.3s ease;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.result-item-emoji { font-size: 1.2rem; }

.result-item-info { flex: 1; }

.result-item-class {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.3;
}

.result-item-conf {
  font-size: 0.75rem;
  color: var(--text-mid);
}

.result-item-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
}

.badge-matang    { background: #FCCF9A; color: #7C3508; }
.badge-setengah  { background: #FEF3B0; color: #713F12; }
.badge-mentah    { background: #D1FAE5; color: #065F46; }

/* Stats */
.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid rgba(240,122,26,0.1);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem;
  gap: 0.2rem;
}

.stat-item + .stat-item {
  border-left: 1px solid rgba(240,122,26,0.1);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--orange-dark);
}

/* ============ NUTRISI SECTION ============ */
.nutrisi-section {
  padding: 60px 0 80px;
  background: linear-gradient(180deg, transparent, rgba(240,122,26,0.05));
}

.section-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.section-title {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.section-sub {
  color: var(--text-mid);
  font-size: 0.95rem;
}

.nutrisi-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.nutrisi-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid transparent;
  transition: transform var(--transition), box-shadow var(--transition);
}

.nutrisi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

/* Card borders — Keprok palette */
.card-matang   { border-color: #FCCF9A; }
.card-setengah { border-color: #FEF3B0; }
.card-mentah   { border-color: #BBF7D0; }

.nutrisi-badge {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text-dark);
}

.nutrisi-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.nutrisi-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.nutrisi-label {
  width: 90px;
  flex-shrink: 0;
  color: var(--text-mid);
  font-weight: 500;
}

.nutrisi-bar-wrap {
  flex: 1;
  height: 6px;
  background: #F5F5F4;
  border-radius: 99px;
  overflow: hidden;
}

.nutrisi-bar {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--orange-light), var(--orange));
  border-radius: 99px;
  animation: grow-bar 1s ease both;
  animation-delay: 0.3s;
}

@keyframes grow-bar {
  from { width: 0 !important; }
}

.card-setengah .nutrisi-bar { background: linear-gradient(90deg, #FCD34D, #F59E0B); }
.card-mentah   .nutrisi-bar { background: linear-gradient(90deg, #4ADE80, #16A34A); }

.nutrisi-val {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dark);
  width: 45px;
  text-align: right;
}

.nutrisi-desc {
  font-size: 0.82rem;
  color: var(--text-mid);
  line-height: 1.6;
  padding-top: 1rem;
  border-top: 1px solid #F5F5F4;
}

/* ============ FOOTER ============ */
.footer {
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(240,122,26,0.1);
  padding: 1.5rem 2rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.footer-copy {
  font-size: 0.78rem;
  color: var(--text-light);
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-dark);
  color: #fff;
  padding: 0.65rem 1.5rem;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  z-index: 999;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ============ LOADING OVERLAY ============ */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,247,237,0.8);
  border-radius: inherit;
  backdrop-filter: blur(4px);
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--orange-pale);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .main-panel {
    grid-template-columns: 1fr;
  }

  .nutrisi-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  /* ── Navbar mobile ── */
  .nav-links { display: none; }
  .nav-hamburger {
    display: flex;
    position: absolute;
    right: 1.25rem;
  }
  .nav-container {
    position: relative;
    justify-content: center;
  }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px; left: 0; right: 0;
    background: rgba(255,255,255,0.98);
    padding: 1rem;
    border-bottom: 1px solid rgba(249,115,22,0.1);
    box-shadow: var(--shadow-md);
  }

  /* ── Hero mobile ── */
  .hero {
    padding: 90px 2rem 1.5rem;
    text-align: center;
  }
  .hero::before { display: none; }
  .hero-content { max-width: 100%; }

  .hero-title {
    font-size: 1.75rem;
    line-height: 1.2;
    margin-bottom: 0.6rem;
  }

  .hero-subtitle {
    font-size: 0.86rem;
    line-height: 1.6;
  }

  .hero-mobile-actions { display: grid; }

  /* ── Action bar mobile: hide desktop buttons ── */
  .action-buttons { display: none !important; }
  .action-bar {
    flex-direction: row;
    align-items: center;
    padding: 0.75rem 1rem;
  }

  /* ── Dropzone smaller on mobile ── */
  .dropzone { min-height: 220px; }

  /* ── Camera controls compact ── */
  .camera-controls {
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
  }
  .btn-icon {
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
  }
  .live-indicator {
    font-size: 0.68rem;
    padding: 0.22rem 0.6rem;
  }

  .nutrisi-cards { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; text-align: center; }

  .toast {
    bottom: 1.5rem;
    font-size: 0.8rem;
    padding: 0.55rem 1.2rem;
  }
}
