/* =========================================================
   WIRTZ HUB · RECURSOS · DOCUMENTOS
   Biblioteca documental · versiones · vencimientos · auditoría
   ========================================================= */

.docs-page {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 7px;
  min-height: calc(100vh - var(--topbar-height) - 44px);
  animation: fadeUp 0.2s ease both;
}

/* =========================================================
   HEADER COMPACTO
   ========================================================= */

.docs-head {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 56px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.docs-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.docs-brand__icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--text-strong);
}

.docs-brand__icon .icon {
  width: 15px;
  height: 15px;
}

.docs-brand h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.055em;
}

.docs-brand p {
  margin: 2px 0 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 760;
  line-height: 1.25;
}

.docs-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
}

/* =========================================================
   BOTONES
   ========================================================= */

.docs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 26px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    transform var(--transition),
    opacity var(--transition);
}

.docs-btn .icon {
  width: 11px;
  height: 11px;
  stroke-width: 2;
}

.docs-btn:active {
  transform: scale(0.98);
}

.docs-btn--light {
  border: 1px solid var(--line);
  background: var(--panel-solid);
  color: var(--text-strong);
}

.docs-btn--light:hover {
  border-color: var(--line-strong);
  background: var(--panel-hover);
}

.docs-btn--dark {
  border: 1px solid var(--text-strong);
  background: var(--text-strong);
  color: var(--white);
}

.docs-btn--dark:hover {
  opacity: 0.88;
}

html[data-theme="dark"] .docs-btn--dark {
  color: #090b10;
}

/* =========================================================
   MÉTRICAS COMPACTAS
   ========================================================= */

.docs-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-solid);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.docs-metric {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 45px;
  padding: 7px 8px;
  border-right: 1px solid var(--line);
}

.docs-metric:last-child {
  border-right: 0;
}

.docs-metric span {
  color: var(--muted);
  font-size: 7.2px;
  font-weight: 950;
  letter-spacing: 0.085em;
  line-height: 1;
  text-transform: uppercase;
}

.docs-metric strong {
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.06em;
}

.docs-metric small {
  color: var(--muted-2);
  font-size: 7px;
  font-weight: 820;
  line-height: 1;
}

/* =========================================================
   PANEL PRINCIPAL
   ========================================================= */

.docs-panel,
.docs-flow {
  display: grid;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.docs-toolbar {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px;
  border-bottom: 1px solid var(--line);
}

.docs-title {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.docs-title span {
  color: var(--muted);
  font-size: 7.4px;
  font-weight: 950;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}

.docs-title strong {
  color: var(--text-strong);
  font-size: 11.5px;
  font-weight: 950;
  line-height: 1.1;
  letter-spacing: -0.045em;
}

/* =========================================================
   FILTROS
   ========================================================= */

.docs-filters {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
  flex-wrap: wrap;
}

.docs-search {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(390px, 100%);
  min-width: 240px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--muted);
  transition:
    background var(--transition),
    border-color var(--transition);
}

.docs-search:focus-within {
  border-color: var(--line-strong);
  background: var(--panel-hover);
}

.docs-search .icon {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}

.docs-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text-strong);
  outline: none;
  font-size: 9px;
  font-weight: 780;
}

.docs-search input::placeholder {
  color: var(--muted-2);
}

.docs-filters select {
  height: 28px;
  min-width: 104px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--text-strong);
  outline: none;
  font-size: 8.5px;
  font-weight: 850;
}

/* =========================================================
   TABLA
   ========================================================= */

.docs-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
}

.docs-table {
  width: 100%;
  min-width: 1220px;
  border-collapse: collapse;
  background: var(--panel-solid);
}

.docs-table th,
.docs-table td {
  height: 31px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 8.6px;
  font-weight: 720;
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

.docs-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-solid);
  color: var(--muted);
  font-size: 7px;
  font-weight: 950;
  letter-spacing: 0.085em;
  text-transform: uppercase;
}

.docs-table tbody tr {
  transition:
    background var(--transition),
    color var(--transition);
}

.docs-table tbody tr:hover {
  background: var(--panel-hover);
}

.docs-table strong {
  color: var(--text-strong);
  font-weight: 950;
}

.docs-code,
.docs-version,
.docs-type,
.docs-status,
.docs-expire {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 18px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text-strong);
  font-size: 7.5px;
  font-weight: 950;
}

.docs-code {
  padding: 2px 6px;
}

.docs-name {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 240px;
  overflow: hidden;
  color: var(--text-strong);
  font-weight: 950;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.docs-name .icon {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  color: var(--muted);
}

.docs-status::before,
.docs-expire::before,
.docs-type::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--muted);
}

.docs-status.is-current::before {
  background: var(--success);
}

.docs-status.is-draft::before,
.docs-status.is-review::before,
.docs-status.is-prepared::before {
  background: var(--warning);
}

.docs-status.is-critical::before,
.docs-expire.is-soon::before {
  background: var(--danger);
}

.docs-expire.is-ok::before {
  background: var(--success);
}

.docs-date,
.docs-location {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-strong);
  font-weight: 870;
}

.docs-date .icon,
.docs-location .icon {
  width: 11px;
  height: 11px;
  color: var(--muted);
}

/* =========================================================
   FLUJO ABAJO
   ========================================================= */

.docs-flow {
  align-content: start;
}

.docs-flow__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
}

.docs-flow__head span {
  color: var(--muted);
  font-size: 7.4px;
  font-weight: 950;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}

.docs-flow__head strong {
  display: block;
  margin-top: 2px;
  color: var(--text-strong);
  font-size: 11.5px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.04em;
}

.docs-flow__head .icon {
  width: 14px;
  height: 14px;
  color: var(--text-strong);
}

.docs-timeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.docs-event {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 7px;
  min-height: 62px;
  padding: 8px;
  border-right: 1px solid var(--line);
}

.docs-event:last-child {
  border-right: 0;
}

.docs-event__icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text-strong);
}

.docs-event__icon .icon {
  width: 12px;
  height: 12px;
}

.docs-event__body {
  display: grid;
  align-content: start;
  gap: 3px;
  min-width: 0;
}

.docs-event__body strong {
  color: var(--text-strong);
  font-size: 9px;
  font-weight: 950;
  line-height: 1.1;
}

.docs-event__body p {
  margin: 0;
  color: var(--muted);
  font-size: 7.8px;
  font-weight: 760;
  line-height: 1.3;
}

.docs-event__body small {
  color: var(--muted-2);
  font-size: 7px;
  font-weight: 850;
  line-height: 1;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1380px) {
  .docs-head {
    grid-template-columns: 1fr;
  }

  .docs-actions {
    justify-content: flex-start;
  }

  .docs-toolbar {
    grid-template-columns: 1fr;
  }

  .docs-filters {
    justify-content: flex-start;
  }

  .docs-timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .docs-event:nth-child(2n) {
    border-right: 0;
  }

  .docs-event:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 1100px) {
  .docs-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .docs-metric:nth-child(3n) {
    border-right: 0;
  }

  .docs-metric:nth-child(n + 4) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  .docs-page {
    gap: 6px;
  }

  .docs-actions,
  .docs-filters {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .docs-search {
    width: 100%;
    min-width: 0;
  }

  .docs-btn,
  .docs-filters select {
    width: 100%;
  }

  .docs-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .docs-metric {
    border-right: 1px solid var(--line);
    border-top: 1px solid var(--line);
  }

  .docs-metric:nth-child(1),
  .docs-metric:nth-child(2) {
    border-top: 0;
  }

  .docs-metric:nth-child(2n) {
    border-right: 0;
  }

  .docs-timeline {
    grid-template-columns: 1fr;
  }

  .docs-event {
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .docs-event:first-child {
    border-top: 0;
  }

  .docs-brand {
    align-items: flex-start;
  }
}