/* ============================================================
   3AE SmartBag — styles
   ============================================================ */
:root {
  --bg: #0a0f1e;
  --bg-2: #0f1830;
  --panel: #121d38;
  --panel-2: #16234a;
  --line: #24345f;
  --text: #e7eefc;
  --muted: #93a6cf;
  --muted-2: #6c7fa8;
  --accent: #2dd4bf;     /* teal */
  --accent-2: #38bdf8;   /* sky */
  --brand: #19c3a6;
  --warn: #f59e0b;
  --danger: #ef4444;
  --ok: #22c55e;
  --gold: #f5b301;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0,0,0,.45);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 700px at 80% -10%, #14223f 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- Header / tabs ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 14px 22px;
  background: linear-gradient(180deg, rgba(18,29,56,.95), rgba(10,15,30,.85));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30; backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-weight: 800; letter-spacing: .5px; font-size: 20px;
  color: #00120e; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 8px 12px; border-radius: 10px; box-shadow: 0 6px 18px rgba(45,212,191,.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 18px; }
.brand-text small { color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 6px; background: rgba(255,255,255,.03); padding: 5px; border-radius: 12px; border: 1px solid var(--line); }
.tab {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  padding: 9px 16px; font-size: 14px; font-weight: 600; border-radius: 9px; cursor: pointer;
  transition: .18s;
}
.tab:hover { color: var(--text); }
.tab.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #04130f; box-shadow: 0 6px 16px rgba(56,189,248,.25); }

.app-main { flex: 1; padding: 22px; }
.panel { display: none; animation: fade .25s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity:1; transform:none; } }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; cursor: pointer; border-radius: 10px; font-weight: 600; font-size: 14px;
  padding: 10px 16px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  transition: .16s; user-select: none;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #04130f; border: 0; }
.btn-ghost { background: transparent; }
.btn-tool { padding: 8px 12px; font-size: 13px; }
.btn-danger { color: #fff; border-color: #5e2230; background: linear-gradient(135deg,#b91c1c,#ef4444); }
.btn.is-off { opacity: .55; }

/* ============================================================
   OVERVIEW
   ============================================================ */
.overview { max-width: 1100px; margin: 0 auto; }
.hero { padding: 14px 4px 26px; }
.hero h1 { font-size: 30px; margin: 0 0 10px; letter-spacing: -.3px; }
.lead { color: var(--muted); font-size: 16px; max-width: 820px; line-height: 1.6; }
.hero-cta { margin-top: 18px; display: flex; gap: 12px; flex-wrap: wrap; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 16px; margin: 8px 0 30px; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow);
}
.card .card-ico { font-size: 24px; }
.card h3 { margin: 8px 0 6px; font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; }

.flow { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; }
.flow h2 { margin: 0 0 14px; font-size: 19px; }
.flow-steps { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; gap: 12px; }
.flow-steps li { counter-increment: s; position: relative; padding: 12px 14px 12px 52px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; }
.flow-steps li::before {
  content: counter(s); position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #04130f; font-weight: 800;
}
.flow-steps b { display:block; margin-bottom: 2px; }
.flow-steps span { color: var(--muted); font-size: 13.5px; }

/* ---- Overview: sections chung ---- */
.ov-section { margin: 30px 0; }
.ov-h2 { font-size: 21px; margin: 0 0 4px; }
.ov-sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

/* ---- Demo banner (nút vào 3D / Admin) ---- */
.demo-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  margin: 8px 0 30px; padding: 20px 24px; border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(45,212,191,.12), rgba(56,189,248,.10)), var(--panel);
  border: 1px solid var(--accent);
}
.demo-banner-text h2 { margin: 0 0 4px; font-size: 19px; }
.demo-banner-text p { margin: 0; color: var(--muted); font-size: 14px; }
.demo-banner-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.demo-btn {
  display: inline-flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2);
}
.demo-btn .demo-ico { font-size: 26px; }
.demo-btn b { display: block; font-size: 15px; }
.demo-btn small { display: block; color: var(--muted); font-size: 12px; }
.demo-btn.demo-3d:hover { border-color: var(--accent); }
.demo-btn.demo-admin:hover { border-color: var(--accent-2); }

/* ---- Lợi ích ---- */
.benefits { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 16px; }
.benefit-card { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.benefit-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.benefit-ico { font-size: 24px; }
.benefit-head h3 { margin: 0; font-size: 15.5px; line-height: 1.3; }
.benefit-card ul { margin: 0; padding-left: 18px; display: grid; gap: 7px; }
.benefit-card li { color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.benefit-card li b { color: var(--text); }

/* ---- Mô hình thế giới ---- */
.models { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px,1fr)); gap: 14px; }
.model-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; border-left: 3px solid var(--accent-2); }
.model-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.model-top b { font-size: 14.5px; }
.model-tag { font-size: 11px; font-weight: 700; color: #9cdcff; background: rgba(56,189,248,.14); border: 1px solid rgba(56,189,248,.4); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.model-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ---- Cách thức thực hiện ---- */
.impl { display: grid; gap: 12px; }
.impl-step { display: flex; gap: 16px; align-items: flex-start; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.impl-num { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 17px; color: #04130f; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.impl-body b { display: block; font-size: 15px; margin-bottom: 2px; }
.impl-body span { color: var(--muted); font-size: 13.5px; line-height: 1.5; }

/* ---- CTA cuối ---- */
.demo-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 26px 0 8px; padding: 18px 22px; border-radius: var(--radius); background: var(--panel); border: 1px dashed var(--line); }
.demo-foot span { font-weight: 600; margin-right: auto; }

/* ============================================================
   SCENE
   ============================================================ */
.scene-wrap {
  position: relative; width: 100%; height: calc(100vh - 150px); min-height: 520px;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: radial-gradient(900px 500px at 50% 0%, #16243f, #070b16 70%);
  box-shadow: var(--shadow);
}
#scene-canvas { display: block; width: 100%; height: 100%; }

.overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.overlay.markers { z-index: 12; }
.overlay.labels { z-index: 8; }

/* marker dots */
.marker {
  position: absolute; top: 0; left: 0; pointer-events: auto; cursor: pointer;
  width: 20px; height: 20px; will-change: transform;
}
.marker .pulse {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle, rgba(56,189,248,.95) 0 30%, rgba(56,189,248,.25) 31% 60%, transparent 61%);
  box-shadow: 0 0 0 2px rgba(255,255,255,.25);
}
.marker .ring { position: absolute; inset: -6px; border-radius: 50%; border: 2px solid rgba(56,189,248,.6); animation: ping 1.8s ease-out infinite; }
.marker:hover .pulse { background: radial-gradient(circle, #fff 0 30%, rgba(56,189,248,.45) 31% 60%, transparent 61%); }
.marker.alarm .pulse { background: radial-gradient(circle, #fff 0 30%, rgba(239,68,68,.5) 31% 60%, transparent 61%); }
.marker.alarm .ring { border-color: rgba(239,68,68,.7); }
@keyframes ping { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(1.8); opacity: 0; } }

/* always-on small labels */
.scene-label {
  position: absolute; top: 0; left: 0; transform: translate(-50%,-50%);
  font-size: 11.5px; font-weight: 700; letter-spacing: .2px; white-space: nowrap;
  color: #dbe7ff; background: rgba(8,14,28,.72); border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 999px; will-change: transform; backdrop-filter: blur(3px);
}
.scene-label.tag-out { color: #b9f5e8; border-color: #1f6b5c; }
.scene-label.tag-in  { color: #cfe6ff; border-color: #2a5b8a; }

.scene-toolbar {
  position: absolute; left: 14px; top: 14px; z-index: 14;
  display: flex; gap: 8px; flex-wrap: wrap; max-width: 70%;
}
.scene-hint {
  position: absolute; right: 14px; top: 14px; z-index: 14; color: var(--muted);
  font-size: 12px; background: rgba(8,14,28,.6); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 999px;
}
.dot-inline { display:inline-block; width:9px; height:9px; border-radius:50%; background: var(--accent-2); vertical-align: middle; box-shadow:0 0 0 2px rgba(56,189,248,.3); }

.scene-legend {
  position: absolute; left: 14px; bottom: 14px; z-index: 14; display: flex; gap: 14px; flex-wrap: wrap;
  background: rgba(8,14,28,.62); border: 1px solid var(--line); padding: 8px 12px; border-radius: 10px;
  font-size: 12px; color: var(--muted);
}
.scene-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lg-belt { background: #3b4a6b; }
.lg-rfid { background: var(--accent); }
.lg-cam  { background: var(--gold); }
.lg-tower{ background: var(--accent-2); border-radius: 50%; }

/* info card */
.info-card {
  position: absolute; right: 14px; bottom: 14px; z-index: 16; width: 360px; max-width: calc(100% - 28px);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 18px 16px; transition: opacity .2s, transform .2s;
}
.info-card.hidden { opacity: 0; transform: translateY(12px); pointer-events: none; }
.info-close { position: absolute; right: 10px; top: 8px; background: transparent; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
.info-close:hover { color: #fff; }
.info-body .ic-tag { display: inline-block; font-size: 11px; font-weight: 700; color: #04130f; background: linear-gradient(135deg,var(--accent),var(--accent-2)); padding: 3px 9px; border-radius: 999px; }
.info-body h3 { margin: 10px 0 2px; font-size: 18px; }
.info-body .ic-sub { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.info-body p { color: #cfe0ff; font-size: 13.5px; line-height: 1.55; margin: 0 0 10px; }
.info-body ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.info-body ul b { color: var(--text); }

.scene-alert {
  position: absolute; left: 50%; top: 64px; transform: translateX(-50%); z-index: 18;
  background: linear-gradient(135deg,#b91c1c,#ef4444); color: #fff; font-weight: 700; font-size: 14px;
  padding: 10px 18px; border-radius: 10px; box-shadow: 0 10px 30px rgba(239,68,68,.4);
  animation: alertPulse 1s ease-in-out infinite;
}
.scene-alert.hidden { display: none; }
@keyframes alertPulse { 0%,100% { box-shadow: 0 10px 30px rgba(239,68,68,.35);} 50% { box-shadow: 0 10px 40px rgba(239,68,68,.7);} }

.scene-loading {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 20;
  color: var(--muted); font-size: 14px; background: rgba(7,11,22,.6);
}
.scene-loading.hidden { display: none; }

/* ============================================================
   ADMIN
   ============================================================ */
.admin { max-width: 1200px; margin: 0 auto; }
.admin h2 { font-size: 20px; margin: 4px 0 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi .kpi-label { color: var(--muted); font-size: 12.5px; }
.kpi .kpi-value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.kpi .kpi-delta { font-size: 12px; margin-top: 4px; }
.kpi .up { color: var(--ok); } .kpi .down { color: var(--danger); } .kpi .flat { color: var(--muted); }
.kpi.accent { border-color: var(--accent); }
.kpi.warn { border-color: var(--warn); }

.admin-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 920px) { .admin-grid { grid-template-columns: 1fr; } }

.panel-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.panel-box h3 { margin: 0 0 12px; font-size: 15px; display:flex; align-items:center; justify-content:space-between; }
.panel-box h3 .live { font-size: 11px; color: var(--ok); display:inline-flex; align-items:center; gap:6px; }
.panel-box h3 .live::before { content:""; width:8px;height:8px;border-radius:50%;background:var(--ok); box-shadow:0 0 0 0 rgba(34,197,94,.6); animation:livedot 1.6s infinite; }
@keyframes livedot { 0%{box-shadow:0 0 0 0 rgba(34,197,94,.55);} 70%{box-shadow:0 0 0 8px rgba(34,197,94,0);} 100%{box-shadow:0 0 0 0 rgba(34,197,94,0);} }

table.bags { width: 100%; border-collapse: collapse; font-size: 13px; }
table.bags th, table.bags td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.bags th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
table.bags tbody tr:hover { background: rgba(56,189,248,.06); }
.tagid { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--accent); }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: rgba(34,197,94,.15); color: #7ee2a8; border: 1px solid rgba(34,197,94,.4); }
.badge.move { background: rgba(56,189,248,.15); color: #9cdcff; border: 1px solid rgba(56,189,248,.4); }
.badge.warn { background: rgba(245,158,11,.15); color: #f7c66b; border: 1px solid rgba(245,158,11,.4); }
.badge.err { background: rgba(239,68,68,.15); color: #f5a3a3; border: 1px solid rgba(239,68,68,.45); }

.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.events li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); font-size: 13px; }
.events .ev-ico { font-size: 16px; line-height: 1.4; }
.events .ev-time { color: var(--muted-2); font-size: 11.5px; }
.events li.err { border-color: rgba(239,68,68,.4); }
.events li.warn { border-color: rgba(245,158,11,.4); }
