/* ============================================================
   nex-modern.css
   Design tokens + base styles for the modernised NexERP UI.
   Extracted from the canonical reference: sales-real.php.
   Loaded by core/site_inc/header.inc.php on every page.
   ============================================================ */

:root {
  /* Palette — light theme only */
  --color-bg:           #fafafa;   /* page background      (zinc-50)  */
  --color-surface:      #ffffff;   /* cards, sidebar       (white)    */
  --color-border:       #e4e4e7;   /* primary border       (zinc-200) */
  --color-border-soft:  #f4f4f5;   /* dividers             (zinc-100) */
  --color-text:         #000000;   /* all text             (black)    */
  --color-text-muted:   #000000;   /* legacy compat alias  (also black per design rule) */
  --color-icon:         #a1a1aa;   /* decorative svg only  (zinc-400) */

  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;

  --status-amber-bg:   #fffbeb;  /* amber-50  */
  --status-amber-dot:  #f59e0b;  /* amber-500 */
  --status-blue-bg:    #eff6ff;
  --status-blue-dot:   #3b82f6;
  --status-emerald-bg: #ecfdf5;
  --status-emerald-dot:#10b981;
  --status-rose-bg:    #fff1f2;
  --status-rose-dot:   #f43f5e;
  --status-zinc-bg:    #f4f4f5;
  --status-zinc-dot:   #a1a1aa;

  /* Type */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --text-base: 14px;

  /* Shadows */
  --shadow-soft: 0 1px 2px 0 rgb(0 0 0 / 0.04);
  --shadow-card: 0 1px 3px 0 rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.04);
  --shadow-pop:  0 10px 30px -10px rgb(0 0 0 / 0.15), 0 4px 12px -4px rgb(0 0 0 / 0.08);
  --shadow-brand-glow: 0 1px 3px 0 rgb(37 99 235 / 0.40);

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h:  56px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* ---------- Base ---------- */
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-feature-settings: 'cv11','ss01','ss03'; }
html, body { height: 100%; margin: 0; padding: 0; background: var(--color-bg); color: var(--color-text); font-family: var(--font-sans); font-size: var(--text-base); line-height: 1.5; font-variant-numeric: tabular-nums; }
* { box-sizing: border-box; }

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: var(--color-text); }

:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; border-radius: 6px; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #a1a1aa; background-clip: padding-box; border: 2px solid transparent; }

/* ---------- Shell layout (sidebar + main) ---------- */
.nex-shell { display: flex; height: 100vh; overflow: hidden; }

.nex-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

.nex-sidebar-brand {
  display: flex; align-items: center; gap: 8px;
  height: var(--topbar-h);
  padding: 0 20px;
  border-bottom: 1px solid var(--color-border);
}
.nex-sidebar-brand-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: #18181b; color: #fff;
  font-size: 13px; font-weight: 700;
}
.nex-sidebar-brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.nex-sidebar-brand-meta { margin-left: auto; font-size: 10px; font-weight: 500; color: var(--color-text); }

.nex-sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 12px; }
.nex-nav-group { margin-bottom: 20px; }
.nex-nav-group:last-child { margin-bottom: 0; }
.nex-nav-group-label {
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--color-text);
}
.nex-nav-group-label svg { width: 16px; height: 16px; }
.nex-nav-child { display: block; padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; color: var(--color-text); transition: background 120ms; }
.nex-nav-child:hover { background: #f4f4f5; }
.nex-nav-child.is-active { background: var(--brand-50); color: var(--brand-700); }

.nex-nav-link { /* top-level single link */
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; color: var(--color-text);
  transition: background 120ms;
}
.nex-nav-link:hover { background: #f4f4f5; }
.nex-nav-link.is-active { background: var(--brand-50); color: var(--brand-700); }
.nex-nav-link svg, .nex-nav-group-label svg { width: 16px; height: 16px; }

.nex-sidebar-user {
  border-top: 1px solid var(--color-border);
  padding: 12px;
}
.nex-sidebar-user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); }
.nex-sidebar-user-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9999px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff; font-size: 12px; font-weight: 700;
}
.nex-sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nex-sidebar-user-meta { font-size: 11px; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Mobile drawer */
.nex-sidebar-overlay { display: none; }
.nex-sidebar-toggle { display: none; }

@media (max-width: 1023px) {
  .nex-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%); transition: transform 200ms ease-out;
    z-index: 60; box-shadow: var(--shadow-pop);
  }
  .nex-shell.is-drawer-open .nex-sidebar { transform: translateX(0); }
  .nex-shell.is-drawer-open .nex-sidebar-overlay {
    display: block; position: fixed; inset: 0;
    background: rgb(0 0 0 / 0.4); z-index: 50;
  }
  .nex-sidebar-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: transparent; border: 0; cursor: pointer;
    color: var(--color-text);
  }
  .nex-sidebar-toggle:hover { background: #f4f4f5; }
  .nex-sidebar-toggle svg { width: 20px; height: 20px; }
}

/* Main column */
.nex-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.nex-main-scroll { flex: 1; overflow-y: auto; background: var(--color-bg); }
.nex-main-inner { width: 100%; padding: 24px 16px; }
@media (min-width: 1024px) { .nex-main-inner { padding: 40px 32px; } }

/* Optional mobile header bar (only shows the hamburger button on small screens) */
.nex-mobile-bar {
  display: none;
  height: var(--topbar-h);
  align-items: center;
  padding: 0 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
@media (max-width: 1023px) { .nex-mobile-bar { display: flex; } }

/* ---------- Login mode (no sidebar) ---------- */
.nex-login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--color-bg); padding: 24px;
}
.nex-login-card {
  width: 100%; max-width: 400px; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: 32px;
}
.nex-login-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.nex-login-title { font-size: 20px; font-weight: 700; color: var(--color-text); margin: 0 0 4px; }
.nex-login-subtitle { font-size: 13px; color: var(--color-text); margin: 0 0 24px; }
.nex-login-card label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text); margin-bottom: 6px; }
.nex-login-card input[type="text"],
.nex-login-card input[type="password"] {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: #fff; font-size: 14px; color: var(--color-text);
  margin-bottom: 16px;
}
.nex-login-card input:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
.nex-login-card button[type="submit"], .nex-login-card input[type="submit"] {
  width: 100%; height: 40px; background: #18181b; color: #fff;
  border: 0; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
  cursor: pointer; transition: background 120ms;
}
.nex-login-card button[type="submit"]:hover, .nex-login-card input[type="submit"]:hover { background: #27272a; }

/* ---------- Toast ---------- */
.nex-toast-host { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.nex-toast {
  min-width: 240px; max-width: 360px;
  padding: 12px 16px; border-radius: var(--radius-md);
  background: #fff; border: 1px solid var(--color-border);
  box-shadow: var(--shadow-pop);
  font-size: 13px; font-weight: 500; color: var(--color-text);
  animation: nex-toast-in 200ms ease-out;
}
.nex-toast.is-success { border-color: #a7f3d0; background: #ecfdf5; }
.nex-toast.is-warning { border-color: #fde68a; background: #fffbeb; }
.nex-toast.is-error   { border-color: #fecdd3; background: #fff1f2; }
@keyframes nex-toast-in { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Error page ---------- */
.nex-error-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.nex-error-card { text-align: center; max-width: 400px; }
.nex-error-code { font-size: 64px; font-weight: 700; letter-spacing: -0.02em; color: var(--color-text); }
.nex-error-title { font-size: 18px; font-weight: 700; margin: 8px 0; color: var(--color-text); }
.nex-error-text { font-size: 14px; color: var(--color-text); margin-bottom: 24px; }
.nex-error-link {
  display: inline-block; padding: 8px 16px; background: #18181b; color: #fff;
  border-radius: var(--radius-sm); font-weight: 600; font-size: 13px;
}

/* ============================================================
   PRINT
   Hide sidebar, expand main, table-friendly layout.
   ============================================================ */
@media print {
  body { background: #fff; }
  .nex-sidebar, .nex-mobile-bar, .nex-sidebar-toggle, .nex-toast-host { display: none !important; }
  .nex-shell { display: block; height: auto; }
  .nex-main { display: block; overflow: visible; }
  .nex-main-scroll { overflow: visible; }
  .nex-main-inner { padding: 0; width: 100%; max-width: 100%; }

  /* w3-card / .modern-card etc — strip shadows + heavy borders for paper */
  .w3-card, .w3-card-2, .w3-card-4, .modern-card, .nex-card {
    box-shadow: none !important;
    border: 1px solid #d4d4d8 !important;
    page-break-inside: avoid;
  }

  /* Tables: full width, no row hover bg, page-break friendly */
  table { width: 100% !important; border-collapse: collapse; }
  thead { display: table-header-group; }   /* repeat header on new pages */
  tr { page-break-inside: avoid; }

  a { color: #000 !important; text-decoration: none !important; }

  /* Hide interactive controls on print */
  button, .w3-button, .w3-btn, input[type="submit"], input[type="button"], .ajax-loader, #wait { display: none !important; }
}
