/* ============================================================
   LoadMaster Pro — Styles
   ============================================================ */

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

:root {
  --bg: #f8fafc;
  --bg2: #f1f5f9;
  --white: #ffffff;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --red: #ef4444;
  --green: #10b981;
  --amber: #f59e0b;
  --purple: #8b5cf6;
  --pink: #ec4899;
  --cyan: #06b6d4;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.2);
  --font: 'DM Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  color: var(--slate-900);
  min-height: 100vh;
}

/* ---- HEADER ---- */
.app-header {
  background: var(--white);
  border-bottom: 1px solid var(--slate-200);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--slate-900), var(--slate-700));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--white);
}
.logo-text { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; }
.logo-text .accent { color: var(--blue); }
.logo-sub { font-size: 11px; color: var(--slate-400); font-weight: 500; }

.tab-nav {
  display: flex; gap: 4px; background: var(--slate-100);
  border-radius: 10px; padding: 4px;
}
.tab-btn {
  padding: 10px 18px; border-radius: var(--radius-sm); border: none;
  cursor: pointer; font-size: 13px; font-weight: 600;
  background: transparent; color: var(--slate-500);
  font-family: var(--font); transition: all 0.2s;
}
.tab-btn.active { background: var(--slate-900); color: var(--white); }
.tab-btn:hover:not(.active) { background: var(--slate-200); }

/* ---- MAIN ---- */
.app-main { padding: 20px 24px; max-width: 1600px; margin: 0 auto; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- CARD ---- */
.card {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--slate-200); box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--slate-100);
  font-size: 14px; font-weight: 700; color: var(--slate-900);
  display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 16px 20px; }
.card-warning { border-color: #fde68a; background: #fffbeb; }
.card-header-warning { background: #fffbeb; border-bottom-color: #fde68a; }

/* ---- INPUTS ---- */
.input, .input-select {
  width: 100%; padding: 8px 12px; border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm); font-size: 13px; outline: none;
  background: var(--white); font-family: var(--font);
  transition: border 0.2s;
}
.input:focus, .input-select:focus { border-color: var(--blue); }
.input-select { cursor: pointer; }

/* ---- BUTTONS ---- */
.btn-primary {
  padding: 12px 24px; border-radius: 10px; border: none;
  background: linear-gradient(135deg, var(--slate-900) 0%, var(--slate-800) 100%);
  color: var(--white); cursor: pointer; font-size: 14px; font-weight: 700;
  font-family: var(--font); box-shadow: 0 2px 8px rgba(15,23,42,0.3);
  transition: all 0.2s; width: 100%;
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(15,23,42,0.4); transform: translateY(-1px); }
.btn-primary.btn-sm { width: auto; padding: 10px 20px; font-size: 13px; }

.btn-secondary {
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--slate-300); background: var(--white);
  cursor: pointer; font-size: 12px; font-weight: 600;
  color: var(--slate-700); font-family: var(--font); transition: all 0.2s;
}
.btn-secondary:hover { background: var(--slate-50); }
.btn-secondary.btn-sm { padding: 6px 14px; }

.btn-small-blue {
  padding: 5px 12px; border-radius: 6px; border: none;
  background: var(--blue); color: var(--white); cursor: pointer;
  font-size: 11px; font-weight: 700; font-family: var(--font);
}

.btn-sim-play {
  padding: 6px 16px; border-radius: var(--radius-sm); border: none;
  background: var(--green); color: var(--white); cursor: pointer;
  font-size: 12px; font-weight: 600; font-family: var(--font);
}

/* ---- LOAD PLANNER GRID ---- */
.load-grid { display: grid; grid-template-columns: 380px 1fr; gap: 20px; }
.left-panel { display: flex; flex-direction: column; gap: 16px; }
.right-panel { display: flex; flex-direction: column; gap: 16px; }

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

/* Container info */
.container-info {
  margin-top: 10px; background: var(--slate-50); border-radius: 10px;
  padding: 12px; font-size: 11px; color: var(--slate-600); line-height: 1.9;
}
.container-info .ci-label { font-weight: 700; font-size: 12px; color: var(--slate-900); margin-bottom: 4px; }

/* Cargo list */
.cargo-list { max-height: 400px; overflow-y: auto; }
.cargo-item {
  padding: 12px 20px; border-bottom: 1px solid var(--slate-100);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; transition: background 0.15s;
}
.cargo-item:hover { background: var(--slate-50); }
.cargo-item-name { font-weight: 700; color: var(--slate-900); margin-bottom: 2px; display: flex; align-items: center; gap: 6px; }
.cargo-item-details { color: var(--slate-400); font-size: 11px; }
.cargo-item-details .flag-fragile { color: var(--red); margin-left: 6px; }
.cargo-item-details .flag-nostack { color: var(--amber); margin-left: 6px; }
.cargo-color-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
}
.cargo-actions { display: flex; gap: 4px; }
.btn-icon {
  padding: 4px 8px; border: 1px solid var(--slate-200); border-radius: 5px;
  background: var(--white); cursor: pointer; font-size: 11px;
}
.btn-icon.delete { border-color: #fecaca; }

/* ---- 3D VIEWER ---- */
.viewer-3d { width: 100%; height: 500px; background: var(--slate-50); }
.viewer-hint { padding: 8px 20px 12px; font-size: 11px; color: var(--slate-400); }

/* Badge */
.badge {
  font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 20px;
}
.badge.green { background: #dcfce7; color: #166534; }
.badge.amber { background: #fef3c7; color: #92400e; }
.badge.red { background: #fee2e2; color: #991b1b; }
.hidden { display: none !important; }

/* ---- STATS ROW ---- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-card {
  background: var(--white); border-radius: var(--radius); border: 1px solid var(--slate-200);
  box-shadow: var(--shadow); padding: 16px;
}
.stat-label { font-size: 11px; color: var(--slate-400); font-weight: 600; }
.stat-value { font-size: 22px; font-weight: 800; margin-top: 4px; }

@media (max-width: 768px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ---- WEIGHT + AI ROW ---- */
.weight-ai-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 768px) { .weight-ai-row { grid-template-columns: 1fr; } }

.weight-dist-body { padding: 16px; }
.weight-bar-row { display: flex; gap: 6px; align-items: end; height: 80px; }
.weight-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.weight-bar-val { font-size: 11px; font-weight: 600; color: var(--slate-600); }
.weight-bar {
  width: 100%; border-radius: 4px 4px 0 0; transition: height 0.5s ease; min-height: 8px;
}
.weight-bar-label { font-size: 10px; color: var(--slate-400); }

.ai-suggestions-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.ai-sug-item {
  display: flex; gap: 10px; align-items: start;
  padding: 10px; background: var(--slate-50); border-radius: var(--radius-sm);
}
.ai-sug-icon { font-size: 18px; }
.ai-sug-title { font-size: 12px; font-weight: 700; color: var(--slate-900); }
.ai-sug-desc { font-size: 11px; color: var(--slate-500); margin-top: 2px; }

/* ---- ALERTS ---- */
.alert {
  padding: 12px 16px; border-radius: 10px; font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-icon { font-size: 18px; }

/* ---- SIMULATION ---- */
.sim-grid { display: grid; grid-template-columns: 1fr 360px; gap: 20px; }
@media (max-width: 900px) { .sim-grid { grid-template-columns: 1fr; } }

.sim-controls { display: flex; gap: 8px; }
.sim-progress { padding: 12px 20px; }
.progress-bar { height: 6px; background: var(--slate-200); border-radius: 3px; overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 3px; width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--purple));
  transition: width 0.5s ease;
}
.sim-step-text { font-size: 11px; color: var(--slate-400); margin-top: 6px; text-align: center; }
.sim-instructions { max-height: 600px; overflow-y: auto; }
.sim-instr-item {
  padding: 12px 20px; border-bottom: 1px solid var(--slate-100);
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  transition: background 0.2s;
}
.sim-instr-item:hover { background: var(--slate-50); }
.sim-instr-item.active { background: #eff6ff; }
.sim-instr-num {
  width: 24px; height: 24px; border-radius: 6px; font-size: 11px;
  font-weight: 800; display: flex; align-items: center; justify-content: center;
  background: var(--slate-200); color: var(--slate-500);
}
.sim-instr-num.done { color: var(--white); }
.sim-instr-name { font-size: 12px; font-weight: 700; color: var(--slate-900); }
.sim-instr-pos { font-size: 10px; color: var(--slate-400); }

/* Empty state */
.empty-state { padding: 60px 40px; text-align: center; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--slate-900); }
.empty-sub { font-size: 13px; color: var(--slate-400); margin-top: 4px; }

/* ---- ANALYTICS ---- */
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.analytics-grid .full-span { grid-column: span 2; }
@media (max-width: 768px) {
  .analytics-grid { grid-template-columns: 1fr; }
  .analytics-grid .full-span { grid-column: span 1; }
}
.analytics-center { padding: 24px; display: flex; align-items: center; justify-content: center; min-height: 240px; }
.util-ring { position: relative; width: 160px; height: 160px; margin: 0 auto; }
.util-ring svg { display: block; }
.util-ring-text {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.util-ring-pct { font-size: 32px; font-weight: 800; color: var(--slate-900); }
.util-ring-label { font-size: 11px; color: var(--slate-400); }
.util-volume { margin-top: 16px; font-size: 13px; color: var(--slate-600); text-align: center; }

.weight-progress { margin-bottom: 12px; }
.weight-progress-header { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.weight-progress-label { color: var(--slate-500); }
.weight-progress-value { font-weight: 700; color: var(--slate-900); }
.weight-progress-bar { height: 12px; background: var(--slate-200); border-radius: 6px; overflow: hidden; }
.weight-progress-fill { height: 100%; border-radius: 6px; transition: width 0.5s ease; }
.weight-details { font-size: 12px; color: var(--slate-500); line-height: 1.8; }

/* Manifest table */
.manifest-wrap { overflow-x: auto; }
.manifest-wrap table { width: 100%; border-collapse: collapse; font-size: 12px; }
.manifest-wrap th {
  padding: 10px 16px; text-align: left; font-weight: 700;
  color: var(--slate-600); background: var(--slate-50);
  border-bottom: 1px solid var(--slate-200);
}
.manifest-wrap td { padding: 10px 16px; border-bottom: 1px solid var(--slate-100); }
.manifest-wrap tr.unplaced { background: #fef2f2; }
.manifest-num {
  display: inline-block; width: 22px; height: 22px; border-radius: 5px;
  color: var(--white); font-size: 11px; font-weight: 800;
  text-align: center; line-height: 22px;
}
.status-badge {
  padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 700;
}
.status-loaded { background: #dcfce7; color: #166534; }
.status-failed { background: #fee2e2; color: #991b1b; }

/* ---- COSTS ---- */
.costs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 768px) { .costs-grid { grid-template-columns: repeat(2, 1fr); } }
.cost-card {
  background: var(--white); border-radius: var(--radius); border: 1px solid var(--slate-200);
  box-shadow: var(--shadow); padding: 24px;
}
.cost-icon { font-size: 28px; margin-bottom: 8px; }
.cost-label {
  font-size: 11px; font-weight: 600; color: var(--slate-400);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.cost-value { font-size: 28px; font-weight: 800; margin: 4px 0; }
.cost-sub { font-size: 12px; color: var(--slate-500); }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-box {
  background: var(--white); border-radius: 16px; padding: 28px;
  width: 440px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg);
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; color: var(--slate-900); }
.modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal-form label { font-size: 11px; font-weight: 600; color: var(--slate-600); display: block; margin-bottom: 4px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

.form-group { flex: 1; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.form-checks { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.check-label { display: flex; align-items: center; gap: 4px; font-size: 12px; cursor: pointer; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }
