/**
 * public/css/documents.css
 * Estilos para insignias, visor modal y tarjeta de documento GOV.CO (WCAG 2.1 AA).
 */

/* 1. Insignias de formato y peso */
.doc-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  vertical-align: middle;
  border-radius: 999px;
  max-width: 100%;
}

.doc-badge--pdf {
  background-color: #fde8e8;
  color: #9b1c1c;
}

.doc-badge--doc {
  background-color: #e1ecfb;
  color: #0b4a9a;
}

.doc-badge--xls {
  background-color: #dcf1df;
  color: #0d5a18;
}

.doc-badge--ppt {
  background-color: #fdecd8;
  color: #8a3b00;
}

.doc-badge--txt,
.doc-badge--zip {
  background-color: #eeeeee;
  color: #3f3f3f;
}

.btn .doc-badge {
  margin-left: 0.35rem;
  vertical-align: baseline;
}

/* 2. Bloqueo de scroll global al abrir visor */
html.doc-viewer-open {
  overflow: hidden;
}

/* 3. Visor Modal de PDF */
.doc-viewer {
  display: none;
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(1100px, 96vw);
  height: 92vh;
  max-height: 92vh;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background-color: #ffffff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  z-index: 1050;
  flex-direction: column;
}

.doc-viewer[open],
.doc-viewer.is-open {
  display: flex;
}

.doc-viewer::backdrop {
  background-color: rgba(0, 0, 0, 0.65);
}

.doc-viewer__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background-color: var(--govco-cobalt, #094385);
  color: #ffffff;
}

.doc-viewer__header-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.doc-viewer__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-viewer__meta {
  font-size: 0.8rem;
  color: #d0e1f9;
}

.doc-viewer__header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.doc-viewer__action-link,
.doc-viewer__close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  text-decoration: none;
  background-color: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  cursor: pointer;
}

.doc-viewer__action-link:hover,
.doc-viewer__close-btn:hover {
  background-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.doc-viewer__action-link:focus-visible,
.doc-viewer__close-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px #FEDF13, 0 0 0 5px #094385;
}

.doc-viewer__close-btn {
  font-size: 1.15rem;
  padding: 0.25rem 0.6rem;
  line-height: 1;
}

.doc-viewer__body {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  background-color: #ffffff;
  overflow: hidden;
}

.doc-viewer__frame {
  width: 100%;
  height: 100%;
  border: 0;
  background-color: #ffffff;
}

.doc-viewer__loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #ffffff;
  color: #4B4B4B;
  font-size: 0.95rem;
  font-weight: 600;
  z-index: 2;
}

.doc-viewer__fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  background-color: #ffffff;
  z-index: 3;
}

.doc-viewer__fallback-text {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #4B4B4B;
}

/* 4. Componente Tarjeta de Documento */
.doc-card {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 1.25rem;
  padding: 1.25rem;
  background-color: #e6f0ff;
  border: 1px solid var(--govco-tropical-blue, #C2D7EF);
  border-radius: 10px;
  align-items: start;
}

.doc-card__file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.doc-card__icon {
  width: 60px;
  height: 70px;
}

.doc-card__file--pdf { color: #9b1c1c; }
.doc-card__file--doc { color: #0b4a9a; }
.doc-card__file--xls { color: #0d5a18; }
.doc-card__file--ppt { color: #8a3b00; }
.doc-card__file--txt,
.doc-card__file--zip { color: #5f5f5f; }

.doc-card__size {
  font-size: 0.75rem;
  font-weight: 700;
  color: #5f5f5f;
  text-align: center;
}

.doc-card__data {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.85rem;
  row-gap: 0.4rem;
  font-size: 0.9rem;
}

.doc-card__label {
  color: #5f5f5f;
  font-weight: 600;
  margin: 0;
}

.doc-card__value {
  color: #4B4B4B;
  margin: 0;
  word-break: break-word;
}

.doc-card__name {
  color: var(--govco-cobalt, #094385);
  font-weight: 700;
  text-decoration: underline;
}

.doc-card__name:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px #FEDF13;
  border-radius: 2px;
}

.doc-card__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.doc-card__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
}

.doc-card__btn--view {
  background-color: var(--govco-cobalt, #094385);
  color: #ffffff;
  border: 1px solid var(--govco-cobalt, #094385);
}

.doc-card__btn--download {
  background-color: transparent;
  color: var(--govco-cobalt, #094385);
  border: 1px solid var(--govco-cobalt, #094385);
}

.doc-card__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px #FEDF13, 0 0 0 5px #094385;
}

/* 5. Adaptabilidad móvil */
@media (max-width: 576px) {
  .doc-viewer {
    width: 100vw;
    height: 100dvh;
    /* El <dialog> trae max-width/max-height por defecto (calc(100% - 6px - 2em)) que impedían la pantalla completa */
    max-width: 100vw;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .doc-viewer__header {
    flex-wrap: wrap;
    padding: 0.6rem 0.85rem;
  }

  .doc-card {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .doc-card__data {
    grid-template-columns: 1fr;
    row-gap: 0.25rem;
    text-align: left;
    width: 100%;
  }

  .doc-card__actions {
    justify-content: center;
    width: 100%;
  }
}

/* 6. Modo Alto Contraste */
body.high-contrast .doc-badge {
  background-color: #000000 !important;
  color: #ffffff !important;
  border: 1px solid #ffffff !important;
}

body.high-contrast .doc-viewer {
  background-color: #000000 !important;
  border: 2px solid #ffffff !important;
}

body.high-contrast .doc-viewer__header {
  background-color: #000000 !important;
  border-bottom: 2px solid #ffffff !important;
  color: #ffffff !important;
}

body.high-contrast .doc-viewer__action-link,
body.high-contrast .doc-viewer__close-btn,
body.high-contrast .doc-card__btn {
  background-color: #ffea00 !important;
  color: #000000 !important;
  border: 2px solid #ffffff !important;
  font-weight: 700 !important;
}

body.high-contrast .doc-card {
  background-color: #000000 !important;
  border: 2px solid #ffffff !important;
}

body.high-contrast .doc-card__label,
body.high-contrast .doc-card__value,
body.high-contrast .doc-card__size {
  color: #ffffff !important;
}

body.high-contrast .doc-card__name {
  color: #ffea00 !important;
}

/* 7. Movimiento Reducido */
@media (prefers-reduced-motion: reduce) {
  .doc-viewer,
  .doc-badge,
  .doc-card,
  .doc-card__btn,
  .doc-viewer__action-link,
  .doc-viewer__close-btn {
    transition: none !important;
    animation: none !important;
  }
}
