/* ============================================================
   EINC ADVISORY — DASHBOARD app.css
   Token reka bentuk diport terus daripada web/src/styles/global.css.
   Nama pemboleh ubah dikekalkan supaya dashboard & laman awam kekal seiring.
   ============================================================ */

/* ---------- 1. TOKEN KEKAL ---------- */
:root {
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --accent: #4fd1c5;
  --accent-2: #2c9e96;
  --accent-ink: #04231f;
  --blue: #2f5bff;

  --ok: #34c58a;
  --warn: #e5a53d;
  --err: #f0616d;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius-pill: 999px;

  --maxw: 1200px;
  --gut: 20px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --nav-h: 56px;
  --sidebar-w: 248px;
}
@media (min-width: 768px) { :root { --gut: 32px; } }

/* ---------- 2. TEMA ---------- */
html[data-theme='dark'] {
  color-scheme: dark;
  --bg: #070b14; --bg-2: #0a101c; --surface: #0e1626; --surface-2: #141f33;
  --line: rgba(148, 180, 214, 0.12); --line-strong: rgba(148, 180, 214, 0.24);
  --text: #e9f0f8; --muted: #8da2bc; --shadow: 0 30px 70px -34px rgba(0,0,0,0.95);
}
html[data-theme='light'] {
  color-scheme: light;
  --bg: #f4f7fb; --bg-2: #ffffff; --surface: #ffffff; --surface-2: #eef3f9;
  --line: rgba(13, 25, 45, 0.1); --line-strong: rgba(13, 25, 45, 0.2);
  --text: #0b1220; --muted: #5a6b82; --shadow: 0 26px 56px -32px rgba(13,25,45,0.32);
}

/* ---------- 3. ASAS ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.65;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; line-height: 1.2; letter-spacing: -0.02em; font-weight: 600; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

/* ---------- 4. BUTANG (seperti global.css) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--radius-pill); border: 1px solid transparent;
  font-family: var(--font-display); font-weight: 600; font-size: 14px; line-height: 1;
  cursor: pointer; white-space: nowrap;
  transition: transform 0.18s var(--ease), background 0.22s ease, border-color 0.22s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: #63dcd0; }
.btn--ghost { border-color: var(--line-strong); color: var(--text); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn--sm { padding: 8px 14px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--danger { background: var(--err); color: #fff; }
.btn--danger:hover { background: #ff7681; }

/* ---------- 5. KAD ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: clamp(20px, 3vw, 26px); }
.card--link:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow); }

/* ---------- 6. BORANG (.field seperti global.css) ---------- */
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label { font-family: var(--font-display); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.field label .req { color: var(--accent); }
.field input, .field select, .field textarea {
  width: 100%; font-family: var(--font-body); font-size: 14.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 10px 12px; transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.field[data-invalid] input, .field[data-invalid] select, .field[data-invalid] textarea { border-color: var(--err); }
.field .error { font-size: 12px; color: var(--err); }
.field .hint { font-size: 12px; color: var(--muted); }

/* ---------- 7. NOTE / FLASH ---------- */
.note { border-radius: var(--radius); padding: 12px 16px; font-size: 13.5px; border: 1px solid var(--line-strong); background: var(--surface); margin-bottom: 18px; }
.note--ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, transparent); }
.note--err { border-color: color-mix(in srgb, var(--err) 50%, transparent); color: var(--err); background: color-mix(in srgb, var(--err) 8%, transparent); }

/* ---------- 8. STAT (.stat seperti global.css) ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.stat { background: var(--surface); padding: clamp(20px, 3vw, 26px); display: flex; align-items: center; gap: 16px; }
.stat__ico { width: 42px; height: 42px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--accent); display: grid; place-items: center; flex: none; }
.stat__body b { display: block; font-family: var(--font-mono); font-size: clamp(22px, 3vw, 30px); font-weight: 500; color: var(--accent); line-height: 1.1; }
.stat__body span { color: var(--muted); font-size: 12.5px; display: block; margin-top: 3px; }

/* ---------- 9. JADUAL ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 400; text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--text); }
table.tbl tr:hover td { background: var(--surface-2); }
table.tbl a { color: var(--accent); }
table.tbl a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 10. LENCANA STATUS ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-pill); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.05em; }
.badge i { width: 6px; height: 6px; border-radius: 99px; flex: none; }
.badge--ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.badge--ok i { background: var(--ok); }
.badge--warn { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }
.badge--warn i { background: var(--warn); }
.badge--err { background: color-mix(in srgb, var(--err) 12%, transparent); color: var(--err); }
.badge--err i { background: var(--err); }
.badge--muted { background: color-mix(in srgb, var(--muted) 12%, transparent); color: var(--muted); }
.badge--muted i { background: var(--muted); }

/* ---------- 11. SUSUN ATUR DASHBOARD ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.app__main { display: flex; flex-direction: column; min-width: 0; }
.app__content { padding: clamp(20px, 3vw, 32px); flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: clamp(20px, 3vw, 26px); }
.page-head p { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- 12. SIDEBAR ---------- */
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar__brand { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.sidebar__brand img { height: 24px; width: auto; }
.sidebar__nav { list-style: none; margin: 0; padding: 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar__nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius); font-size: 14px; color: var(--muted); border-left: 2px solid transparent; transition: background 0.15s ease, color 0.15s ease; }
.sidebar__nav a:hover { color: var(--text); background: var(--surface-2); }
.sidebar__nav a.is-active { color: var(--text); background: var(--surface-2); border-left-color: var(--accent); }
.sidebar__nav a svg { flex: none; }
.sidebar__foot { padding: 12px 16px; border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }

/* ---------- 13. TOPBAR ---------- */
.topbar { height: var(--nav-h); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(12px); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 clamp(16px, 3vw, 28px); position: sticky; top: 0; z-index: 30; }
.topbar__crumbs { font-family: var(--font-mono); font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.topbar__crumbs a:hover { color: var(--text); }
.topbar__right { display: flex; align-items: center; gap: 12px; }
.topbar__user { display: flex; align-items: center; gap: 10px; position: relative; }
.topbar__userbtn { display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer; color: var(--text); font-family: var(--font-body); font-size: 13.5px; padding: 6px 8px; border-radius: var(--radius); }
.topbar__userbtn:hover { background: var(--surface-2); }
.topbar__av { width: 30px; height: 30px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line-strong); display: grid; place-items: center; color: var(--accent); overflow: hidden; flex: none; }
.topbar__av img { width: 100%; height: 100%; object-fit: cover; }
.topbar__menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 6px; opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity 0.15s ease, transform 0.15s var(--ease), visibility 0.15s; }
.topbar__user.is-open .topbar__menu { opacity: 1; visibility: visible; transform: translateY(0); }
.topbar__menu a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13.5px; color: var(--muted); }
.topbar__menu a:hover { background: var(--surface-2); color: var(--text); }

.icon-btn { width: 36px; height: 36px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { border-color: var(--line-strong); }

/* ---------- 14. HALAMAN LOG MASUK ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; }
.login__fx { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(48% 42% at 78% 4%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%), radial-gradient(46% 40% at 8% 12%, color-mix(in srgb, var(--blue) 14%, transparent), transparent 72%); }
.login__card { width: 100%; max-width: 400px; }
.login__logo { display: flex; justify-content: center; margin-bottom: 22px; }
.login__logo img { height: 36px; width: auto; }
.login__theme { position: absolute; top: 20px; right: 20px; }

/* Overlay hanya wujud untuk laci sidebar mudah alih. Ia MESTI display:none
   pada desktop: .app ialah grid dua lajur, dan overlay ialah anak KETIGA
   (selepas .sidebar, sebelum .app__main). Tanpa peraturan ini ia mengambil
   sel lajur-2 baris-1, menolak .app__main ke baris 2 lajur 1 — topbar dan
   kandungan tersepit 248px lebar di bawah sidebar, dan kawasan utama nampak
   kosong. Ia tidak nampak seperti ralat kerana overlay itu sendiri tidak
   kelihatan (tiada latar pada desktop). */
.sidebar__overlay { display: none; }

/* ---------- 15. RESPONSIF ---------- */
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar-w); z-index: 60; transform: translateX(-100%); transition: transform 0.25s var(--ease); }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow); }
  .sidebar__overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 55; opacity: 0; visibility: hidden; transition: opacity 0.25s ease, visibility 0.25s; }
  .sidebar__overlay.is-open { opacity: 1; visibility: visible; }
  .sidebar__burger { display: grid !important; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 620px) { .stats { grid-template-columns: 1fr; } }

/* ---------- 16. PENOMBORAN ---------- */
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 22px; }
.pager a, .pager span { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--radius); border: 1px solid var(--line); font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.pager a:hover { color: var(--text); border-color: var(--line-strong); }
.pager .is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pager .is-disabled { opacity: 0.4; pointer-events: none; }
/* ---------- 17. EDITOR DWIBAHASA (posts & faqs) ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs__btn {
  appearance: none; background: none; border: 0; cursor: pointer;
  font-family: var(--font-display); font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 10px 16px; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.tabs__btn:hover { color: var(--text); }
.tabs__btn.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: tabfade 0.2s var(--ease); }
@keyframes tabfade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.editor {
  width: 100%; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius) var(--radius) 0 0; padding: 12px 14px; color: var(--text);
  resize: vertical; transition: border-color 0.2s ease;
}
.editor:focus { outline: none; border-color: var(--accent); }
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 7px 8px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
}
.editor-toolbar button {
  appearance: none; cursor: pointer; background: var(--surface); color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 11.5px; padding: 5px 10px; line-height: 1;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.editor-toolbar button:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- 18. GARIS MASA NOTA (inbox) ---------- */
.timeline { display: grid; gap: 12px; margin-bottom: 20px; }
.timeline__item {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  background: var(--surface-2);
}
.timeline__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
