/* Reset & General Settings */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #10b981; /* Silkworm Emerald Green */
  --primary-dark: #047857;
  --primary-light: #d1fae5;
  --secondary: #6366f1; /* Premium Indigo */
  --accent: #f59e0b; /* Safety Amber */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #f1f5f9;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Loading & Error Screens */
.loading-overlay, .error-container {
  position: fixed;
  inset: 0;
  background-color: var(--bg-main);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.spinner-container {
  text-align: center;
  position: relative;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--primary-light);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

.pulse-ring {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--primary);
  opacity: 0.15;
  animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.spinner-container p {
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
}

.error-card {
  background-color: var(--bg-card);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.error-icon {
  width: 56px;
  height: 56px;
  background-color: #fee2e2;
  color: #ef4444;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.error-icon svg {
  width: 32px;
  height: 32px;
}

.error-card h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.error-card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

.retry-btn {
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  width: 100%;
  transition: background-color 0.2s;
}

.retry-btn:hover {
  background-color: var(--primary-dark);
}

/* App Container */
.app-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--bg-main);
  padding-bottom: 48px;
  position: relative;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.02);
}

/* Hero Banner */
.hero-banner {
  height: 180px;
  background-image: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 24px;
  color: white;
  overflow: hidden;
}

.hero-banner .overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.3) 0%, transparent 60%);
}

.hero-content {
  position: relative;
  z-index: 1;
  width: 100%;
}

.badge-certified {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.badge-icon {
  width: 14px;
  height: 14px;
  color: #34d399;
}

.hero-content h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.hero-content .slogan {
  font-size: 12px;
  opacity: 0.8;
  font-weight: 400;
}

/* Certificate Summary Card */
.cert-summary-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 20px;
  margin: -24px 16px 20px;
  position: relative;
  z-index: 5;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.qr-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-block {
  display: flex;
  flex-col: column;
  flex-direction: column;
}

.info-block.align-right {
  align-items: flex-end;
}

.info-block .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  font-weight: 600;
}

.info-block .value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.info-block .value.code {
  font-family: 'Outfit', monospace;
  font-size: 14px;
  color: var(--text-secondary);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-pill.success {
  background-color: var(--primary-light);
  color: var(--primary-dark);
}

.cert-summary-card .divider {
  height: 1px;
  background-color: var(--border);
  margin: 16px 0;
}

.description-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Tabs Navigation */
.tabs-container {
  display: flex;
  background-color: var(--border);
  padding: 4px;
  border-radius: 12px;
  margin: 0 16px 20px;
}

.tab-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background-color: var(--bg-card);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

/* Tab Panels */
.tab-content-wrapper {
  padding: 0 16px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

/* Timeline Layout */
.timeline {
  position: relative;
  padding-left: 32px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 24px;
  bottom: 24px;
  width: 2px;
  background: linear-gradient(to bottom, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 4px;
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-badge {
  position: absolute;
  left: -32px;
  top: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: var(--bg-card);
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.timeline-badge svg {
  width: 16px;
  height: 16px;
}

/* Custom badge colors per step type */
.timeline-badge.detection { border-color: #ef4444; color: #ef4444; }
.timeline-badge.processing { border-color: #6366f1; color: #6366f1; }
.timeline-badge.harvesting { border-color: #f59e0b; color: #f59e0b; }
.timeline-badge.farming { border-color: #10b981; color: #10b981; }
.timeline-badge.germplasm { border-color: #14b8a6; color: #14b8a6; }

.timeline-card {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.2s;
}

.timeline-card:hover {
  transform: translateY(-2px);
}

.card-header {
  background-color: #f8fafc;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.step-num {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.5px;
}

.card-body {
  padding: 16px;
}

/* Detail list rows inside cards */
.node-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
}

.node-row:last-child {
  margin-bottom: 0;
}

.node-label {
  color: var(--text-muted);
  font-weight: 500;
}

.node-value {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
  max-width: 70%;
}

.node-description {
  background-color: #f8fafc;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 10px;
  border-left: 3px solid var(--border);
}

/* Image grid within cards */
.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.grid-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s;
  border: 1px solid var(--border);
}

.grid-image:hover {
  opacity: 0.9;
}

/* Empty data placeholder */
.no-data {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 8px 0;
}

/* Tab 2: Details List Card */
.details-list-card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 8px 16px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.detail-row:last-child {
  border-bottom: none;
}

.field-label {
  color: var(--text-muted);
  font-weight: 500;
}

.field-val {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
}

.field-val.code {
  font-family: 'Outfit', monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Tab 3: Source Cards */
.source-card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.source-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.source-logo-container {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f8fafc;
}

.source-logo-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.source-logo-container.map-icon {
  color: var(--primary);
  background-color: var(--primary-light);
  border: none;
}

.source-logo-container.map-icon svg {
  width: 24px;
  height: 24px;
}

.source-title-row h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.pill-badge {
  display: inline-block;
  background-color: #f1f5f9;
  color: #475569;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Processing Sub-Steps (Multiple stages) */
.proc-stage-item {
  border-bottom: 1px dashed var(--border);
  padding: 12px 0;
}

.proc-stage-item:first-child {
  padding-top: 0;
}

.proc-stage-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

/* Image Preview Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.modal-content {
  max-width: 100%;
  max-height: 80vh;
}

.modal-content img {
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Utility Helpers */
.mt-4 { margin-top: 16px; }
.hidden { display: none !important; }

/* Animations */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.15; }
  50% { transform: translateX(-50%) scale(1.3); opacity: 0; }
}

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

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
