/* ==========================================================================
   BacanoCore — components.css
   Todo en blanco y negro. La jerarquía se expresa con relleno vs contorno:
     relleno negro  = máxima urgencia
     relleno gris   = requiere atención
     contorno       = estado normal
   ========================================================================== */

/* --------------------------------------------------------------------------
   Card
   -------------------------------------------------------------------------- */
.card {
  background: var(--paper);
  border-radius: var(--r-lg);
  padding: var(--pad-card);
  box-shadow: var(--sh-sm);
  position: relative;
  animation: fade-up .3s ease both;
}
.card--flat { box-shadow: none; border: 1px solid var(--ink-100); }
.card--soft { background: var(--paper-2); box-shadow: none; }
.card--dark { background: var(--ink-900); color: var(--paper); }
.card--pad-0 { padding: 0; overflow: hidden; }
.card--tight { padding: 16px; }

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card__title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-700);
}
.card__title::before {
  content: "";
  width: 12px; height: 12px;
  border-radius: 4px;
  background: var(--ink-900);
  flex: none;
}
.card__title--no-dot::before { display: none; }
.card--dark .card__title { color: #fff; }
.card--dark .card__title::before { background: #fff; }

.card__foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--ink-100);
}

/* --------------------------------------------------------------------------
   Botones
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--paper-3);
  color: var(--ink-800);
  transition: background .18s ease, color .18s ease, transform .12s ease;
}
.btn:hover { background: var(--ink-100); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--ink-900); outline-offset: 2px; }
.btn[disabled] { opacity: .4; pointer-events: none; }

.btn--dark { background: var(--ink-900); color: #fff; }
.btn--dark:hover { background: var(--ink-700); }

.btn--ghost { background: transparent; color: var(--ink-600); }
.btn--ghost:hover { background: var(--paper-3); }

.btn--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--ink-200); }
.btn--outline:hover { background: var(--paper-2); }

/* Acción destructiva: contorno negro grueso, sin color */
.btn--danger { background: transparent; color: var(--ink-900); box-shadow: inset 0 0 0 1.5px var(--ink-900); }
.btn--danger:hover { background: var(--ink-900); color: #fff; }

.btn--sm { height: 31px; padding: 0 12px; font-size: 12px; }
.btn--lg { height: 46px; padding: 0 22px; font-size: 14px; }
.btn--block { width: 100%; }
.btn--icon { width: 38px; padding: 0; }

.btn__arrow {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  margin-right: -8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
}

/* Botón circular */
.icon-btn {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--ink-100);
  color: var(--ink-600);
  transition: background .18s ease, color .18s ease;
}
.icon-btn:hover { background: var(--paper-3); color: var(--ink-900); }
.icon-btn--active { background: var(--ink-900); color: #fff; box-shadow: none; }
.icon-btn--sm { width: 30px; height: 30px; }

/* Icono espejado (flecha "volver") */
.ic--flip { transform: scaleX(-1); }

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--r-full);
  background: var(--paper-3);
  color: var(--ink-600);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
/* Máxima urgencia: negro sólido */
.badge--solid,
.badge--dark { background: var(--ink-900); color: #fff; }
/* Atención: gris sólido */
.badge--soft { background: var(--ink-200); color: var(--ink-800); }
/* Normal: contorno */
.badge--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--ink-200); color: var(--ink-600); }

.badge__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.badge--live .badge__dot { animation: pulse-soft 1.8s ease-in-out infinite; }

/* --------------------------------------------------------------------------
   Estado activa / inactiva
   -------------------------------------------------------------------------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-800);
}
.status::before {
  content: "";
  width: 9px; height: 9px;
  border-radius: 50%;
  flex: none;
}
/* Activa: punto negro relleno */
.status--on::before { background: var(--ink-900); }
/* Inactiva: anillo hueco */
.status--off::before {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--ink-300);
}
.status--off { color: var(--ink-400); }

/* --------------------------------------------------------------------------
   Tabs / segmentos
   -------------------------------------------------------------------------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--r-full);
  background: var(--paper-3);
  color: var(--ink-600);
  font-size: 12px;
  font-weight: 600;
  transition: background .18s ease, color .18s ease;
}
.tab:hover { background: var(--ink-100); }
.tab--active { background: var(--ink-900); color: #fff; }

.segment {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: var(--r-full);
  background: var(--paper-3);
}
.segment button {
  height: 30px;
  padding: 0 14px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-600);
}
.segment button.is-active { background: var(--paper); color: var(--ink-900); box-shadow: var(--sh-xs); }

/* --------------------------------------------------------------------------
   Formularios
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--ink-600); }
.field__hint { font-size: 11px; color: var(--ink-400); }
.field__error { font-size: 11px; color: var(--ink-900); font-weight: 700; }

.input,
.select,
.textarea {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  background: var(--paper-2);
  box-shadow: inset 0 0 0 1px var(--ink-100);
  transition: box-shadow .18s ease, background .18s ease;
}
.textarea { height: auto; min-height: 96px; padding: 11px 14px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--ink-300); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  background: var(--paper);
  box-shadow: inset 0 0 0 1.5px var(--ink-900);
}
.input[aria-invalid="true"] { box-shadow: inset 0 0 0 1.5px var(--ink-900); }

.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237a7a7a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.search {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--r-full);
  background: var(--paper-2);
  box-shadow: inset 0 0 0 1px var(--ink-100);
  min-width: 200px;
}
.search input { flex: 1; border: 0; background: none; outline: none; font-size: 13px; }
.search svg { color: var(--ink-300); flex: none; }

/* Checkbox */
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check__box {
  width: 18px; height: 18px;
  border-radius: 5px;
  background: var(--paper-2);
  box-shadow: inset 0 0 0 1.5px var(--ink-200);
  display: grid;
  place-items: center;
  color: transparent;
  transition: background .16s ease, box-shadow .16s ease, color .16s ease;
  flex: none;
}
.check input:checked + .check__box { background: var(--ink-900); box-shadow: none; color: #fff; }
.check input:focus-visible + .check__box { outline: 2px solid var(--ink-900); outline-offset: 2px; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  width: 40px; height: 23px;
  border-radius: var(--r-full);
  background: var(--ink-200);
  padding: 3px;
  transition: background .2s ease;
  flex: none;
}
.switch__thumb {
  width: 17px; height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--sh-xs);
  transition: transform .2s cubic-bezier(.3, .8, .4, 1);
}
.switch input:checked + .switch__track { background: var(--ink-900); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(17px); }

/* --------------------------------------------------------------------------
   Tablas
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { font-size: 13px; }
.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
  text-align: left;
  padding: 0 14px 11px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-300);
  white-space: nowrap;
}
.table tbody td {
  padding: 13px 14px;
  border-top: 1px solid var(--ink-100);
  vertical-align: middle;
}
.table tbody tr { transition: background .15s ease; }
.table tbody tr:hover { background: var(--paper-2); }
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.table .col-tight { width: 1%; white-space: nowrap; }

/* --------------------------------------------------------------------------
   Avatares y listas
   -------------------------------------------------------------------------- */
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink-900);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -.02em;
  flex: none;
  overflow: hidden;
}
.avatar--sm { width: 26px; height: 26px; font-size: 10px; }
.avatar--lg { width: 46px; height: 46px; font-size: 15px; }
.avatar--soft { background: var(--paper-3); color: var(--ink-600); }
.avatar--outline { background: transparent; color: var(--ink-800); box-shadow: inset 0 0 0 1.5px var(--ink-200); }

.list { display: flex; flex-direction: column; }
.list__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--ink-100);
}
.list__item:first-child { border-top: 0; }
.list__item--btn { cursor: pointer; border-radius: var(--r-sm); padding: 11px 10px; margin: 0 -10px; }
.list__item--btn:hover { background: var(--paper-2); }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; font-size: 13px; }
.kv + .kv { border-top: 1px solid var(--ink-100); }
.kv dt { color: var(--ink-400); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

/* --------------------------------------------------------------------------
   Gráfico de barras (monocromo: gris = normal, negro = destacado)
   -------------------------------------------------------------------------- */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 160px;
  padding-top: 22px;
}
.bars__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  gap: 7px;
  position: relative;
}
.bars__bar {
  width: 100%;
  max-width: 26px;
  border-radius: var(--r-full);
  background: var(--ink-200);
  transition: background .2s ease;
  transform-origin: bottom;
  animation: bar-grow .45s cubic-bezier(.2, .8, .3, 1) both;
}
.bars__col:hover .bars__bar { background: var(--ink-400); }
.bars__col--hi .bars__bar { background: var(--ink-900); }
.bars__label { font-size: 10px; color: var(--ink-400); font-weight: 600; }
.bars__peak {
  position: absolute;
  top: -4px;
  transform: translateY(-100%);
  background: var(--ink-900);
  color: #fff;
  font-size: 10px;
  font-weight: 650;
  padding: 3px 8px;
  border-radius: var(--r-full);
  white-space: nowrap;
}
@keyframes bar-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* Barra de progreso */
.meter { height: 8px; border-radius: var(--r-full); background: var(--paper-3); overflow: hidden; }
.meter__fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--ink-900);
  transition: width .5s cubic-bezier(.2, .8, .3, 1);
}

/* Anillo de progreso */
.ring { transform: rotate(-90deg); }
.ring__bg { fill: none; stroke: var(--paper-3); }
.ring__fg { fill: none; stroke: var(--ink-900); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade-up .18s ease both;
}
.modal {
  width: min(560px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: var(--paper);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  padding: 26px;
  animation: fade-up .24s cubic-bezier(.2, .8, .3, 1) both;
}
.modal--wide { width: min(880px, 100%); }
.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.modal__body { display: flex; flex-direction: column; gap: 14px; }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--ink-100);
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */
.toasts {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border-radius: var(--r-md);
  background: var(--ink-900);
  color: #fff;
  box-shadow: var(--sh-md);
  font-size: 13px;
  animation: fade-up .22s cubic-bezier(.2, .8, .3, 1) both;
}
/* Todos los toasts son negros; el matiz lo da el icono y el texto */
.toast--ok, .toast--warn, .toast--danger, .toast--info { background: var(--ink-900); }
.toast__close { color: rgba(255, 255, 255, .6); margin-left: auto; }
.toast__close:hover { color: #fff; }

/* --------------------------------------------------------------------------
   Estados vacíos / carga
   -------------------------------------------------------------------------- */
.empty {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 54px 20px;
  text-align: center;
  color: var(--ink-400);
}
.empty__icon {
  width: 52px; height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--paper-3);
  color: var(--ink-300);
}

.skeleton {
  background: linear-gradient(90deg, var(--paper-3) 25%, var(--ink-100) 37%, var(--paper-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin .7s linear infinite;
}

/* --------------------------------------------------------------------------
   Tooltip
   -------------------------------------------------------------------------- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  background: var(--ink-900);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 60;
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%); }

/* --------------------------------------------------------------------------
   Código
   -------------------------------------------------------------------------- */
.code {
  background: var(--ink-900);
  color: #e8e8e8;
  border-radius: var(--r-md);
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre;
}
.code .tok-key { color: #ffffff; font-weight: 700; }
.code .tok-str { color: #bdbdbd; }
.code .tok-num { color: #d6d6d6; }
.code .tok-com { color: #6b6b6b; }

.method {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  background: var(--paper-3);
  color: var(--ink-700);
}
.method--get { background: transparent; box-shadow: inset 0 0 0 1px var(--ink-200); color: var(--ink-600); }
.method--post { background: var(--ink-900); color: #fff; }
.method--patch { background: var(--ink-200); color: var(--ink-900); }
.method--delete { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-900); color: var(--ink-900); }

/* Línea de llave / conexión */
.keyline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--ink-900);
  color: #e8e8e8;
  font-family: var(--mono);
  font-size: 12px;
}
.keyline input {
  flex: 1;
  background: none;
  border: 0;
  outline: none;
  color: inherit;
  font: inherit;
}
