/* ═══════════════════════════════════════════════════════════
   grid.css
   Estilos del W Grid.
   Solo consume primitivas. No sabe nada del Mundo V.
   ═══════════════════════════════════════════════════════════ */

/* ── Raíz ───────────────────────────────────────────────── */
.grid {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
}

/* ── Search ─────────────────────────────────────────────── */
.grid-search__wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-soft);
  gap: var(--space-xs);
}

.grid-search__input {
  width: 200px;
  height: var(--control-height-sm);
  padding: 0 var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  outline: none;
  background: var(--color-bg);
  color: var(--color-text-soft);
}

.grid-search__input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,.12);
}

.grid-search__clear {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 16px;
  line-height: 1;
  border-radius: var(--radius-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-search__clear:hover { background: var(--color-hover-soft); }

/* ── Header ─────────────────────────────────────────────── */
.grid-header__wrap {
  overflow: hidden;
  flex-shrink: 0;
  border-bottom: 2px solid var(--color-border);
}

.grid-header {
  display: flex;
  background: var(--color-bg);
  user-select: none;
}

.grid-header__cell {
  display: flex;
  align-items: center;
  height: 30px;
  padding: 0 var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
  border-right: 1px solid var(--color-border);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.grid-header__cell--sortable { cursor: pointer; }
.grid-header__cell--sortable:hover { background: var(--color-hover-soft); }
.grid-header__cell--dragging  { opacity: .5; }
.grid-header__cell--drop-target { background: rgba(37,99,235,.08); }

.grid-header__label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-header__sort {
  margin-left: var(--space-xs);
  color: var(--color-accent);
  font-size: 11px;
}

.grid-header__resizer {
  position: absolute;
  right: 0;
  top: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  background: transparent;
}

.grid-header__resizer:hover { background: var(--color-accent); }

/* ── Body ───────────────────────────────────────────────── */
.grid-body {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  outline: none;
}

.grid-body::-webkit-scrollbar       { width: 6px; height: 6px; }
.grid-body::-webkit-scrollbar-track { background: var(--color-bg); }
.grid-body::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-base);
  border: 1px solid var(--color-bg);
}
.grid-body::-webkit-scrollbar-thumb:hover { background: var(--color-accent); }

.grid-body__row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid transparent;
  cursor: default; user-select: none;
}

.grid--row-borders .grid-body__row { border-bottom-color: var(--color-border); }
.grid--stripes .grid-body__row--odd { background: var(--color-bg); }

.grid-body__row:hover       { background: var(--color-hover-soft); }
.grid-body__row--active     { background: rgba(37,99,235,.35) !important; border-left: 3px solid var(--color-accent); }

.grid-body__cell {
  display: flex;
  align-items: center;
  padding: 0 var(--space-sm);
  height: 30px;
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--color-text-soft);
  font-size: var(--font-size-base);
}

.grid--col-borders .grid-body__cell { border-right: 1px solid var(--color-border); }
.grid-body__cell--active { background: rgba(37,99,235,.35) !important; }

/* ── Highlight búsqueda ─────────────────────────────────── */
.grid-highlight {
  background: rgba(234,179,8,.35);
  border-radius: 2px;
}

/* ── Footer ─────────────────────────────────────────────── */
.grid-footer {
  flex-shrink: 0;
  height: 26px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-sm);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

.grid-footer__status {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}
