/* ===========================
   Tipografía y enlaces
=========================== */
h1 { 
  font-weight: 900; 
  color: #0e7400; 
}

h3 {
  color: #19105f;
}

.h3-link a {
  color: #19105f;
  transition: color .2s, transform .2s, text-decoration .2s;
  text-decoration: underline;
}

.h3-link a:hover { 
  color: #813400; 
  transform: scale(1.08); 
}

/* ===========================
   Modal
=========================== */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: #00000080;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.show { 
  display: flex; 
}

.modal-contenido {
  background: #fff;
  padding: 25px 30px;
  border-radius: 12px;
  max-width: 1200px;
  width: 90%;
  max-height: 100vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,.7);
  position: relative;
}

.modal-title {
  margin: 0 80px 8px 12px;
  font-size: 22px;
  font-weight: 800;
  color: #813400;
  text-align: center;
}

.modal-header-buttons {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap; /* permite que bajen */
  gap: 8px;
  max-width: calc((40px + 8px) * 4); /* ajusta al ancho de 4 botones */
}


.btn-modal {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  background-color: #f5eae3;
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
  transition: background .25s, transform .18s, box-shadow .25s;
}

.btn-modal:hover,
.btn-modal:focus-visible {
  background: #f5e9e0;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0,0,0,.4);
}

.btn-modal:focus-visible {
  outline: 2px solid #742f00; 
  outline-offset: 2px;
}

.btn-modal svg {
  padding-right: 15px;
  padding-bottom: 6px;
  width: 35px; 
  height: 35px; 
  fill: #813400;
  transition: fill .25s;
}

.btn-modal:hover svg,
.btn-modal:focus-visible svg { 
  fill: #813400; 
}

/* ===========================
   Botones principales, categorías, años
=========================== */

.boton-principal,
.boton-anio,
.boton-trimestre,
.boton-categoria,
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 180px; 
  height: 180px;
  margin: 8px;
  font-weight: 600; 
  font-size: 16px;
  cursor: pointer;
  border-radius: 12px;
  border: #813400 3px solid;
  color: #813400;
  transition: background .3s, color .3s, transform .2s, box-shadow .2s, filter .2s;
  box-shadow: 0 4px 8px rgba(0,0,0,.6);
}

.boton-principal i, 
.boton-principal img, 
.boton-principal svg { 
  font-size: 62px; 
  margin-bottom: 8px; 
  color: #813400;
}

.tile {
  display: grid; 
  place-items: center;
  padding: 16px;
  border-radius: 16px;
  box-shadow: 0 8px 18px rgba(0,0,0,.15);
}

.tile-icon-wrap { 
  width: 70px; 
  height: 70px; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
}

.ico-lg, .ico-md {
  filter: invert(9%) sepia(34%) saturate(5379%) hue-rotate(222deg) brightness(91%) contrast(101%); /* COLOR DEL ICONO NO PONER CON CÓDIGO, CAMBIAR A FILTRO*/
  transition: filter .2s;
  max-width: 100%; 
  max-height: 100%;
}

.ico-md { 
  width: 48px; 
  height: 48px; 
}

.tile-text { 
  font-weight: 700; 
  line-height: 1.2; 
  font-size: clamp(16px, 2.2vw, 18px); 
}

.boton-principal:hover,
.boton-categoria:hover,
.boton-anio:hover,
.boton-trimestre:hover {
  background: #f5e9e0;
  color: #813400;
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 24px rgba(0,0,0,.18);
}

/* ===========================
   Layouts
=========================== */
#botones-transparencia,
#contenido-popup-principal,
.grid-wrap,
.lista-archivos,
.visor-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

#botones-transparencia {
  width: 60% !important;
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* siempre 4 por fila */
  gap: 15px;
  margin: 20px auto;
  justify-items: center; /* centra cada botón */
}


.grid-wrap { 
  align-content: flex-start; 
  gap: 24px; 
  padding: 8px 12px; 
}

.lista-archivos { 
  gap: 12px 15px;
  margin-top: 10px; 
}

.visor-actions { 
  align-items: center; 
  margin: 8px 0 10px;
}

/* ===========================
   Archivos
=========================== */
.boton-archivo, .btn-descargar {
  color: #813400;
  border: #813400 3px solid;
  border-radius: 12px;
  font-weight: 600; 
  cursor: pointer;
  transition: background .3s, color .3s, transform .2s, box-shadow .2s;
}

.boton-archivo {
  padding: 14px 20px; 
  min-width: 220px;
  text-align: left; 
  box-shadow: 0 3px 8px rgba(0,0,0,.1);
}

.boton-archivo:hover,
.btn-descargar:hover {
  background: #f5e9e0; 
  color: #813400;
  transform: scale(1.01);
  box-shadow: 0 5px 15px rgba(0,0,0,.18);
}

.btn-descargar {
  display: inline-block; 
  padding: 6px 14px; 
  font-size: 14px;
  border-radius: 6px; 
  text-decoration: none;
}

.btn-descargar:active { 
  background: #813400; 
  transform: scale(.97); 
}

/* ===========================
   Visores
=========================== */

.visor-pdf, .visor-jss {
  width: 100%;
  height: 600px;
  border: none; 
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0,0,0,.15);
}

.visor-jss { 
  overflow: auto; 
  font-size: 14px; 
}

#excel-container {
  max-width: 100%; 
  margin-top: 10px; 
  padding: 10px;
  border: 2px solid #000; 
  border-radius: 6px;
  background: #fff; 
  box-shadow: 0 0 12px rgba(0,0,0,.6);
}

#excel-container select {
  margin-bottom: 10px; 
  padding: 5px 10px;
  font-size: 14px; 
  border: 1px solid #aaa; 
  border-radius: 4px;
  background: #f8f8f8; 
  cursor: pointer;
}

.excel-table {
  border-collapse: collapse; 
  width: 100%;
  font-family: Arial, sans-serif; 
  font-size: 13px; 
  color: #333;
}

.excel-table th, .excel-table td {
  border: 1px solid #ccc; 
  padding: 6px; 
  min-width: 150px;
  text-align: center; 
  background: #fff; 
  vertical-align: top;
}

.excel-table th { 
  background: #f4f4f4; 
  font-weight: bold; 
  position: sticky; 
  top: 0; 
  z-index: 2; 
}

.excel-table tbody tr:nth-child(even) td { 
  background: #f9f9f9; 
}

.excel-table td div { 
  max-height: 3.6em; 
  overflow-y: auto; 
  line-height: 1.2em;
}

/* Scroll personalizado */
.excel-wrapper::-webkit-scrollbar { 
  height: 8px; 
  width: 8px; 
}

.excel-wrapper::-webkit-scrollbar-track { 
  background: #f1f1f1; 
}

.excel-wrapper::-webkit-scrollbar-thumb { 
  background: #bbb; 
  border-radius: 4px; 
}

.excel-wrapper::-webkit-scrollbar-thumb:hover { 
  background: #999; 
}

/* ===========================
   Responsive
=========================== */
@media (max-width: 900px) {
  #botones-transparencia { 
    grid-template-columns: repeat(2, minmax(200px, 1fr)); 
  }
}
@media (max-width: 700px) {
  .tile, .boton-anio.tile {
     width: 44vw; 
     height: 44vw; 
    }
}
@media (max-width: 600px) {
  #botones-transparencia { 
    grid-template-columns: 1fr; 
  }

  .boton-principal { 
    width: 100%; 
    padding: 15px; 
    font-size: 16px; 
  }

}

@media (max-width: 420px) {
  .tile, .boton-anio.tile { width: 86vw; height: 86vw; }
}

/* ===========================
   Responsive completo
=========================== */

/* Laptops y pantallas medianas */
@media (max-width: 1200px) {
  .modal-contenido {
    max-width: 95%;
    padding: 20px;
  }
  .boton-principal,
  .boton-categoria,
  .boton-anio,
  .boton-trimestre {
    width: 160px;
    height: 160px;
    font-size: 15px;
  }
}

/* Tablets horizontales */
@media (max-width: 900px) {
  #botones-transparencia {
    grid-template-columns: repeat(2, minmax(200px, 1fr));
    width: 50% !important;
  }
  .modal-title {
    font-size: 20px;
  }
  .visor-pdf,
  .visor-jss {
    height: 500px;
  }
}

/* Tablets verticales / móviles grandes */
@media (max-width: 700px) {
  .tile,
  .boton-anio.tile {
    width: 44vw;
    height: 44vw;
  }
  .boton-principal,
  .boton-categoria,
  .boton-anio,
  .boton-trimestre {
    width: 44vw;
    height: 44vw;
    font-size: 14px;
  }
  .modal-contenido {
    padding: 18px;
  }
  .modal-title {
    font-size: 18px;
  }
  .visor-pdf,
  .visor-jss {
    height: 450px;
  }
}

/* Smartphones medianos */
@media (max-width: 600px) {
  #botones-transparencia {
    grid-template-columns: 1fr;
    width: 50% !important;
  }
  .boton-principal,
  .boton-categoria,
  .boton-anio,
  .boton-trimestre {
    width: 100%;
    padding: 15px;
    font-size: 16px;
  }

  .visor-pdf,
  .visor-jss {
    height: 400px;
  }
  .modal-contenido {
    width: 95%;
    max-height: 90vh;
  }
}

/* Smartphones pequeños */
@media (max-width: 420px) {
  .tile,
  .boton-anio.tile {
    width: 86vw;
    height: 86vw;
  }
  .modal-title {
    font-size: 16px;
    margin: 0 40px 6px;
  }
  .btn-modal {
    width: 36px;
    height: 36px;
  }
  .btn-modal svg {
    width: 28px;
    height: 28px;
  }
}

/* 2) SOLO lista de ARCHIVOS (en popup o donde uses .lista-archivos + .boton-archivo) */
.lista-archivos{
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;  /* SIEMPRE 3 por fila */
  gap: 16px !important;                 /* separación entre botones */
  padding: 0 8px;                       /* “un poco de margen” a los lados */
  align-items: stretch !important;       /* alturas iguales por fila */
  justify-items: stretch !important;
  width: 100% !important;
}
.lista-archivos > *{ margin: 0 !important; }

/* El botón de archivo llena su celda y recorta títulos largos con "..." */
.boton-archivo{
  width: 100% !important;
  height: 100% !important;
  min-height: 56px;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;

  /* truncado */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  padding: 0 10px;
  box-sizing: border-box;
}

/* Responsivo SOLO para archivos */
@media (max-width: 900px){
  .lista-archivos{ grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
}
@media (max-width: 560px){
  .lista-archivos{ grid-template-columns: 1fr !important; };

}

/* FIX: Archivos -> truncado inicia a la izquierda, no centrado */
#popup-principal .lista-archivos .boton-archivo{
  justify-content: flex-start !important; /* alinea el contenido al inicio */
  text-align: left !important;            /* texto alineado a la izquierda */
  /* mantiene el recorte con "…" que ya tienes */
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  padding-left: 12px;                     /* pequeño margen interno */
}

/* Por si algún botón tiene más de un hijo (icono + texto), evita que bloqueen el “…” */
#popup-principal .lista-archivos .boton-archivo > *{
  min-width: 0; /* permite que el contenido flex pueda contraerse */
}