/* Foxel Mining — Design System
   Color palette inspired by Indonesian mining industry:
   - Navy (deep pit)   : primary brand
   - Orange (coal fire): accent, alerts
   - Sage (reclaim)    : success
   - Earth (OB)        : neutral warm
   Typography: Inter (web) — clean, legible in pit tablet + boardroom projector
*/

:root {
  /* Brand */
  --fx-navy-900: #0B1E3F;
  --fx-navy-800: #12305F;
  --fx-navy-700: #1B4280;
  --fx-navy-600: #2458A3;
  --fx-navy-500: #3A73C6;
  --fx-navy-100: #E7EEF8;
  --fx-navy-50:  #F4F7FC;

  --fx-orange-600: #D46B1A;
  --fx-orange-500: #F08420;
  --fx-orange-400: #F5A15A;
  --fx-orange-100: #FCE8D7;

  /* Semantic */
  --fx-green-600:  #2E7D46;   /* on-track, K3 streak */
  --fx-green-500:  #43A55F;
  --fx-green-100:  #DFF0E3;

  --fx-red-600:    #B2283A;
  --fx-red-500:    #D93B4F;
  --fx-red-100:    #FADDE1;

  --fx-amber-600:  #B87900;
  --fx-amber-500:  #E09B10;
  --fx-amber-100:  #FCEBC2;

  /* Neutrals */
  --fx-ink-900: #0E131A;
  --fx-ink-800: #1F2937;
  --fx-ink-700: #374151;
  --fx-ink-600: #4B5563;
  --fx-ink-500: #6B7280;
  --fx-ink-400: #9CA3AF;
  --fx-ink-300: #D1D5DB;
  --fx-ink-200: #E5E7EB;
  --fx-ink-100: #F3F4F6;
  --fx-ink-50:  #F9FAFB;
  --fx-white:   #FFFFFF;

  /* Earth (OB / stripping context) */
  --fx-earth-700: #6B4F2E;
  --fx-earth-500: #A8864D;
  --fx-earth-100: #EDE3D0;

  /* Spacing scale (matches Tailwind) */
  --fx-1: 4px;
  --fx-2: 8px;
  --fx-3: 12px;
  --fx-4: 16px;
  --fx-6: 24px;
  --fx-8: 32px;
  --fx-12: 48px;

  /* Radius */
  --fx-r-sm: 6px;
  --fx-r-md: 10px;
  --fx-r-lg: 16px;
  --fx-r-xl: 24px;

  /* Shadow */
  --fx-shadow-sm: 0 1px 2px rgba(11,30,63,.06), 0 1px 1px rgba(11,30,63,.04);
  --fx-shadow-md: 0 4px 10px rgba(11,30,63,.08), 0 2px 4px rgba(11,30,63,.04);
  --fx-shadow-lg: 0 12px 28px rgba(11,30,63,.12), 0 4px 10px rgba(11,30,63,.06);

  /* Typography */
  --fx-font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --fx-font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* Base reset — scoped to demo container */
.fx-app, .fx-app * {
  box-sizing: border-box;
}

.fx-app {
  font-family: var(--fx-font-sans);
  color: var(--fx-ink-900);
  background: var(--fx-ink-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography scale */
.fx-h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; color: var(--fx-ink-900); }
.fx-h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; color: var(--fx-ink-900); }
.fx-h3 { font-size: 17px; font-weight: 600; color: var(--fx-ink-900); }
.fx-h4 { font-size: 14px; font-weight: 600; color: var(--fx-ink-800); text-transform: uppercase; letter-spacing: 0.03em; }
.fx-body { font-size: 14px; color: var(--fx-ink-700); }
.fx-small { font-size: 12px; color: var(--fx-ink-500); }
.fx-mono { font-family: var(--fx-font-mono); font-variant-numeric: tabular-nums; }
.fx-tnum { font-variant-numeric: tabular-nums; }

/* Card */
.fx-card {
  background: var(--fx-white);
  border: 1px solid var(--fx-ink-200);
  border-radius: var(--fx-r-md);
  box-shadow: var(--fx-shadow-sm);
  padding: var(--fx-6);
}

.fx-card--compact { padding: var(--fx-4); }

.fx-card--hero {
  background: linear-gradient(135deg, var(--fx-navy-900) 0%, var(--fx-navy-700) 100%);
  color: var(--fx-white);
  border: none;
}

/* Buttons */
.fx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--fx-2);
  padding: 10px 16px;
  border-radius: var(--fx-r-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 120ms ease;
  text-decoration: none;
  font-family: inherit;
  min-height: 40px;
}
.fx-btn:focus-visible { outline: 2px solid var(--fx-navy-500); outline-offset: 2px; }

.fx-btn--primary { background: var(--fx-navy-700); color: var(--fx-white); }
.fx-btn--primary:hover { background: var(--fx-navy-800); }

.fx-btn--accent { background: var(--fx-orange-500); color: var(--fx-white); }
.fx-btn--accent:hover { background: var(--fx-orange-600); }

.fx-btn--ghost { background: transparent; color: var(--fx-ink-700); border-color: var(--fx-ink-300); }
.fx-btn--ghost:hover { background: var(--fx-ink-50); border-color: var(--fx-ink-400); }

.fx-btn--danger { background: var(--fx-red-500); color: var(--fx-white); }
.fx-btn--danger:hover { background: var(--fx-red-600); }

.fx-btn--sm { padding: 6px 10px; min-height: 32px; font-size: 12px; }
.fx-btn--lg { padding: 14px 22px; min-height: 48px; font-size: 15px; }

/* Pill / badge */
.fx-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.fx-pill--ok    { background: var(--fx-green-100); color: var(--fx-green-600); }
.fx-pill--warn  { background: var(--fx-amber-100); color: var(--fx-amber-600); }
.fx-pill--alert { background: var(--fx-red-100);   color: var(--fx-red-600); }
.fx-pill--info  { background: var(--fx-navy-100);  color: var(--fx-navy-700); }
.fx-pill--muted { background: var(--fx-ink-100);   color: var(--fx-ink-600); }

/* KPI tile */
.fx-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--fx-4);
}
.fx-kpi__label { font-size: 11px; color: var(--fx-ink-500); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.fx-kpi__value { font-size: 26px; font-weight: 700; color: var(--fx-ink-900); font-variant-numeric: tabular-nums; }
.fx-kpi__delta { font-size: 12px; font-weight: 600; }
.fx-kpi__delta--up   { color: var(--fx-green-600); }
.fx-kpi__delta--down { color: var(--fx-red-600); }

/* Progress bar */
.fx-progress {
  height: 8px;
  background: var(--fx-ink-200);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.fx-progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--fx-navy-600), var(--fx-navy-500));
  border-radius: 999px;
  transition: width 300ms ease;
}
.fx-progress--warn .fx-progress__fill { background: linear-gradient(90deg, var(--fx-amber-600), var(--fx-amber-500)); }
.fx-progress--alert .fx-progress__fill { background: linear-gradient(90deg, var(--fx-red-600), var(--fx-red-500)); }
.fx-progress--ok .fx-progress__fill { background: linear-gradient(90deg, var(--fx-green-600), var(--fx-green-500)); }

/* Alert banner */
.fx-alert {
  display: flex;
  gap: var(--fx-3);
  padding: var(--fx-3) var(--fx-4);
  border-radius: var(--fx-r-sm);
  border: 1px solid transparent;
  align-items: flex-start;
}
.fx-alert--info  { background: var(--fx-navy-50);   border-color: var(--fx-navy-100);   color: var(--fx-navy-800); }
.fx-alert--warn  { background: var(--fx-amber-100); border-color: #F0D785;              color: var(--fx-amber-600); }
.fx-alert--alert { background: var(--fx-red-100);   border-color: #F4B7BF;              color: var(--fx-red-600); }
.fx-alert--ok    { background: var(--fx-green-100); border-color: #B7DEC0;              color: var(--fx-green-600); }

.fx-alert__icon { flex-shrink: 0; margin-top: 2px; }
.fx-alert__title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.fx-alert__body { font-size: 12px; line-height: 1.4; }

/* Side nav */
.fx-sidebar {
  width: 232px;
  min-height: 100vh;
  background: var(--fx-navy-900);
  color: var(--fx-white);
  display: flex;
  flex-direction: column;
  padding: var(--fx-4);
}
.fx-sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--fx-2);
  padding: var(--fx-3) var(--fx-2);
  margin-bottom: var(--fx-6);
}
.fx-sidebar__brand-mark {
  width: 28px; height: 28px;
  background: var(--fx-orange-500);
  border-radius: 6px;
  display: grid; place-items: center;
  font-weight: 700; color: var(--fx-white); font-size: 14px;
}
.fx-sidebar__brand-text { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.fx-sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.fx-sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--fx-3);
  padding: 10px 12px;
  border-radius: var(--fx-r-sm);
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 120ms ease;
}
.fx-sidebar__item:hover { background: rgba(255,255,255,0.06); color: var(--fx-white); }
.fx-sidebar__item--active { background: rgba(240,132,32,0.15); color: var(--fx-orange-400); }
.fx-sidebar__section-label { font-size: 10px; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 0.08em; padding: var(--fx-4) var(--fx-2) var(--fx-2); font-weight: 600; }

/* Top header */
.fx-topbar {
  height: 60px;
  background: var(--fx-white);
  border-bottom: 1px solid var(--fx-ink-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--fx-6);
}
.fx-topbar__title { font-size: 15px; font-weight: 600; color: var(--fx-ink-900); }
.fx-topbar__meta { display: flex; align-items: center; gap: var(--fx-4); font-size: 12px; color: var(--fx-ink-500); }

/* Layout grid */
.fx-layout { display: flex; min-height: 100vh; }
.fx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fx-content { flex: 1; padding: var(--fx-6); overflow-y: auto; }

/* Table */
.fx-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fx-table th { text-align: left; padding: 10px 12px; background: var(--fx-ink-50); color: var(--fx-ink-600); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--fx-ink-200); }
.fx-table td { padding: 10px 12px; border-bottom: 1px solid var(--fx-ink-100); color: var(--fx-ink-800); }
.fx-table tr:hover td { background: var(--fx-ink-50); }
.fx-table__num { text-align: right; font-variant-numeric: tabular-nums; }

/* Avatar */
.fx-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--fx-navy-600), var(--fx-navy-800));
  color: var(--fx-white);
  display: grid; place-items: center;
  font-weight: 600; font-size: 12px;
  flex-shrink: 0;
}

/* Phone frame (for mobile screens) */
.fx-phone {
  width: 380px;
  height: 780px;
  background: var(--fx-ink-900);
  border-radius: 44px;
  padding: 14px;
  box-shadow: var(--fx-shadow-lg);
  position: relative;
}
.fx-phone__screen {
  width: 100%; height: 100%;
  background: var(--fx-white);
  border-radius: 32px;
  overflow: hidden;
  position: relative;
}
.fx-phone__notch {
  position: absolute;
  top: 20px; left: 50%;
  transform: translateX(-50%);
  width: 120px; height: 26px;
  background: var(--fx-ink-900);
  border-radius: 16px;
  z-index: 10;
}

/* Demo-specific helpers */
.fx-scene-label {
  display: inline-block;
  background: var(--fx-orange-500);
  color: var(--fx-white);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: var(--fx-3);
}
.fx-demo-nav {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 8px;
  background: var(--fx-white);
  padding: 8px;
  border-radius: 999px;
  box-shadow: var(--fx-shadow-lg);
  border: 1px solid var(--fx-ink-200);
  z-index: 100;
}

/* i18n — dual-span pattern (CSS-only hide/show) */
html[data-lang="id"] [data-lang="en"] { display: none !important; }
html[data-lang="en"] [data-lang="id"] { display: none !important; }

/* Language toggle component */
.fx-lang-toggle {
  display: inline-flex;
  background: var(--fx-ink-100);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.fx-lang-toggle__btn {
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--fx-ink-500);
  cursor: pointer;
  border-radius: 999px;
  font-family: inherit;
  letter-spacing: 0.04em;
  transition: all 120ms ease;
}
.fx-lang-toggle__btn:hover { color: var(--fx-ink-700); }
.fx-lang-toggle__btn--active {
  background: var(--fx-white);
  color: var(--fx-navy-700);
  box-shadow: 0 1px 2px rgba(11,30,63,0.08);
}

/* For dark backgrounds (scene banner, sidebar) */
.fx-lang-toggle--dark { background: rgba(255,255,255,0.1); }
.fx-lang-toggle--dark .fx-lang-toggle__btn { color: rgba(255,255,255,0.6); }
.fx-lang-toggle--dark .fx-lang-toggle__btn:hover { color: var(--fx-white); }
.fx-lang-toggle--dark .fx-lang-toggle__btn--active { background: var(--fx-white); color: var(--fx-navy-800); }

/* Header tools row — wraps home + lang toggle so they always sit on the same line */
.fx-header-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  vertical-align: middle;
}

/* Home button — injected into .fx-header-tools by lib/i18n.js */
.fx-home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 5px;
  text-decoration: none;
  transition: background 120ms ease, transform 120ms ease;
}
.fx-home-btn:hover {
  background: var(--fx-orange-500);
  transform: translateY(-1px);
}
.fx-home-btn svg { width: 13px; height: 13px; display: block; }

/* Utility */
.fx-grid { display: grid; gap: var(--fx-4); }
.fx-grid-4 { grid-template-columns: repeat(4, 1fr); }
.fx-grid-3 { grid-template-columns: repeat(3, 1fr); }
.fx-grid-2 { grid-template-columns: repeat(2, 1fr); }
.fx-flex { display: flex; gap: var(--fx-3); }
.fx-flex-between { display: flex; justify-content: space-between; align-items: center; }
.fx-flex-col { display: flex; flex-direction: column; gap: var(--fx-3); }
.fx-stack-2 > * + * { margin-top: var(--fx-2); }
.fx-stack-3 > * + * { margin-top: var(--fx-3); }
.fx-stack-4 > * + * { margin-top: var(--fx-4); }
.fx-stack-6 > * + * { margin-top: var(--fx-6); }

.fx-text-center { text-align: center; }
.fx-text-right { text-align: right; }
.fx-mono-lg { font-family: var(--fx-font-mono); font-size: 15px; font-variant-numeric: tabular-nums; }
