/* Ghost Store — public status page. Light theme shared with /shop (shop-vue/src/assets/main.css). */
:root {
  color-scheme: light;
  --bg: #F5F6F8;
  --panel: #FFFFFF;
  --panel2: #F1F3F6;
  --line: #E3E7ED;
  --line-strong: #CBD3DD;
  --text: #0F172A;
  --muted: #475569;
  --subtle: #5B6678;
  --accent: #2563EB;
  --accent-soft: #EAF1FF;
  --green: #15803D;
  --green-bar: #22A55A;
  --green-soft: #E8F7EE;
  --yellow: #B45309;
  --yellow-bar: #F0A63A;
  --yellow-soft: #FEF5E7;
  --red: #C62828;
  --red-bar: #E5484D;
  --red-soft: #FDECEC;
  --blue: #2563EB;
  --violet: #7C3AED;
  --amber: #D97706;
  --cyan: #0E7490;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.35); outline-offset: 2px; border-radius: 6px; }

.shell { max-width: 1200px; margin: 0 auto; padding: 0 24px 40px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; }

/* ─── Top bar ─── */
.topbar {
  min-height: 72px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-height: 44px; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--text);
  color: #FFFFFF;
  font-weight: 800;
  font-size: 18px;
}
.brand b, .brand small { display: block; }
.brand b { font-size: 14px; letter-spacing: 0.02em; }
.brand small { color: var(--subtle); font-size: 12px; }

.live-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid #BFE6CD;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.live-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--green-bar); animation: pulse 1.6s ease-in-out infinite; }
.live-chip.stale { border-color: #F6D6A8; background: var(--yellow-soft); color: var(--yellow); }
.live-chip.stale i { background: var(--yellow-bar); animation: none; }
.updated { color: var(--subtle); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ─── Overall banner ─── */
.hero {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 24px 0;
  padding: 24px 28px;
  border: 1px solid #BFE6CD;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--green-soft), var(--panel) 70%);
  box-shadow: var(--shadow);
}
body.degraded .hero { border-color: #F6D6A8; background: linear-gradient(135deg, var(--yellow-soft), var(--panel) 70%); }
body.down .hero { border-color: #F5C2C3; background: linear-gradient(135deg, var(--red-soft), var(--panel) 70%); }
.hero-copy { min-width: 0; }
.eyebrow { display: flex; align-items: center; gap: 8px; color: var(--green); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; }
body.degraded .eyebrow { color: var(--yellow); }
body.down .eyebrow { color: var(--red); }
.eyebrow-line { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.hero h1 { margin: 8px 0 4px; font-size: clamp(22px, 3.2vw, 30px); line-height: 1.2; letter-spacing: -0.02em; }
.hero p { margin: 0; color: var(--muted); }
.hero-side { display: grid; gap: 8px; justify-items: end; text-align: right; }
.hero-uptime span { display: block; color: var(--subtle); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; }
.hero-uptime b { font-size: 22px; font-variant-numeric: tabular-nums; }
.refresh-label { display: inline-flex; align-items: center; gap: 8px; color: var(--subtle); font-size: 12px; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.hero-orbit { display: none; }

/* ─── Metric cards ─── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric-card {
  --tone: var(--blue);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.metric-card[data-tone="violet"] { --tone: var(--violet); }
.metric-card[data-tone="amber"] { --tone: var(--amber); }
.metric-card[data-tone="green"] { --tone: var(--green); }
.metric-card[data-tone="champagne"] { --tone: var(--text); }
.metric-card[data-tone="cyan"] { --tone: var(--cyan); }
.metric-head { display: flex; align-items: center; justify-content: space-between; color: var(--subtle); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; }
.metric-icon { color: var(--tone); font-size: 16px; }
.metric-card > b { font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.metric-card small { color: var(--subtle); font-size: 12px; }
.meter { height: 6px; border-radius: 999px; background: var(--panel2); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--tone); transition: width 0.6s ease; }
.metric-subhead { display: flex; justify-content: space-between; margin-top: 4px; color: var(--subtle); font-size: 12px; font-weight: 700; }
.metric-subhead b { color: var(--text); font-variant-numeric: tabular-nums; }
.swap-meter i { opacity: 0.6; }
.metric-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: auto; color: var(--subtle); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ─── Panels ─── */
.panel {
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; margin-bottom: 16px; }
.section-kicker { display: block; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; }
.section-head h2 { margin: 2px 0 0; font-size: 18px; letter-spacing: -0.01em; }
.section-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--panel2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.loading-row { padding: 16px; color: var(--subtle); text-align: center; }


/* Chart */
.chart-legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; font-weight: 600; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 3px; border-radius: 2px; }
.legend-cpu { background: var(--blue); }
.legend-ram { background: var(--violet); }
.legend-disk { background: var(--amber); }
.chart-wrap canvas { display: block; width: 100%; height: 200px; }
.chart-axis { display: flex; justify-content: space-between; margin-top: 6px; color: var(--subtle); font-size: 12px; }

/* Services */
.service-head-meta { display: flex; align-items: center; gap: 10px; color: var(--subtle); font-size: 12px; }
.service-list { display: grid; grid-template-columns: minmax(0, 1fr); }
.service-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}
.service-row:last-child { border-bottom: 0; }
.service-main { display: flex; flex: 1; align-items: center; gap: 10px; min-width: 0; }
.service-name { font-weight: 600; overflow-wrap: anywhere; }
.service-meta { display: grid; flex: 1; gap: 2px; text-align: right; color: var(--subtle); font-size: 12px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.service-meta strong { color: var(--red); }
.service-group summary { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-weight: 700; }
.service-group summary::before { content: "+"; }
.service-group[open] summary::before { content: "−"; }
.service-group summary span { margin-left: auto; color: var(--subtle); font-size: 12px; font-weight: 400; }
.status-dot { flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.status-dot.ok { background: var(--green-bar); box-shadow: 0 0 0 3px var(--green-soft); }
.status-dot.warn { background: var(--yellow-bar); box-shadow: 0 0 0 3px var(--yellow-soft); }
.status-dot.error { background: var(--red-bar); box-shadow: 0 0 0 3px var(--red-soft); }

/* Background workers */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--subtle);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.worker-state { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.worker-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.worker-state.ok { color: var(--green); }
.worker-state.ok i { background: var(--green-bar); }
.worker-state.error { color: var(--red); }
.worker-state.error i { background: var(--red-bar); }
.worker-state.none { color: var(--subtle); }

/* Lịch sử: 144 khoảng 10 phút. Thanh là một điều khiển chọn bằng chuột/chạm/phím. */
.uptime-note { color: var(--subtle); font-size: 12px; }
.uptime-list { display: grid; gap: 14px; }
.uptime-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 90px; align-items: center; gap: 12px; }
.uptime-name { font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.uptime-bar { display: grid; grid-template-columns: repeat(144, minmax(0, 1fr)); gap: 1px; height: 44px; cursor: crosshair; touch-action: pan-y; }
.uptime-cell { display: block; border-radius: 2px; background: var(--line); }
.uptime-cell.ok { background: var(--green-bar); }
.uptime-cell.warn { background: var(--yellow-bar); }
.uptime-cell.error { background: var(--red-bar); }
.uptime-cell:hover, .uptime-cell.selected { box-shadow: inset 0 0 0 2px var(--text); }
.uptime-pct { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.uptime-pct small { display: block; font-weight: 400; color: var(--subtle); }
#history-system { margin-top: 24px; }
#history-system label { display: block; font-weight: 600; }
#history-system select { min-height: 44px; max-width: 100%; margin: 8px 0 12px; padding: 8px; font: inherit; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel); color: var(--text); }
.status-tooltip { position: fixed; z-index: 20; max-width: min(360px, calc(100vw - 16px)); padding: 12px; border-radius: 8px; background: var(--text); color: white; box-shadow: var(--shadow); font-size: 13px; white-space: pre-line; overflow-wrap: anywhere; pointer-events: none; }
.worker-state.warn { color: var(--yellow); }
.worker-state.warn i { background: var(--yellow-bar); }

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding-top: 16px;
  color: var(--subtle);
  font-size: 12px;
}

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

@media (max-width: 640px) {
  .shell { padding: 0 14px 28px; }
  .topbar { padding: 10px 0; }
  .hero { padding: 20px; }
  .hero-side { justify-items: start; text-align: left; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { padding: 14px; }
  .metric-card > b { font-size: 22px; }
  .panel { padding: 16px; }
  .uptime-row { grid-template-columns: minmax(0, 1fr) auto; }
  .uptime-bar { grid-column: 1 / -1; grid-row: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
