/* ============================================================
   ERP Design System — erp.css
   5 themes: ocean | forest | violet | ember | rose
   All themes share the same dark shell — only accent changes.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Theme Tokens ─────────────────────────────────────────── */

/* Ocean (default — deep navy + electric blue) */
[data-theme="ocean"], :root {
  --accent:         #3b82f6;
  --accent-hover:   #2563eb;
  --accent-muted:   rgba(59,130,246,.12);
  --accent-glow:    rgba(59,130,246,.35);
  --accent-text:    #93c5fd;
}

/* Forest (deep teal + emerald) */
[data-theme="forest"] {
  --accent:         #10b981;
  --accent-hover:   #059669;
  --accent-muted:   rgba(16,185,129,.12);
  --accent-glow:    rgba(16,185,129,.35);
  --accent-text:    #6ee7b7;
}

/* Violet (deep purple) */
[data-theme="violet"] {
  --accent:         #8b5cf6;
  --accent-hover:   #7c3aed;
  --accent-muted:   rgba(139,92,246,.12);
  --accent-glow:    rgba(139,92,246,.35);
  --accent-text:    #c4b5fd;
}

/* Ember (amber/orange) */
[data-theme="ember"] {
  --accent:         #f97316;
  --accent-hover:   #ea6100;
  --accent-muted:   rgba(249,115,22,.12);
  --accent-glow:    rgba(249,115,22,.35);
  --accent-text:    #fdba74;
}

/* Rose (crimson red) */
[data-theme="rose"] {
  --accent:         #f43f5e;
  --accent-hover:   #e11d48;
  --accent-muted:   rgba(244,63,94,.12);
  --accent-glow:    rgba(244,63,94,.35);
  --accent-text:    #fda4af;
}

/* ── Shared Dark Shell (all themes) ──────────────────────── */
:root {
  /* Backgrounds */
  --bg-base:        #0a0d14;
  --bg-surface:     #0f1320;
  --bg-elevated:    #151929;
  --bg-overlay:     #1c2133;
  --bg-hover:       #1e2438;
  --bg-active:      #232840;

  /* Borders */
  --border:         rgba(255,255,255,.07);
  --border-strong:  rgba(255,255,255,.14);
  --border-accent:  var(--accent);

  /* Text */
  --text-primary:   #f0f2f8;
  --text-secondary: #8892a4;
  --text-muted:     #4d5568;
  --text-accent:    var(--accent-text);

  /* Status */
  --success:        #22c55e;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #38bdf8;

  /* Sidebar */
  --sidebar-w:      260px;
  --sidebar-collapsed-w: 68px;

  /* Topbar */
  --topbar-h:       62px;

  /* Radius */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  20px;

  /* Shadow */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,.45);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.55);
  --shadow-accent: 0 0 24px var(--accent-glow);

  /* Transition */
  --t-fast: 150ms ease;
  --t-base: 220ms ease;
  --t-slow: 380ms cubic-bezier(.4,0,.2,1);
}

/* ── Theme transition (smooth color switch) ──────────────── */
*, *::before, *::after {
  transition: background-color var(--t-slow), border-color var(--t-slow), box-shadow var(--t-slow);
}
/* Don't transition layout properties */
.no-transition, .no-transition * { transition: none !important; }

/* ── Layout Shell ─────────────────────────────────────────── */
.erp-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--t-slow);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-w); }

.sidebar-logo {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  font-weight: 800;
  font-family: 'Sora', sans-serif;
  color: #fff;
  box-shadow: var(--shadow-accent);
}
.sidebar-logo-text {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-logo-text span { color: var(--accent); }

/* Nav sections */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 20px 6px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--t-base);
}
.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  margin: 1px 8px;
  border-radius: var(--r-md);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: .88rem;
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--t-fast);
  position: relative;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-muted);
  color: var(--accent-text);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-item .nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.nav-item .nav-label {
  overflow: hidden;
  transition: opacity var(--t-base), max-width var(--t-slow);
  max-width: 180px;
}
.sidebar.collapsed .nav-label { opacity: 0; max-width: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  flex-shrink: 0;
}
.sidebar.collapsed .nav-badge { display: none; }

/* Sidebar bottom */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 8px;
  flex-shrink: 0;
}

/* Collapse toggle */
.sidebar-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-md);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: .88rem;
  font-family: 'DM Sans', sans-serif;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-toggle .toggle-icon { flex-shrink: 0; transition: transform var(--t-slow); }
.sidebar.collapsed .sidebar-toggle .toggle-icon { transform: rotate(180deg); }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--t-slow);
}
.main-content.sidebar-collapsed { margin-left: var(--sidebar-collapsed-w); }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  color: var(--text-secondary);
}
.topbar-breadcrumb .crumb-current {
  color: var(--text-primary);
  font-weight: 600;
}
.topbar-breadcrumb .crumb-sep { color: var(--text-muted); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Icon button */
.icon-btn {
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  transition: all var(--t-fast);
  position: relative;
}
.icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border);
  color: var(--text-primary);
}
.icon-btn .badge-dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
}

/* Theme switcher pill */
.theme-switcher {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 8px;
}
.theme-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.theme-dot:hover { transform: scale(1.2); }
.theme-dot.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
  transform: scale(1.15);
}
.theme-dot[data-t="ocean"]  { background: #3b82f6; }
.theme-dot[data-t="forest"] { background: #10b981; }
.theme-dot[data-t="violet"] { background: #8b5cf6; }
.theme-dot[data-t="ember"]  { background: #f97316; }
.theme-dot[data-t="rose"]   { background: #f43f5e; }

/* User avatar */
.user-avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: var(--accent-muted);
  border: 1px solid var(--accent);
  color: var(--accent-text);
  font-size: .8rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-family: 'Sora', sans-serif;
}

/* ── Page Content ─────────────────────────────────────────── */
.page-content {
  padding: 28px 28px;
  flex: 1;
}

.page-header {
  margin-bottom: 28px;
}
.page-title {
  font-family: 'Sora', sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.page-subtitle {
  font-size: .85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-family: 'Sora', sans-serif;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-primary);
}
.card-subtitle { font-size: .78rem; color: var(--text-secondary); margin-top: 2px; }

/* ── KPI Cards ────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  cursor: default;
  transition: border-color var(--t-base), transform var(--t-fast);
}
.kpi-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  border-radius: 50%;
  transform: translate(20px, -20px);
  pointer-events: none;
}
.kpi-label {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.kpi-value {
  font-family: 'Sora', sans-serif;
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 10px;
}
.kpi-value .kpi-currency {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-right: 2px;
}
.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .78rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
}
.kpi-trend.up   { background: rgba(34,197,94,.12); color: #4ade80; }
.kpi-trend.down { background: rgba(239,68,68,.12);  color: #f87171; }
.kpi-icon {
  position: absolute;
  top: 16px; right: 16px;
  width: 40px; height: 40px;
  background: var(--accent-muted);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
  color: var(--accent);
}

/* ── Grid Layouts ─────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-3-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

/* ── Table ────────────────────────────────────────────────── */
.erp-table { width: 100%; border-collapse: collapse; }
.erp-table th {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.erp-table td {
  padding: 12px 14px;
  font-size: .85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.erp-table tr:last-child td { border-bottom: none; }
.erp-table tbody tr { transition: background var(--t-fast); }
.erp-table tbody tr:hover { background: var(--bg-hover); }
.erp-table td .cell-primary { color: var(--text-primary); font-weight: 500; }

/* ── Status Badges ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  gap: 5px;
  font-size: .72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-success { background: rgba(34,197,94,.12); color: #4ade80; }
.badge-warning { background: rgba(245,158,11,.12); color: #fbbf24; }
.badge-danger  { background: rgba(239,68,68,.12);  color: #f87171; }
.badge-info    { background: rgba(56,189,248,.12); color: #7dd3fc; }
.badge-muted   { background: var(--bg-overlay); color: var(--text-muted); }

/* ── Module Grid ──────────────────────────────────────────── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.module-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--t-fast);
}
.module-card:hover {
  border-color: var(--accent);
  background: var(--accent-muted);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.module-card-icon {
  font-size: 1.6rem;
  margin-bottom: 8px;
  display: block;
}
.module-card-name {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'Sora', sans-serif;
}
.module-card-desc {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Activity Feed ────────────────────────────────────────── */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
  flex-shrink: 0;
}
.activity-text { font-size: .83rem; color: var(--text-secondary); }
.activity-text strong { color: var(--text-primary); font-weight: 500; }
.activity-time { font-size: .72rem; color: var(--text-muted); margin-top: 2px; font-family: 'DM Mono', monospace; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-family: 'DM Sans', sans-serif;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--t-fast);
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-accent); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }
.btn-sm { padding: 5px 11px; font-size: .78rem; }

/* ── Progress Bar ─────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--bg-overlay);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 1s cubic-bezier(.4,0,.2,1);
}

/* ── Chart Container ──────────────────────────────────────── */
.chart-wrap { position: relative; }

/* ── Divider ──────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Tooltip ──────────────────────────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%; bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: var(--bg-overlay);
  color: var(--text-primary);
  font-size: .72rem;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast);
  z-index: 999;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulse-accent {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%       { box-shadow: 0 0 0 8px transparent; }
}

.animate-fade   { animation: fadeIn .4s ease both; }
.animate-slide  { animation: slideIn .3s ease both; }

/* Stagger children */
.stagger > *:nth-child(1) { animation-delay: .05s; }
.stagger > *:nth-child(2) { animation-delay: .10s; }
.stagger > *:nth-child(3) { animation-delay: .15s; }
.stagger > *:nth-child(4) { animation-delay: .20s; }
.stagger > *:nth-child(5) { animation-delay: .25s; }
.stagger > *:nth-child(6) { animation-delay: .30s; }
.stagger > *:nth-child(7) { animation-delay: .35s; }
.stagger > *:nth-child(8) { animation-delay: .40s; }

/* ── Utility ──────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-1   { margin-top: 4px; }
.mt-2   { margin-top: 8px; }
.mt-3   { margin-top: 12px; }
.mt-4   { margin-top: 16px; }
.mb-4   { margin-bottom: 16px; }
.text-accent   { color: var(--accent-text); }
.text-muted    { color: var(--text-muted); }
.text-sm       { font-size: .82rem; }
.text-xs       { font-size: .72rem; }
.font-mono     { font-family: 'DM Mono', monospace; }
.font-heading  { font-family: 'Sora', sans-serif; }
.w-full        { width: 100%; }
.overflow-hidden { overflow: hidden; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1200px) {
  .grid-3     { grid-template-columns: 1fr 1fr; }
  .grid-3-2   { grid-template-columns: 1fr; }
  .grid-2-1   { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar    { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .grid-2     { grid-template-columns: 1fr; }
  .kpi-grid   { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
}
