/* ═══════════════════════════════════════════════════════
   FreightPilot — Group Buy Board
   Dark theme: ice-blue / aurora-green palette
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #263548;
  --bg-input: #0f172a;
  --border: #334155;
  --border-light: #475569;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --ice-blue: #7dd3fc;
  --ice-blue-dim: #38bdf8;
  --aurora-green: #4ade80;
  --aurora-green-dim: #22c55e;
  --aurora-green-bg: rgba(74, 222, 128, 0.1);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.1);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.1);
  --shipped: #a78bfa;
  --shipped-bg: rgba(167, 139, 250, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────── */

.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon { font-size: 24px; }

.logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ice-blue);
  letter-spacing: -0.5px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--aurora-green-bg);
  color: var(--aurora-green);
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.nav { display: flex; gap: 4px; }

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.nav-link.active { color: var(--ice-blue); background: rgba(125, 211, 252, 0.1); }

/* ─── Main ───────────────────────────────────────────── */

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ─── Page Header ────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-header p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

/* ─── Buttons ────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--aurora-green);
  color: #0f172a;
}
.btn-primary:hover { background: var(--aurora-green-dim); transform: translateY(-1px); }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-light); color: var(--text-primary); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid transparent;
}
.btn-danger:hover { border-color: var(--danger); }

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

/* ─── Cards Grid ─────────────────────────────────────── */

.orders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.order-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.2s;
  cursor: pointer;
}

.order-card:hover {
  border-color: var(--ice-blue-dim);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.order-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.order-village {
  font-size: 18px;
  font-weight: 700;
  color: var(--ice-blue);
}

.order-status {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-open { background: var(--aurora-green-bg); color: var(--aurora-green); }
.status-closed { background: var(--warning-bg); color: var(--warning); }
.status-shipped { background: var(--shipped-bg); color: var(--shipped); }

.order-description {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.order-coordinator {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.order-coordinator strong { color: var(--text-secondary); }

/* ─── Progress Bar ───────────────────────────────────── */

.progress-section { margin-bottom: 12px; }

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}

.progress-weight {
  color: var(--text-primary);
  font-weight: 600;
}

.progress-target {
  color: var(--text-muted);
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--bg-primary);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s ease-out;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.15) 50%,
    transparent 100%
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-low { background: linear-gradient(90deg, #f87171, #fb923c); }
.progress-mid { background: linear-gradient(90deg, #fbbf24, #facc15); }
.progress-high { background: linear-gradient(90deg, #4ade80, #22c55e); }
.progress-full { background: linear-gradient(90deg, #7dd3fc, #38bdf8); }

.order-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── Order Detail Page ──────────────────────────────── */

.order-detail {
  max-width: 700px;
}

.order-detail-header {
  margin-bottom: 32px;
}

.order-detail-header h2 {
  font-size: 28px;
  color: var(--ice-blue);
  margin-bottom: 8px;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
}
.back-link:hover { color: var(--ice-blue); }

.detail-progress {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.detail-progress .progress-bar { height: 14px; border-radius: 7px; }

.detail-progress .progress-labels {
  font-size: 15px;
  margin-bottom: 12px;
}

.weight-big {
  font-size: 32px;
  font-weight: 700;
  color: var(--aurora-green);
}

.weight-big .unit {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── Items List ─────────────────────────────────────── */

.items-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.item-info { flex: 1; }

.item-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

.item-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.item-weight {
  font-weight: 700;
  color: var(--aurora-green);
  font-size: 15px;
  margin-right: 16px;
}

.item-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}
.item-delete:hover { color: var(--danger); background: var(--danger-bg); }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }

/* ─── Stats Page ─────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.stat-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--ice-blue);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card.highlight .stat-value { color: var(--aurora-green); }

/* ─── Modal ──────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.modal-close:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }

.modal-form { padding: 24px; }

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--ice-blue);
}

.form-group textarea { min-height: 80px; resize: vertical; }

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ─── Loading & Misc ─────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px;
  color: var(--text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--ice-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ─────────────────────────────────────── */

@media (max-width: 640px) {
  .header-inner { padding: 0 16px; }
  .main { padding: 20px 16px; }
  .orders-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; align-items: flex-start; gap: 16px; }
  .logo h1 { font-size: 18px; }
  .badge { display: none; }
  .order-village { font-size: 16px; }
  .weight-big { font-size: 24px; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
}
