/* ===========================================================
   NODO Shell — Inputs reusables
   ===========================================================
   text · money · ruc · ci · phone · email · date · dateRange
   select (combobox searchable) · switch · textarea
   Tema-aware (Office/Bloomberg/Slate).
   =========================================================== */

/* ---------- Wrapper común ---------- */
.ni {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-ui);
  position: relative;
}
.ni__label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: var(--fw-semi);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ni__label-required { color: var(--danger); font-weight: bold; }
.ni__hint  { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.ni__error { font-size: 10px; color: var(--danger); margin-top: 2px; min-height: 13px; }

/* ---------- Input base (text/email/phone/ruc/ci/money) ---------- */
.ni__input {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--sil-500);
  background: #fff;
  border-radius: 2px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  height: 26px;
}
.ni__input:focus-within {
  border-color: var(--ofc-blue-500);
  box-shadow: 0 0 0 1px var(--ofc-blue-300), inset 0 1px 2px rgba(0,0,0,0.06);
}
.ni__input--invalid {
  border-color: var(--danger);
}
.ni__input--invalid:focus-within {
  box-shadow: 0 0 0 1px rgba(164,0,0,0.4), inset 0 1px 2px rgba(0,0,0,0.06);
}
.ni__input--readonly { background: var(--sil-100); }
.ni__input--disabled { background: var(--sil-100); opacity: 0.7; cursor: not-allowed; }

.ni__input input {
  flex: 1;
  padding: 0 8px;
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--fs-sm);
  color: var(--text);
  font-family: inherit;
  min-width: 0;
}
.ni__input input::placeholder { color: var(--text-muted); opacity: 0.7; }
.ni__input--money input,
.ni__input--ruc input,
.ni__input--ci input,
.ni__input--phone input,
.ni__input--date input,
.ni__input--time input {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.ni__input--money input { text-align: right; }

.ni__prefix,
.ni__suffix {
  padding: 0 8px;
  display: flex;
  align-items: center;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  background: var(--sil-100);
  white-space: nowrap;
  user-select: none;
}
.ni__prefix { border-right: 1px solid var(--sil-400); }
.ni__suffix { border-left:  1px solid var(--sil-400); cursor: pointer; }
.ni__suffix svg { width: 14px; height: 14px; }
.ni__suffix:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- Textarea ---------- */
.ni__textarea {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--sil-500);
  background: #fff;
  border-radius: 2px;
  font-size: var(--fs-sm);
  color: var(--text);
  font-family: inherit;
  outline: none;
  resize: vertical;
  min-height: 60px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}
.ni__textarea:focus {
  border-color: var(--ofc-blue-500);
  box-shadow: 0 0 0 1px var(--ofc-blue-300), inset 0 1px 2px rgba(0,0,0,0.06);
}
.ni__textarea-counter {
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  margin-top: 2px;
}

/* ---------- Select (searchable combobox) ---------- */
.ni__select {
  position: relative;
}
.ni__select-control {
  display: flex;
  align-items: center;
  height: 26px;
  border: 1px solid var(--sil-500);
  background: #fff;
  border-radius: 2px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
  cursor: pointer;
  padding: 0 6px 0 8px;
  font-size: var(--fs-sm);
  color: var(--text);
  gap: 4px;
}
.ni__select-control:hover { border-color: var(--ofc-blue-300); }
.ni__select-control:focus { outline: none; border-color: var(--ofc-blue-500); box-shadow: 0 0 0 1px var(--ofc-blue-300); }
.ni__select-value { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ni__select-value--placeholder { color: var(--text-muted); }
.ni__select-arrow {
  width: 10px; height: 10px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.ni__select-arrow svg { width: 8px; height: 8px; }

.ni__select-menu {
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  right: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  display: none;
  max-height: 280px;
  overflow: hidden;
  flex-direction: column;
}
.ni__select--open .ni__select-menu { display: flex; }
.ni__select-search {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--sil-50);
}
.ni__select-search input {
  width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--sil-400);
  border-radius: 2px;
  font-size: var(--fs-sm);
  outline: none;
  background: #fff;
}
.ni__select-search input:focus { border-color: var(--ofc-blue-500); }
.ni__select-options {
  flex: 1;
  overflow: auto;
  padding: 2px 0;
}
.ni__select-opt {
  padding: 4px 10px;
  font-size: var(--fs-sm);
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.ni__select-opt:hover { background: var(--bg-hover); }
.ni__select-opt[aria-selected="true"] { background: var(--ofc-blue-100); color: var(--ofc-blue-900); font-weight: var(--fw-semi); }
.ni__select-opt--focused { background: var(--ofc-blue-100); }
.ni__select-empty { padding: 12px; text-align: center; color: var(--text-muted); font-size: 11px; font-style: italic; }

/* ---------- Switch ---------- */
.ni__switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: var(--fs-sm);
}
.ni__switch-track {
  position: relative;
  width: 36px;
  height: 18px;
  background: linear-gradient(180deg, #d6dce3 0%, #bbc4cf 100%);
  border: 1px solid var(--sil-500);
  border-radius: 10px;
  transition: background var(--t);
  flex-shrink: 0;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}
.ni__switch-track::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  background: linear-gradient(180deg, #fff 0%, #e5e9ef 100%);
  border: 1px solid var(--sil-500);
  border-radius: 50%;
  transition: transform var(--t);
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.ni__switch input { display: none; }
.ni__switch input:checked + .ni__switch-track {
  background: linear-gradient(180deg, var(--ofc-blue-500) 0%, var(--ofc-blue-700) 100%);
  border-color: var(--ofc-blue-900);
}
.ni__switch input:checked + .ni__switch-track::after {
  transform: translateX(18px);
  border-color: var(--ofc-blue-900);
}

/* ---------- Date picker popup ---------- */
.ni__datepicker {
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  padding: 6px;
  display: none;
  width: 250px;
}
.ni__datepicker--open { display: block; }
.ni__datepicker-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.ni__datepicker-title {
  flex: 1;
  text-align: center;
  font-weight: var(--fw-semi);
  color: var(--ofc-blue-900);
  font-size: var(--fs-sm);
  text-transform: capitalize;
}
.ni__datepicker-nav {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}
.ni__datepicker-nav:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.ni__datepicker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}
.ni__datepicker-grid .ni__dp-dow {
  font-size: 9px;
  text-align: center;
  padding: 3px 0;
  color: var(--text-muted);
  font-weight: var(--fw-semi);
  text-transform: uppercase;
}
.ni__datepicker-grid .ni__dp-cell {
  padding: 4px 0;
  text-align: center;
  font-size: 11px;
  cursor: pointer;
  border-radius: 2px;
  border: 1px solid transparent;
  font-family: var(--font-mono);
  color: var(--text);
}
.ni__datepicker-grid .ni__dp-cell:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.ni__datepicker-grid .ni__dp-cell--other { color: var(--text-muted); opacity: 0.5; }
.ni__datepicker-grid .ni__dp-cell--today {
  border-color: var(--ofc-blue-700);
  font-weight: bold;
}
.ni__datepicker-grid .ni__dp-cell--selected {
  background: var(--ofc-blue-700);
  color: #fff;
  font-weight: bold;
}
.ni__datepicker-grid .ni__dp-cell--in-range {
  background: var(--ofc-blue-100);
  color: var(--ofc-blue-900);
  border-radius: 0;
}
.ni__datepicker-footer {
  display: flex;
  gap: 4px;
  padding-top: 6px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  justify-content: space-between;
}
.ni__datepicker-quick {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--sil-100);
  border: 1px solid var(--sil-400);
  border-radius: 2px;
  cursor: pointer;
  color: var(--text);
}
.ni__datepicker-quick:hover { background: var(--bg-hover); border-color: var(--border-hover); }

/* ---------- Date range (dos inputs lado a lado) ---------- */
.ni__daterange {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ni__daterange .ni__input { flex: 1; }
.ni__daterange-sep { color: var(--text-muted); font-size: var(--fs-sm); padding: 0 2px; }


/* =============================================================
   THEME OVERRIDES — Bloomberg
   ============================================================= */
[data-theme="bloomberg"] .ni__input,
[data-theme="bloomberg"] .ni__textarea,
[data-theme="bloomberg"] .ni__select-control {
  background: #1a1a1a;
  border-color: #3a3a3a;
  color: #e8e8e8;
}
[data-theme="bloomberg"] .ni__input:focus-within,
[data-theme="bloomberg"] .ni__textarea:focus,
[data-theme="bloomberg"] .ni__select-control:focus {
  border-color: #d4a76a;
  box-shadow: 0 0 0 1px rgba(212,167,106,0.5);
}
[data-theme="bloomberg"] .ni__input input,
[data-theme="bloomberg"] .ni__textarea { color: #e8e8e8; }
[data-theme="bloomberg"] .ni__input--readonly,
[data-theme="bloomberg"] .ni__input--disabled { background: #2a2a2a; color: #888; }
[data-theme="bloomberg"] .ni__prefix,
[data-theme="bloomberg"] .ni__suffix { background: #2a2a2a; color: #d4a76a; border-color: #3a3a3a; }
[data-theme="bloomberg"] .ni__select-menu {
  background: #2a2a2a;
  border-color: #5a4520;
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
}
[data-theme="bloomberg"] .ni__select-search { background: #1f1f1f; border-bottom-color: #3a3a3a; }
[data-theme="bloomberg"] .ni__select-search input {
  background: #1a1a1a; color: #e8e8e8; border-color: #3a3a3a;
}
[data-theme="bloomberg"] .ni__select-opt { color: #e8e8e8; }
[data-theme="bloomberg"] .ni__select-opt:hover,
[data-theme="bloomberg"] .ni__select-opt--focused {
  background: linear-gradient(180deg, #4a3a20 0%, #3a2a18 100%);
  color: #e8c084;
}
[data-theme="bloomberg"] .ni__select-opt[aria-selected="true"] {
  background: linear-gradient(180deg, #d4a76a 0%, #b8761a 100%);
  color: #1a1a1a;
}
[data-theme="bloomberg"] .ni__switch-track {
  background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
  border-color: #4a4a4a;
}
[data-theme="bloomberg"] .ni__switch input:checked + .ni__switch-track {
  background: linear-gradient(180deg, #d4a76a 0%, #b8761a 100%);
  border-color: #8a5418;
}
[data-theme="bloomberg"] .ni__datepicker {
  background: #232323;
  border-color: #5a4520;
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
}
[data-theme="bloomberg"] .ni__datepicker-title { color: #e8c084; }
[data-theme="bloomberg"] .ni__datepicker-grid .ni__dp-cell { color: #e8e8e8; }
[data-theme="bloomberg"] .ni__datepicker-grid .ni__dp-cell--other { color: #555; }
[data-theme="bloomberg"] .ni__datepicker-grid .ni__dp-cell--today { border-color: #d4a76a; }
[data-theme="bloomberg"] .ni__datepicker-grid .ni__dp-cell--selected { background: #d4a76a; color: #1a1a1a; }
[data-theme="bloomberg"] .ni__datepicker-grid .ni__dp-cell--in-range { background: #3a2a18; color: #e8c084; }
[data-theme="bloomberg"] .ni__datepicker-quick { background: #2a2a2a; border-color: #4a4a4a; color: #e8e8e8; }

/* =============================================================
   THEME OVERRIDES — Slate
   ============================================================= */
[data-theme="slate"] .ni__switch input:checked + .ni__switch-track {
  background: linear-gradient(180deg, #52b788 0%, #2d6a4f 100%);
  border-color: #1b4332;
}
[data-theme="slate"] .ni__datepicker-grid .ni__dp-cell--selected { background: #2d6a4f; }
[data-theme="slate"] .ni__datepicker-grid .ni__dp-cell--in-range { background: #d8f3dc; color: #1b4332; }
