@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --brand: #4f7cff;
  --brand-dark: #3a5fe0;
  --brand-soft: #eef2ff;
  --radius: 14px;
}

* { font-family: 'Inter', system-ui, -apple-system, sans-serif; }

body {
  background-color: #f5f7fb;
  transition: background-color .2s ease, color .2s ease;
}

/* ---------- Navbar ---------- */
.navbar-cba {
  background: linear-gradient(135deg, #1b2340 0%, #2b3a67 100%);
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.navbar-cba .navbar-brand { font-weight: 700; letter-spacing: .3px; }
.navbar-cba .nav-link { opacity: .85; }
.navbar-cba .nav-link:hover { opacity: 1; }

.badge-rol {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ---------- Cards ---------- */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .08);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid rgba(0,0,0,.06);
  font-weight: 600;
}
.card-stat {
  border-left: 4px solid var(--brand);
}
.card-stat.stat-warning { border-left-color: #f5a524; }
.card-stat.stat-success { border-left-color: #17c964; }

/* ---------- Buttons ---------- */
.btn { border-radius: 10px; font-weight: 500; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

/* ---------- Tables ---------- */
.table { border-radius: var(--radius); overflow: hidden; }
.table-sm td, .table-sm th { vertical-align: middle; }
.table thead th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  border-bottom-width: 1px;
}

/* Producto con stock bajo el minimo */
.low-stock { background-color: #fff6e0 !important; }

/* Producto ya revisado / con precio actualizado desde la migracion */
.row-actualizado { background-color: #eafef1 !important; }
.badge-actualizado { background-color: #17c964; }
.badge-sin-actualizar { background-color: #9ca3af; }

/* ---------- Forms ---------- */
.form-control, .form-select { border-radius: 10px; }
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(79,124,255,.15);
}

/* ---------- Utilities ---------- */
.text-brand { color: var(--brand); }
.bg-brand-soft { background-color: var(--brand-soft); }

/* ---------- Dark mode toggle button ---------- */
.theme-toggle {
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08);
  color: #fff;
  border-radius: 10px;
  padding: .35rem .6rem;
  line-height: 1;
}
.theme-toggle:hover { background: rgba(255,255,255,.18); }

/* =========================================================
   DARK MODE (Bootstrap 5.3 data-bs-theme="dark" + overrides)
   ========================================================= */
[data-bs-theme="dark"] body { background-color: #10131c; color: #e5e7eb; }
[data-bs-theme="dark"] .card { background-color: #171b28; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
[data-bs-theme="dark"] .card-header { border-bottom-color: rgba(255,255,255,.08); }
[data-bs-theme="dark"] .table { --bs-table-bg: #171b28; color: #e5e7eb; }
[data-bs-theme="dark"] .table thead th { color: #9aa3b2; }
[data-bs-theme="dark"] .low-stock { background-color: #3a2f10 !important; color: #ffe6a3; }
[data-bs-theme="dark"] .row-actualizado { background-color: #10321f !important; color: #b9f5d0; }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select {
  background-color: #1e2333; color: #e5e7eb; border-color: #2b3145;
}
[data-bs-theme="dark"] .form-control:focus, [data-bs-theme="dark"] .form-select:focus {
  background-color: #1e2333; color: #e5e7eb;
}
[data-bs-theme="dark"] .text-muted { color: #8b93a7 !important; }
[data-bs-theme="dark"] .dropdown-menu { background-color: #171b28; }
[data-bs-theme="dark"] .dropdown-item { color: #e5e7eb; }
[data-bs-theme="dark"] .dropdown-item:hover { background-color: #232946; color: #fff; }
[data-bs-theme="dark"] .bg-brand-soft { background-color: #1b2340; }
[data-bs-theme="dark"] a { color: #8fb0ff; }

.precio-venta-input {
  background-color: #eafbe7 !important;
  border: 2px solid #17c964 !important;
  font-weight: 600;
}
[data-bs-theme="dark"] .precio-venta-input {
  background-color: #10321f !important;
  border-color: #17c964 !important;
  color: #b9f5d0 !important;
}

#resultados { min-height: 300px; }

.form-label { display: block; margin-bottom: .35rem; }

/* ---------- Menu desplegable propio (reemplaza al <select> nativo) ---------- */
.custom-select-wrapper {
  position: relative;
}
.custom-select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.custom-select-trigger {
  width: 100%;
  text-align: left;
  background-color: #fff;
  cursor: pointer;
  position: relative;
  padding-right: 2rem;
}
.custom-select-trigger::after {
  content: "";
  position: absolute;
  right: .9rem;
  top: 50%;
  width: .55em;
  height: .55em;
  border-right: 2px solid #6b7280;
  border-bottom: 2px solid #6b7280;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.custom-select-trigger.open::after {
  transform: translateY(-30%) rotate(-135deg);
}
.custom-select-panel {
  display: none;
  position: absolute;
  z-index: 1050;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15,23,42,.15);
  padding: .4rem;
}
.custom-select-panel.open { display: block; }
.custom-select-search {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: .4rem .6rem;
  font-size: .9rem;
  margin-bottom: .3rem;
}
.custom-select-list {
  max-height: 260px;
  overflow-y: auto;
}
.custom-select-option {
  padding: .4rem .6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .92rem;
  white-space: normal;
}
.custom-select-option:hover { background-color: var(--brand-soft); }
.custom-select-option.active { background-color: var(--brand); color: #fff; }
.custom-select-group-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #6b7280;
  padding: .5rem .5rem .15rem;
}
.custom-select-empty {
  padding: .5rem .6rem;
  color: #6b7280;
  font-size: .9rem;
}

[data-bs-theme="dark"] .custom-select-trigger { background-color: #1e2333; color: #e5e7eb; border-color: #2b3145; }
[data-bs-theme="dark"] .custom-select-trigger::after { border-color: #9aa3b2; }
[data-bs-theme="dark"] .custom-select-panel { background: #171b28; border-color: #2b3145; }
[data-bs-theme="dark"] .custom-select-search { background: #1e2333; color: #e5e7eb; border-color: #2b3145; }
[data-bs-theme="dark"] .custom-select-option:hover { background-color: #232946; }
[data-bs-theme="dark"] .custom-select-group-label { color: #9aa3b2; }
[data-bs-theme="dark"] .custom-select-empty { color: #9aa3b2; }

@media print {
  nav, .no-print { display: none !important; }
}
