/* ===== Biovegi Mission Control - Design System ===== */
/* Brand: Green #42AB48 | Orange #F26728 | DarkGreen #14713C | Yellow #FFC82C */
/* Fonts: SVN-Gratelos Display (headlines) | Barlow Condensed (body) */

:root {
  /* Brand palette */
  --green: #42AB48;
  --orange: #F26728;
  --dark-green: #14713C;
  --yellow: #FFC82C;

  /* Extended palette */
  --ink: #0E1A14;
  --ink-2: #1A2B20;
  --ink-3: #283930;
  --surface: #0B1410;
  --surface-2: #11201A;
  --surface-3: #182B21;
  --border: rgba(66, 171, 72, 0.15);
  --border-2: rgba(66, 171, 72, 0.3);
  --text: #E8F5E9;
  --text-2: #A8C9A8;
  --text-3: #6B8E6B;
  --danger: #FF5252;
  --warn: #FFC82C;
  --ok: #42AB48;

  /* Stage colors */
  --stage-placed: #FFC82C;
  --stage-ack: #64B5F6;
  --stage-eta: #42AB48;
  --stage-checkup: #F26728;
  --stage-docs: #AB47BC;
  --stage-update: #8D6E63;
  --stage-arrived: #42AB48;

  /* Type */
  --font-display: 'SVN-Gratelos-Display', serif;
  --font-body: 'Barlow-Condensed', system-ui, sans-serif;

  /* Radius */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;

  /* Shadows */
  --shadow-1: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-2: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 24px rgba(66, 171, 72, 0.15);
}

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

html, body {
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Background grain texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(66, 171, 72, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(242, 103, 40, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* === Layout === */
.app {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 100vh;
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--dark-green), var(--green));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--yellow);
  box-shadow: 0 0 20px rgba(66, 171, 72, 0.3);
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: normal;
  color: var(--text);
  letter-spacing: 0.5px;
  line-height: 1;
}

.brand-text .subtitle {
  font-size: 12px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* === Stat Cards === */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}

.stat-card[data-accent="green"]::before { background: var(--green); }
.stat-card[data-accent="orange"]::before { background: var(--orange); }
.stat-card[data-accent="yellow"]::before { background: var(--yellow); }
.stat-card[data-accent="blue"]::before { background: #64B5F6; }

.stat-value {
  font-family: var(--font-display);
  font-size: 36px;
  line-height: 1;
  color: var(--text);
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-3);
  margin-top: 6px;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}

.stat-sub.overdue {
  color: var(--orange);
  font-weight: 700;
}

/* === Filter Bar === */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar .search {
  flex: 1;
  min-width: 200px;
}

.input, .select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 14px;
  width: 100%;
  transition: border-color 0.15s;
}

.input:focus, .select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(66, 171, 72, 0.15);
}

.input::placeholder { color: var(--text-3); }

.select {
  cursor: pointer;
  min-width: 140px;
}

/* === Shipment Cards === */
.shipment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shipment-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.shipment-card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow-2);
}

.shipment-card.overdue {
  border-left: 3px solid var(--orange);
}

/* Stage indicator dot */
.stage-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stage-dot.placed_order { background: var(--stage-placed); box-shadow: 0 0 8px var(--stage-placed); }
.stage-dot.acknowledged { background: var(--stage-ack); box-shadow: 0 0 8px var(--stage-ack); }
.stage-dot.eta_confirmed { background: var(--stage-eta); box-shadow: 0 0 8px var(--stage-eta); }
.stage-dot.routine_checkup { background: var(--stage-checkup); box-shadow: 0 0 12px var(--stage-checkup); animation: pulse 2s infinite; }
.stage-dot.documents_received { background: var(--stage-docs); }
.stage-dot.eta_updated { background: var(--stage-update); }
.stage-dot.arrived { background: var(--stage-arrived); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-dot.routine_checkup { animation: none; }
}

.shipment-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shipment-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.po-number {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text);
}

.freight-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 700;
}

.freight-badge.airfreight {
  background: rgba(100, 181, 246, 0.15);
  color: #64B5F6;
}

.freight-badge.seafreight {
  background: rgba(66, 171, 72, 0.15);
  color: var(--green);
}

.company-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 700;
}

.company-badge.vietnam {
  background: rgba(20, 113, 60, 0.25);
  color: #42AB48;
  border: 1px solid rgba(66, 171, 72, 0.3);
}

.company-badge.southern {
  background: rgba(242, 103, 40, 0.15);
  color: #F26728;
  border: 1px solid rgba(242, 103, 40, 0.3);
}

.shipment-meta {
  font-size: 14px;
  color: var(--text-2);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.shipment-meta span { display: inline-flex; align-items: center; gap: 4px; }

.shipment-route {
  font-size: 13px;
  color: var(--text-3);
}

.stage-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.checkup-flag {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.checkup-due {
  font-size: 12px;
  color: var(--warn);
  font-weight: 700;
}

.checkup-due.overdue {
  color: var(--orange);
  animation: blink 1.5s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
  .checkup-due.overdue { animation: none; }
}

/* === Mini Pipeline Bar === */
.pipeline-mini {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 4px;
}

.pipeline-mini .seg {
  height: 4px;
  flex: 1;
  background: var(--surface-3);
  border-radius: 2px;
}

.pipeline-mini .seg.done {
  background: var(--green);
}

.pipeline-mini .seg.current {
  background: var(--orange);
  box-shadow: 0 0 6px var(--orange);
}

/* === Buttons === */
.btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--r-sm);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--green);
  color: white;
}

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

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text);
}

.btn-sm {
  font-size: 12px;
  padding: 6px 14px;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 82, 82, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 82, 82, 0.1);
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  max-width: 700px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-2);
  transform: translateY(20px);
  transition: transform 0.2s;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 20px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  padding: 4px;
}

.modal-close:hover { color: var(--text); }

.modal-body { padding: 24px; }

/* Form */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-3);
  margin-bottom: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

textarea.input {
  resize: vertical;
  min-height: 60px;
  font-family: var(--font-body);
}

/* === Timeline === */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 16px 0;
}

.timeline-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  padding-bottom: 20px;
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item:last-child::before { display: none; }

.timeline-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--surface-3);
  z-index: 1;
}

.timeline-icon.active {
  background: var(--green);
  color: white;
}

.timeline-content {
  padding-top: 4px;
}

.timeline-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.timeline-time {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.timeline-notes {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--r-sm);
  border-left: 2px solid var(--border-2);
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* === Loading === */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-3);
}

/* === Responsive === */
@media (max-width: 900px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .shipment-card { grid-template-columns: auto 1fr; }
  .shipment-card .stage-badge { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 600px) {
  .app { padding: 0 16px; }
  .stats-bar { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 28px; }
  .form-row { grid-template-columns: 1fr; }
  .header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .header-actions { width: 100%; }
  .shipment-card { padding: 16px; gap: 12px; }
  .shipment-meta { flex-direction: column; gap: 4px; }
  .modal { max-height: 90vh; }
}

/* === Toast === */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 12px 20px;
  color: var(--text);
  font-size: 14px;
  box-shadow: var(--shadow-2);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 0.2s ease;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid #64B5F6; }

@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }
