/* Modern Mobile-First CSS for 2/3 Shelf-Life Calculator */
:root {
  --primary: #047857;
  --primary-hover: #065f46;
  --primary-light: #ecfdf5;
  --primary-border: #a7f3d0;
  
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-light: #fef2f2;
  --danger-border: #fecaca;

  --success: #16a34a;
  --success-light: #f0fdf4;
  --success-border: #bbf7d0;

  --amber: #d97706;
  --amber-light: #fffbeb;
  --amber-border: #fde68a;

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-raised: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  padding: 12px 12px 32px 12px;
  display: flex;
  justify-content: center;
}

.app-container {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
.app-header {
  text-align: center;
  padding: 8px 4px 4px 4px;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.header-icon {
  width: 14px;
  height: 14px;
}

.header-title {
  font-size: 24px;
  font-weight: 800;
  color: #064e3b;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.header-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.reference-banner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: #334155;
  background: #e2e8f0;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-weight: 500;
  margin-bottom: 10px;
}

.banner-icon {
  width: 14px;
  height: 14px;
  color: var(--primary);
}

.pwa-install-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background-color: #0f172a;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  margin-top: 6px;
  transition: background-color 0.15s ease;
}

.pwa-install-btn:hover {
  background-color: #1e293b;
}

.pwa-icon {
  width: 16px;
  height: 16px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

/* Form Styles */
.form-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

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

.form-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.sub-label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background-color: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.date-input {
  width: 100%;
  min-height: 48px; /* Touch target minimum for mobile */
  padding: 10px 14px;
  font-size: 16px; /* 16px prevents iOS/Android auto-zoom */
  font-weight: 600;
  color: var(--text-main);
  background-color: var(--surface-raised);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  cursor: pointer;
}

.date-input:focus {
  border-color: var(--primary);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.15);
}

/* Chips / Shortcuts */
.chips-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.chips-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0;
  -webkit-overflow-scrolling: touch;
}

.chips-row.wrap {
  flex-wrap: wrap;
}

.chip {
  min-height: 34px;
  padding: 6px 10px;
  background-color: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.chip:hover, .chip:active {
  background-color: var(--primary-light);
  border-color: var(--primary-border);
  color: var(--primary);
}

.chip-preset {
  background-color: #f8fafc;
  font-size: 11.5px;
  border-color: #cbd5e1;
}

.chip-sm {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 11px;
}

/* Advanced Collapsible */
.advanced-section {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-bottom: 12px;
  background-color: #fafafa;
}

.advanced-summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.chevron-icon {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

details[open] .chevron-icon {
  transform: rotate(180deg);
}

.advanced-content {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.alert-error {
  background-color: var(--danger-light);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.alert-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Buttons */
.button-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.btn-primary {
  flex: 2;
  background-color: var(--primary);
  color: white;
  box-shadow: 0 2px 4px rgba(4, 120, 87, 0.2);
}

.btn-primary:hover, .btn-primary:active {
  background-color: var(--primary-hover);
}

.btn-secondary {
  flex: 1;
  background-color: var(--surface-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover, .btn-secondary:active {
  background-color: #e2e8f0;
  color: var(--text-main);
}

.btn-icon {
  width: 18px;
  height: 18px;
}

/* Results Section */
.result-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Status Hero Card */
.status-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  border-width: 2px;
  transition: all 0.25s ease;
}

.status-card.status-red {
  background-color: #fef2f2;
  border-color: #ef4444;
  color: #991b1b;
}

.status-card.status-green {
  background-color: #f0fdf4;
  border-color: #22c55e;
  color: #14532d;
}

.status-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.status-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-red .status-icon-box {
  background-color: #dc2626;
  color: white;
}

.status-green .status-icon-box {
  background-color: #16a34a;
  color: white;
}

.status-icon {
  width: 26px;
  height: 26px;
}

.status-texts {
  display: flex;
  flex-direction: column;
}

.status-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.status-headline {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.2;
}

.status-description {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 4px;
}

/* Date Highlight Card */
.date-highlight-card {
  background: linear-gradient(135deg, #064e3b 0%, #047857 100%);
  color: white;
  border: none;
  text-align: center;
  padding: 18px;
}

.date-highlight-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.9;
  margin-bottom: 6px;
}

.date-icon {
  width: 14px;
  height: 14px;
}

.date-highlight-value {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.date-highlight-sub {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 4px;
}

/* Progress / Timeline Card */
.progress-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.progress-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.progress-badge {
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background-color: var(--surface-raised);
  color: var(--text-main);
}

.progress-track-wrapper {
  position: relative;
  padding-top: 18px;
  margin-bottom: 6px;
}

.progress-track {
  position: relative;
  height: 16px;
  background-color: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: visible;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background-color: #22c55e;
  transition: width 0.4s ease, background-color 0.4s ease;
}

.progress-bar-fill.fill-red {
  background-color: #dc2626;
}

.threshold-marker {
  position: absolute;
  top: -18px;
  bottom: -4px;
  width: 2px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.marker-flag {
  font-size: 10px;
  font-weight: 800;
  background-color: #0f172a;
  color: white;
  padding: 1px 4px;
  border-radius: 4px;
  white-space: nowrap;
}

.marker-line {
  flex: 1;
  width: 2px;
  background-color: #0f172a;
  border-left: 1px dashed white;
}

.progress-axis {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.axis-point {
  display: flex;
  flex-direction: column;
}

.axis-point.start {
  align-items: flex-start;
}

.axis-point.mid {
  align-items: center;
  font-weight: 700;
  color: var(--text-main);
}

.axis-point.end {
  align-items: flex-end;
}

.axis-label {
  font-size: 10px;
  text-transform: uppercase;
  opacity: 0.8;
}

.axis-val {
  font-weight: 600;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.metric-card.highlight-metric {
  border-color: #cbd5e1;
  background-color: #f8fafc;
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.metric-number {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
  margin: 4px 0 2px 0;
}

.metric-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* Guidance Card */
.guidance-card {
  background-color: #f8fafc;
  border-left: 4px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guidance-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.guidance-icon {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.guidance-text {
  font-size: 13px;
  color: #334155;
  line-height: 1.4;
}

/* Footer */
.app-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 12px 4px 0 4px;
}

.footer-sub {
  font-size: 10px;
  opacity: 0.75;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Desktop layout scaling */
@media (min-width: 640px) {
  body {
    padding: 24px 16px 48px 16px;
  }
  
  .app-container {
    max-width: 580px;
  }

  .header-title {
    font-size: 28px;
  }
}
