/* Design system PORT từ AIEV (D:\CLAUDE\AIEV\apps\web\src\app\globals.css +
   .claude\skills\webui-design\SKILL.md) — "Shopify Admin style": tối giản, mật độ thông tin cao,
   KHÔNG gradient, KHÔNG glassmorphism, KHÔNG animation trang trí (chỉ transition 150ms).
   script-factory không có build step (thuần HTML/CSS/JS) nên copy NGUYÊN giá trị biến màu +
   class component, không dùng Tailwind. */

:root {
  --primary: #ed3c47;
  --primary-hover: #d62e3a;
  --primary-soft: #fdedef;
  --secondary: #ff7849;
  --bg: #ffffff;
  --bg-subtle: #f6f6f7;
  --surface: #ffffff;
  --border: #e7e7ea;
  --text: #101113;
  --text-muted: #5f6470;
  --success: #16a34a;
  --success-bg: #e7f6ec;
  --danger: #e8590c;
  --danger-bg: #fbeee5;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-card: 0 1px 2px rgba(16,17,19,0.06);
  --transition: 150ms ease;
  --text-meta: 0.8125rem; /* 13px */
  --shell-nav-w: 220px;
}

:root[data-theme="dark"] {
  --primary: #ed3c47;
  --primary-hover: #f25560;
  --primary-soft: #3a1d20;
  --bg: #131417;
  --bg-subtle: #1a1b1f;
  --surface: #1e1f24;
  --border: #2c2d33;
  --text: #f2f3f5;
  --text-muted: #9a9ea9;
  --success: #2ebd6b;
  --success-bg: #17301f;
  --danger: #f0742e;
  --danger-bg: #33231a;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); }
.hidden { display: none !important; }
code { background: var(--bg-subtle); padding: 1px 5px; border-radius: 4px; font-size: var(--text-meta); }

/* ---- Thang chữ 3 bậc — không tự chế cỡ khác ---- */
.text-meta { font-size: var(--text-meta); color: var(--text-muted); }
.text-xs { font-size: 12px; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 20px; font-weight: 600; margin-bottom: 16px; }
h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }

/* ---- Login ---- */
#pageLogin { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg-subtle); }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 32px; width: 320px; }
.login-box h1 { font-size: 20px; font-weight: 700; color: var(--primary); margin: 0 0 4px; }
.login-box p.sub { color: var(--text-muted); font-size: var(--text-meta); margin: 0 0 20px; }

/* ---- Shell layout: rail trái + nội dung (không có panel phải — chưa cần) ---- */
#app { display: none; }
#app.visible { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--shell-nav-w); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 0; display: flex; flex-direction: column; transition: width var(--transition);
}
.sidebar h1 { font-size: 16px; font-weight: 700; padding: 0 16px 16px; margin: 0; border-bottom: 1px solid var(--border); color: var(--primary); }
.nav-item {
  display: flex; align-items: center; gap: 8px; margin: 2px 8px; padding: 8px 12px; border-radius: var(--radius);
  color: var(--text-muted); text-decoration: none; cursor: pointer; font-size: 14px; transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--bg-subtle); color: var(--text); }
.nav-item.active { color: var(--primary); background: var(--primary-soft); font-weight: 500; }
.nav-group-title { padding: 16px 20px 4px; font-size: 12px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; }
.sidebar-footer { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--border); font-size: var(--text-meta); color: var(--text-muted); }
.sidebar-footer button { margin-top: 8px; }

.main { flex: 1; padding: 20px; }

/* ---- Card / Panel (nesting tối đa Card -> Panel) ---- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: 16px; margin-bottom: 16px;
}
.panel { background: var(--bg-subtle); border-radius: var(--radius); padding: 12px; }

/* ---- Form ---- */
label { display: block; font-size: var(--text-meta); color: var(--text-muted); margin-bottom: 4px; margin-top: 12px; }
label:first-child { margin-top: 0; }
.input, input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; height: 36px; padding: 0 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px; font-family: inherit;
  transition: border-color var(--transition);
}
.input:focus, input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
textarea { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer; transition: background var(--transition), border-color var(--transition);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary, button:not(.btn) { background: var(--primary); color: #fff; border: none; }
.btn-primary:hover:not(:disabled), button:not(.btn):hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary, button.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled), button.secondary:hover:not(:disabled) { background: var(--bg-subtle); }
.btn-destructive, button.danger { background: var(--danger); color: #fff; border: none; }
.btn-destructive:hover:not(:disabled), button.danger:hover:not(:disabled) { opacity: 0.9; }
.btn-sm, button.small { height: 30px; padding: 0 12px; font-size: 13px; }

/* ---- Badge ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge.admin { background: var(--primary-soft); color: var(--primary); }
.badge.editor { background: var(--bg-subtle); color: var(--text); }
.badge.viewer { background: var(--bg-subtle); color: var(--text-muted); }
.badge.on { background: var(--success-bg); color: var(--success); }
.badge.off { background: var(--danger-bg); color: var(--danger); }

/* ---- Table ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:hover td { background: var(--bg-subtle); }

/* ---- Message ---- */
.msg { padding: 10px 12px; border-radius: var(--radius); font-size: var(--text-meta); margin-top: 12px; }
.msg.error { background: var(--danger-bg); color: var(--danger); }
.msg.ok { background: var(--success-bg); color: var(--success); }
.msg.warn { background: #fef3c7; color: #92400e; }
:root[data-theme="dark"] .msg.warn { background: #3a2e10; color: #fcd34d; }

.script-output { background: var(--bg-subtle); border-radius: var(--radius); padding: 12px; white-space: pre-wrap; font-size: 14px; line-height: 1.6; margin-top: 8px; }
.cap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-top: 12px; }
.cap-toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 6px 10px; background: var(--bg-subtle); border-radius: var(--radius); cursor: pointer; }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.theme-toggle { background: none; border: 1px solid var(--border); color: var(--text-muted); width: 30px; height: 30px; padding: 0; border-radius: var(--radius); }

/* ---- Hộp hướng dẫn/chú thích — ẩn/hiện được toàn cục (nút 💡 ở sidebar), MẶC ĐỊNH HIỆN vì
   người mới cần thấy ngay, không phải chủ động bật lên mới thấy. */
.hint-box {
  background: var(--bg-subtle); border-left: 3px solid var(--primary); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 16px; font-size: var(--text-meta); line-height: 1.6;
}
.hint-box ol, .hint-box ul { margin: 8px 0 0; padding-left: 20px; }
.hint-box b { color: var(--text); }
.hint-inline { font-weight: 400; color: var(--text-muted); }
:root[data-hints="off"] .hint-box, :root[data-hints="off"] .hint-inline { display: none; }
