/* ═══════════════════════════════════════════════════════════════
   LONX ERP — Design V2 Enhancement Layer
   Enhances existing styles without breaking them
   ═══════════════════════════════════════════════════════════════ */

/* ── Font Scale Tokens ───────────────────────────────────────── */
:root {
  /* A1 type scale (Brand 2.1, 2026-10-09): 12 / 13 / 14 / 16 / 24 / 28 only */
  --fs-2xs: 12px;
  --fs-xs:  12px;
  --fs-sm:  12px;
  --fs-base:14px;
  --fs-md:  14px;
  --fs-lg:  16px;
  --fs-xl:  24px;
  --fs-2xl: 28px;
  --fs-3xl: 28px;
  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semibold:600;
  --fw-bold:    700;
  --fw-black:   800;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR V2 ENHANCEMENTS
   ═══════════════════════════════════════════════════════════════ */

/* Richer active indicator */
.nav-link.active {
  background: linear-gradient(135deg, rgba(230,43,72,.14) 0%, rgba(230,43,72,.06) 100%) !important;
  color: #fff !important;
}
.nav-link.active .nav-icon i { color: var(--erp-red); }

/* Active bar — thicker + glow */
.nav-link.active::before {
  width: 4px !important;
  box-shadow: 0 0 8px var(--erp-red);
}

/* Nav section labels */
.nav-section-label { letter-spacing: 1px; }

/* Nav hover smoother */
.nav-link { transition: background 150ms ease, color 150ms ease, transform 100ms ease; }
.nav-link:hover { transform: translateX(-2px); }
[dir="rtl"] .nav-link:hover { transform: translateX(2px); }
@media (prefers-reduced-motion: reduce) {
  .nav-link:hover { transform: none; }
}

/* Sidebar footer user avatar ring */
.user-avatar {
  box-shadow: 0 0 0 2px rgba(230,43,72,.3), 0 0 0 4px rgba(230,43,72,.1) !important;
}

/* Sidebar gradient background — dark theme only. Was unconditional with
   !important, which permanently forced a dark sidebar regardless of the
   light/dark toggle (beats the theme-aware var(--sidebar-bg) rule in
   index.html no matter what that rule resolves to). */
[data-theme="dark"] .sidebar {
  background: linear-gradient(180deg, #111213 0%, #0D0D0E 100%) !important;
}

/* ═══════════════════════════════════════════════════════════════
   TOPBAR V2 ENHANCEMENTS
   ═══════════════════════════════════════════════════════════════ */
.topbar {
  backdrop-filter: blur(12px);
}
[data-theme="dark"] .topbar {
  background: rgba(26,27,28,.85) !important;
  border-bottom-color: rgba(255,255,255,.06) !important;
}

/* Search bar — pill with inner glow */
.topbar-search input {
  box-shadow: inset 0 1px 3px rgba(0,0,0,.06) !important;
}
.topbar-search input:focus {
  border-color: var(--erp-red) !important;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.06), 0 0 0 3px var(--erp-red-10) !important;
  outline: none !important;
}

/* Notification bell pulse */
.topbar-notif-btn { position: relative; }
.notif-pulse {
  position: absolute;
  top: 6px; inset-inline-end: 6px;
  width: 8px; height: 8px;
  background: var(--erp-red);
  border-radius: 50%;
  border: 2px solid var(--topbar-bg);
}
.notif-pulse::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: var(--erp-red);
  opacity: .4;
  animation: pulsering 2s ease-in-out infinite;
}
@keyframes pulsering {
  0%   { transform: scale(1); opacity: .4; }
  70%  { transform: scale(2); opacity: 0; }
  100% { transform: scale(2); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .notif-pulse::after { animation: none; }
}

/* ═══════════════════════════════════════════════════════════════
   CARDS & KPI WIDGETS V2
   ═══════════════════════════════════════════════════════════════ */
.stat-card, .kpi-card {
  position: relative;
  overflow: hidden;
  transition: transform 200ms ease, box-shadow 200ms ease !important;
}
.stat-card:hover, .kpi-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: var(--shadow-lg) !important;
}
@media (prefers-reduced-motion: reduce) {
  .stat-card:hover, .kpi-card:hover { transform: none !important; }
}

/* Left accent border on stat cards */
.stat-card::before, .kpi-card::before {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  border-radius: var(--r-full) 0 0 var(--r-full);
  background: var(--erp-red);
  opacity: .7;
}
[dir="rtl"] .stat-card::before, [dir="rtl"] .kpi-card::before {
  inset-inline-start: auto;
  inset-inline-end: 0;
  border-radius: 0 var(--r-full) var(--r-full) 0;
}

/* Card icon circle glow */
.stat-icon, .kpi-icon {
  border-radius: 12px !important;
  position: relative;
}
.stat-icon::after, .kpi-icon::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 16px;
  background: inherit;
  opacity: .15;
  filter: blur(6px);
  z-index: -1;
}

/* Section/page cards */
.card {
  border-radius: var(--r-xl) !important;
  transition: box-shadow 200ms ease !important;
}
.card:hover { box-shadow: var(--shadow-md) !important; }

/* Dark mode glass cards */
[data-theme="dark"] .card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .kpi-card {
  background: rgba(55,57,58,.5) !important;
  backdrop-filter: blur(8px);
  border-color: rgba(255,255,255,.06) !important;
}

/* ═══════════════════════════════════════════════════════════════
   TABLE V2 ENHANCEMENTS
   ═══════════════════════════════════════════════════════════════ */
.data-table tbody tr:nth-child(even) {
  background: rgba(0,0,0,.018);
}
[data-theme="dark"] .data-table tbody tr:nth-child(even) {
  background: rgba(255,255,255,.02);
}
.data-table tbody tr {
  border-inline-start: 3px solid transparent;
  transition: border-color 150ms ease, background 150ms ease !important;
}
.data-table tbody tr:hover {
  border-inline-start-color: var(--erp-red) !important;
  background: var(--erp-red-10) !important;
}
[dir="rtl"] .data-table tbody tr {
  border-inline-start: none;
  border-inline-end: 3px solid transparent;
}
[dir="rtl"] .data-table tbody tr:hover {
  border-inline-end-color: var(--erp-red) !important;
}
.data-table th {
  letter-spacing: .3px;
  font-size:12px !important;
  font-weight: 700 !important;
  text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════════════════
   BUTTON V2 ENHANCEMENTS
   ═══════════════════════════════════════════════════════════════ */

/* Primary: gradient + stronger glow */
.btn-primary {
  background: linear-gradient(135deg, #383838 0%, #171717 100%) !important;
  box-shadow: 0 2px 12px rgba(23,23,23,.25) !important;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #525252 0%, #000000 100%) !important;
  box-shadow: 0 4px 20px rgba(23,23,23,.4) !important;
}
.btn-primary:active { transform: scale(.98); }

/* Ghost button variant */
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 600; color: var(--text-2);
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
  cursor: pointer; touch-action: manipulation;
}
.btn-ghost:hover { border-color: var(--erp-red); color: var(--erp-red); background: var(--erp-red-10); }

/* Danger button — independent of brand accent, see index.html's --danger */
.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px;
  background: linear-gradient(135deg, #EF4444, #c62d2d);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(239,68,68,.25);
  cursor: pointer; touch-action: manipulation;
  transition: box-shadow 150ms ease, transform 100ms ease;
}
.btn-danger:hover { box-shadow: 0 4px 16px rgba(239,68,68,.4); }
.btn-danger:active { transform: scale(.97); }

/* ═══════════════════════════════════════════════════════════════
   BADGE / STATUS PILLS V2
   ═══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size:12px; font-weight: 700; letter-spacing: .2px;
}
.badge-success  { background: rgba(52,211,153,.12); color: #10b981; }
.badge-warning  { background: rgba(251,191,36,.12);  color: #d97706; }
.badge-danger   { background: rgba(239,68,68,.10);   color: var(--danger, #EF4444); }
.badge-info     { background: rgba(59,130,246,.10);  color: #3b82f6; }
.badge-neutral  { background: rgba(136,136,136,.1);  color: var(--text-3); }
.badge-purple   { background: rgba(167,139,250,.12); color: #8b5cf6; }
[data-theme="dark"] .badge-success { color: #34d399; }
[data-theme="dark"] .badge-warning { color: #fbbf24; }
[data-theme="dark"] .badge-info    { color: #60a5fa; }

/* ═══════════════════════════════════════════════════════════════
   MODAL V2 ENHANCEMENTS
   ═══════════════════════════════════════════════════════════════ */

/* Backdrop: frosted glass */
.modal-overlay {
  backdrop-filter: blur(6px) !important;
  background: rgba(0,0,0,.5) !important;
}
[data-theme="dark"] .modal-overlay {
  background: rgba(0,0,0,.7) !important;
}

/* Modal panel: top accent line */
.modal {
  border-radius: var(--r-xl) !important;
  border-top: 3px solid var(--erp-red) !important;
  animation: modalIn 220ms cubic-bezier(.16,1,.3,1) !important;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .modal { animation: none !important; }
}

/* Modal header */
.modal-header {
  border-bottom: 1px solid var(--border) !important;
  padding-bottom: 16px !important;
}
.modal-title { font-size: var(--fs-lg) !important; font-weight: 700 !important; }

/* ═══════════════════════════════════════════════════════════════
   FORM INPUT V2 ENHANCEMENTS
   ═══════════════════════════════════════════════════════════════ */
.form-control {
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease !important;
}
.form-control:focus {
  border-color: var(--erp-red) !important;
  box-shadow: 0 0 0 3px var(--erp-red-10) !important;
}
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 32px;
}
[dir="rtl"] select.form-control {
  background-position: right 12px center;
  padding-left: inherit;
  padding-right: 32px;
}

/* ═══════════════════════════════════════════════════════════════
   PAGE TRANSITIONS
   ═══════════════════════════════════════════════════════════════ */
.page-content {
  animation: pageEnter 250ms cubic-bezier(.16,1,.3,1);
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .page-content { animation: none; }
}

/* ═══════════════════════════════════════════════════════════════
   TOAST V2 ENHANCEMENTS
   ═══════════════════════════════════════════════════════════════ */
.toast {
  border-inline-start: 4px solid var(--erp-red) !important;
  backdrop-filter: blur(8px) !important;
  animation: toastIn 300ms cubic-bezier(.16,1,.3,1) !important;
}
.toast.success { border-inline-start-color: var(--green) !important; }
.toast.error   { border-inline-start-color: var(--erp-red) !important; }
.toast.warning { border-inline-start-color: var(--amber) !important; }
.toast.info    { border-inline-start-color: var(--blue) !important; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATE V2
   ═══════════════════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
  gap: 16px;
}
.empty-state-icon {
  width: 72px; height: 72px;
  background: var(--erp-red-10);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size:24px; color: var(--erp-red);
  margin-bottom: 8px;
}
.empty-state h3 { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; }
.empty-state p  { font-size: 13px; color: var(--text-3); max-width: 300px; margin: 0; }

/* ═══════════════════════════════════════════════════════════════
   SKELETON LOADING V2
   ═══════════════════════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card2) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background: var(--bg-card); }
}

/* ═══════════════════════════════════════════════════════════════
   SCROLLBAR V2 — Thinner, on-theme
   ═══════════════════════════════════════════════════════════════ */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ═══════════════════════════════════════════════════════════════
   FOCUS RINGS V2 — More visible
   ═══════════════════════════════════════════════════════════════ */
:focus-visible {
  outline: 2px solid var(--erp-red) !important;
  outline-offset: 3px !important;
  border-radius: var(--r-sm) !important;
}

/* ═══════════════════════════════════════════════════════════════
   MISC POLISH
   ═══════════════════════════════════════════════════════════════ */

/* Page loader bar */
#page-loader {
  background: linear-gradient(90deg, var(--erp-red), #ff6b88, var(--erp-red)) !important;
  background-size: 200% !important;
  animation: loaderShimmer 1.5s ease infinite !important;
}
@keyframes loaderShimmer {
  0%   { background-position: 0%; }
  100% { background-position: 200%; }
}
@media (prefers-reduced-motion: reduce) {
  #page-loader { animation: none !important; }
}

/* Selection color */
::selection { background: rgba(230,43,72,.15); }

/* Chip/tag components */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: 12px; font-weight: 600; color: var(--text-2);
}

/* ── Sidebar Footer Compact ────────────────────────────────────── */
.sidebar-footer     { padding: var(--sp2) var(--sp2) !important; }

/* ── Employee Login Block ──────────────────────────────────────── */
.emp-login-block {
  margin-top: 14px;
  padding: 14px 16px 12px;
  background: color-mix(in srgb, var(--erp-red) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--erp-red) 30%, transparent);
  border-right: 3px solid var(--erp-red);
  border-radius: var(--r-md);
}
.emp-login-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 12px;
}
.emp-login-title .ti { color: var(--erp-red); font-size:16px; }
.emp-login-hint {
  margin: 8px 0 0;
  font-size:12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 5px;
}
.input-password-wrap { position: relative; }
.input-password-wrap .form-control { padding-left: 36px; }
[dir="rtl"] .input-password-wrap .form-control { padding-left: unset; padding-right: 36px; }
.pw-toggle {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer; color: var(--text-3);
  padding: 0; font-size:14px; line-height: 1;
  transition: color 150ms;
}
[dir="rtl"] .pw-toggle { left: unset; right: 10px; }
.pw-toggle:hover { color: var(--erp-red); }

/* Print styles */
@media print {
  .sidebar, .topbar, .modal-overlay { display: none !important; }
  .main-content { margin: 0 !important; padding: 16px !important; }
}
