/* =====================================================================
   StockPro — Tema visual (dark / light) sobre Bootstrap 5
   Dirección: ERP industrial. Acero + ámbar. Cifras en monoespaciada.
   ===================================================================== */

:root {
  --font-display: "Sora", system-ui, sans-serif;
  --font-body:    "Inter", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, monospace;

  --brand:      #3d7dff;   /* acero */
  --brand-2:    #6aa1ff;
  --accent:     #f6a623;   /* ámbar industrial */
  --ok:         #22c55e;
  --warn:       #f59e0b;
  --danger:     #f43f5e;
  --info:       #38bdf8;
  --radius:     14px;
  --radius-sm:  10px;
  --sidebar-w:  262px;
  --topbar-h:   64px;
  --shadow-sm:  0 1px 2px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
  --shadow-md:  0 6px 24px rgba(2,6,23,.10);
  --shadow-lg:  0 24px 60px -18px rgba(2,6,23,.35);
}

/* ------------------------- DARK (por defecto) ------------------------ */
[data-theme="dark"] {
  --bg:        #0b0f17;
  --bg-2:      #0f1521;
  --surface:   #131b2b;
  --surface-2: #182238;
  --line:      #1f2b40;
  --line-2:    #2a3a57;
  --text:      #e6edf7;
  --text-2:    #9fb0c9;
  --text-3:    #64748b;
  --sidebar:   #0a0e16;
  --hover:     #182238;
  color-scheme: dark;
}

/* ------------------------------ LIGHT -------------------------------- */
[data-theme="light"] {
  --bg:        #f4f6fb;
  --bg-2:      #eef1f8;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --line:      #e6eaf2;
  --line-2:    #d7ddeb;
  --text:      #0f1b2d;
  --text-2:    #51607a;
  --text-3:    #8a97ac;
  --sidebar:   #0b1220;
  --hover:     #f1f5fb;
  color-scheme: light;
}

/* ------------------------------ BASE --------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
h1,h2,h3,h4,h5,h6,.h-display { font-family: var(--font-display); letter-spacing: -.01em; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { color: var(--brand); }
.mono, .num { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 20px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ----------------------------- LAYOUT -------------------------------- */
.app { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid rgba(255,255,255,.04);
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 1040;
  transition: transform .28s cubic-bezier(.4,0,.2,1), width .28s;
}
.sidebar__brand {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; color: #fff; flex: 0 0 auto;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.sidebar__logo {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  display: grid; place-items: center; color: #fff; font-size: 16px;
  background: linear-gradient(135deg, var(--brand), #2456c9);
  box-shadow: 0 4px 14px rgba(61,125,255,.45);
}
.sidebar__title { font-family: var(--font-display); font-weight: 700; font-size: 17px; line-height: 1; }
.sidebar__title small { display:block; font-size: 10px; color: #7d8aa5; font-weight: 500; margin-top: 3px; letter-spacing:.04em; }
.sidebar__nav { flex: 1 1 auto; overflow-y: auto; padding: 12px 12px 24px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: #1c2740; }

.nav-group {
  color: #5b6883; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; padding: 16px 12px 6px;
}
.nav-link-x {
  display: flex; align-items: center; gap: 12px;
  color: #aeb9cf; padding: 9px 12px; border-radius: 9px;
  font-size: 13.5px; font-weight: 500; margin-bottom: 2px;
  position: relative; transition: background .15s, color .15s;
}
.nav-link-x i { width: 18px; text-align: center; font-size: 14px; color: #6b7896; transition: color .15s; }
.nav-link-x:hover { background: rgba(255,255,255,.045); color: #fff; }
.nav-link-x:hover i { color: var(--brand-2); }
.nav-link-x.active { background: linear-gradient(90deg, rgba(61,125,255,.18), rgba(61,125,255,.02)); color: #fff; }
.nav-link-x.active i { color: var(--brand-2); }
.nav-link-x.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  background: var(--brand); border-radius: 0 3px 3px 0;
}

/* MAIN */
.main { flex: 1 1 auto; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; transition: margin .28s; }
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 1030;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
}
.content { padding: 24px 26px 60px; flex: 1 1 auto; }

/* toggle sidebar collapsed */
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main { margin-left: 0; }

/* SEARCH */
.global-search { position: relative; max-width: 420px; flex: 1 1 auto; }
.global-search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 13px; }
.global-search input {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 9px 14px 9px 38px; font-size: 13px;
  transition: border .15s, box-shadow .15s;
}
.global-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(61,125,255,.15); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-2); display: grid; place-items: center;
  cursor: pointer; transition: .15s; position: relative;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); background: var(--hover); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }

.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 6px; border-radius: 10px; }
.user-chip:hover { background: var(--hover); }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff; font-family: var(--font-display);
  background: linear-gradient(135deg, #7c3aed, var(--brand));
}

/* PAGE HEADER */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; font-weight: 700; margin: 0 0 3px; }
.page-head .sub { color: var(--text-2); font-size: 13px; }
.breadcrumb-x { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.breadcrumb-x a { color: var(--text-3); }
.breadcrumb-x a:hover { color: var(--brand-2); }
.breadcrumb-x .sep { opacity: .5; }

/* ----------------------------- CARDS --------------------------------- */
.card-x {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-x + .card-x { margin-top: 18px; }
.card-x__head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-x__head h2, .card-x__head h3 { font-size: 15px; font-weight: 600; margin: 0; }
.card-x__head .desc { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.card-x__body { padding: 20px; }

/* KPI CARDS */
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-2); }
.kpi__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.kpi__label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.kpi__icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 16px; }
.kpi__value { font-family: var(--font-mono); font-size: 27px; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.kpi__foot { margin-top: 12px; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.kpi .trend-up { color: var(--ok); font-weight: 600; }
.kpi .trend-down { color: var(--danger); font-weight: 600; }
.kpi::after { content:""; position:absolute; right:-30px; top:-30px; width:120px; height:120px; border-radius:50%; opacity:.06; }

.tone-brand  .kpi__icon { background: rgba(61,125,255,.14); color: var(--brand-2); }
.tone-brand::after  { background: var(--brand); }
.tone-accent .kpi__icon { background: rgba(246,166,35,.15); color: var(--accent); }
.tone-accent::after { background: var(--accent); }
.tone-ok     .kpi__icon { background: rgba(34,197,94,.14); color: var(--ok); }
.tone-ok::after     { background: var(--ok); }
.tone-danger .kpi__icon { background: rgba(244,63,94,.14); color: var(--danger); }
.tone-danger::after { background: var(--danger); }
.tone-info   .kpi__icon { background: rgba(56,189,248,.14); color: var(--info); }
.tone-info::after   { background: var(--info); }
.tone-violet .kpi__icon { background: rgba(139,92,246,.16); color: #a78bfa; }
.tone-violet::after { background: #8b5cf6; }

/* ----------------------------- BADGES -------------------------------- */
.badge-soft { font-weight: 600; font-size: 11px; padding: 4px 9px; border-radius: 7px; letter-spacing: .01em; }
.badge-success { background: rgba(34,197,94,.14);  color: #4ade80; }
.badge-danger  { background: rgba(244,63,94,.14);  color: #fb7185; }
.badge-warning { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-info    { background: rgba(56,189,248,.15); color: #38bdf8; }
.badge-secondary { background: rgba(100,116,139,.18); color: #94a3b8; }
[data-theme="light"] .badge-success { color:#15803d;} 
[data-theme="light"] .badge-danger  { color:#be123c;}
[data-theme="light"] .badge-warning { color:#b45309;}
[data-theme="light"] .badge-info    { color:#0369a1;}
[data-theme="light"] .badge-secondary{color:#475569;}

/* ----------------------------- TABLES -------------------------------- */
.table-wrap { overflow-x: auto; }
table.tx { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tx thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--surface);
}
table.tx tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--text); vertical-align: middle; }
table.tx tbody tr { transition: background .12s; }
table.tx tbody tr:hover { background: var(--hover); }
table.tx tbody tr:last-child td { border-bottom: none; }
table.tx td.num, table.tx th.num { text-align: right; font-family: var(--font-mono); font-feature-settings:"tnum" 1; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 11.5px; color: var(--text-3); }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--surface-2); border:1px solid var(--line); }
.thumb-i { width:40px;height:40px;border-radius:8px;display:grid;place-items:center;background:var(--surface-2);border:1px solid var(--line);color:var(--text-3);}

/* DataTables overrides */
.dataTables_wrapper { color: var(--text-2); }
.dataTables_filter input, .dataTables_length select {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 6px 10px; margin-left: 6px;
}
.dataTables_filter input:focus { outline: none; border-color: var(--brand); }
.dataTables_paginate .paginate_button {
  padding: 5px 11px !important; margin: 0 2px; border-radius: 8px !important;
  border: 1px solid var(--line) !important; color: var(--text-2) !important; background: var(--surface) !important;
}
.dataTables_paginate .paginate_button.current { background: var(--brand) !important; color: #fff !important; border-color: var(--brand) !important; }
.dataTables_paginate .paginate_button:hover { background: var(--hover) !important; color: var(--text) !important; }
.dataTables_info { font-size: 12px; color: var(--text-3); padding-top: 12px !important; }
table.dataTable { border-collapse: collapse !important; }

/* ----------------------------- BUTTONS ------------------------------- */
.btn { font-size: 13px; font-weight: 600; border-radius: 10px; padding: 9px 16px; border: 1px solid transparent; }
.btn-brand { background: var(--brand); color: #fff; }
.btn-brand:hover { background: #2f6ae6; color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); border-color: var(--line-2); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; }

/* SEGMENTED */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: none; background: transparent; color: var(--text-2); font-size: 12.5px; font-weight: 600; padding: 6px 14px; border-radius: 7px; cursor: pointer; transition: .15s; }
.seg button.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }

/* FILTERS BAR */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .form-select-x, .filters .form-input-x {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 8px 12px; font-size: 13px; min-width: 150px;
}
.filters .form-select-x:focus, .filters .form-input-x:focus { outline: none; border-color: var(--brand); }

/* PROGRESS bar */
.bar { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 6px; }

/* MISC */
.muted { color: var(--text-3); }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.dropdown-menu { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); border-radius: 12px; }
.dropdown-item { color: var(--text-2); font-size: 13px; padding: 8px 14px; border-radius: 8px; }
.dropdown-item:hover { background: var(--hover); color: var(--text); }
.dropdown-header { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-state i { font-size: 42px; opacity: .4; margin-bottom: 14px; }

/* activity feed */
.feed-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: none; }
.feed-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 34px; font-size: 13px; }
.feed-body { flex: 1; min-width: 0; }
.feed-body .t { font-size: 13px; font-weight: 500; }
.feed-body .m { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* progress ring for physical count */
.mini-stat { display:flex; align-items:center; gap:10px; }
.mini-stat .n { font-family: var(--font-mono); font-weight:700; font-size:18px; }

/* toast/login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(1200px 600px at 20% -10%, rgba(61,125,255,.20), transparent 60%),
  radial-gradient(900px 500px at 100% 100%, rgba(246,166,35,.12), transparent 55%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 34px; }
.form-label-x { font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; display:block; }
.form-control-x { width: 100%; background: var(--bg-2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 11px 14px; font-size: 14px; }
.form-control-x:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(61,125,255,.15); }

/* ---------------------------- RESPONSIVE ----------------------------- */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open::after { content:""; position: fixed; inset: 0; background: rgba(2,6,23,.55); z-index: 1035; }
  .global-search { max-width: none; }
}
@media (max-width: 640px) {
  .content { padding: 16px 14px 48px; }
  .kpi__value { font-size: 23px; }
  .hide-sm { display: none !important; }
}

/* chart canvas height guard */
.chart-box { position: relative; }
