* {
  box-sizing: border-box;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  max-width: 1100px;
  margin: auto;
  padding: 15px;
  background: #f5f5f5;
  color: #222;
}

h1 {
  text-align: center;
}

h2 {
  text-align: center;
}

.panel {
  background: white;
  padding: 18px;
  margin-bottom: 20px;
  border-radius: 15px;
  box-shadow: 0 2px 8px #0002;
}

input[type="file"] {
  width: 100%;
  padding: 12px 0;
}

.subir {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 15px;
  background: #111;
  color: white;
  font-size: 18px;
  cursor: pointer;
}

.mensaje {
  padding: 10px;
  margin-top: 8px;
  background: #eee;
  border-radius: 8px;
}

/* ============ FILTROS ============ */

.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 15px;
}

.filtro {
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  background: #ddd;
  color: #222;
  font-size: 16px;
  cursor: pointer;
}

.filtro.activo {
  background: #111;
  color: white;
}

.orden {
  text-align: center;
  margin-top: 15px;
}

select {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #bbb;
  font-size: 16px;
}

/* ============ GALERÍA ============ */

.galeria {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

/* ============ GRUPO DE DÍA ============ */

.dia-grupo {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0 0 12px 0;
  padding: 0;
  box-sizing: border-box;
}

/* ============ CABECERA DEL DÍA ============ */

.dia-separador {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  max-width: 100%;
  min-height: 50px;
  margin: 0;
  padding: 8px 8px 8px 14px;
  box-sizing: border-box;
  background: #252525;
  color: white;
  border-radius: 10px;
  cursor: pointer;
}
/* La fecha queda SIEMPRE exactamente en el
     centro del encabezado. */

.dia-titulo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  max-width: 55%;
  margin: 0;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  pointer-events: none;
}

/* Los controles empiezan por la derecha:
    [archivos] [checkbox] [flecha] */

.dia-controles {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.dia-contador {
  display: block;
  min-width: 0;
  color: #aaa;
  font-size: 13px;
  white-space: nowrap;
  margin: 0;
}

/* ============ CHECKBOX DEL DÍA ============ */

.selector-dia {
  display: flex;

  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  cursor: pointer;
}

.selector-dia input {
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  cursor: pointer;
}

/* ============ FLECHA DEL ACORDEÓN ============ */

.boton-acordeon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: white;
  font-size: 18px;
  cursor: pointer;
}

/* Cuando el día está cerrado, la flecha gira. */

.dia-grupo.cerrado .boton-acordeon {
  transform: rotate(-90deg);
}

/* ============ CONTENIDO DEL DÍA ============ */

.dia-contenido {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 12px 0;
}

.dia-grupo.cerrado .dia-contenido {
  display: none;
}

/* ============ ELEMENTOS DE LA GALERÍA ============ */

.elemento {
  position: relative;
  width: 100%;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px #0002;
}

.elemento img,
.elemento video {
  display: block;
  width: 100%;
  height: 170px;
  object-fit: cover;
  background: #111;
}

.elemento video {
  cursor: pointer;
}

/* ============ INFORMACIÓN ============ */

.info {
  padding: 8px;
  font-size: 13px;
  text-align: center;
}

.fecha {
  color: #666;
  margin-top: 4px;
}

.calidad {
  color: #555;
  margin-top: 4px;
  font-size: 12px;
}

/* ============ ACCIONES ============ */

.acciones {
  display: flex;
  border-top: 1px solid #eee;
}

.acciones a,
.acciones button {
  flex: 1;
  padding: 9px;
  text-align: center;
  text-decoration: none;
  background: white;
  color: #111;
  border: 0;
  cursor: pointer;
  font-size: 14px;
}

.acciones button {
  border-left: 1px solid #eee;
}

.vacio {
  text-align: center;
  padding: 35px;
  color: #666;
}

/* ============ SELECCIÓN INDIVIDUAL ============ */

.selector-media {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 2px solid white;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.selector-media.seleccionado {
  background: #1976d2;
  border-color: #64b5f6;
}

.elemento.seleccionada {
  outline: 3px solid #1976d2;
  outline-offset: -3px;
}

/* ============ BARRA DE SELECCIÓN ============ */

.barra-seleccion {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 10px;
  margin-bottom: 15px;
  background: rgba(20, 20, 20, 0.96);
  color: white;
  border-radius: 10px;
}

.contador-seleccion {
  text-align: center;
  font-weight: bold;
  margin-bottom: 10px;
}

.seleccion-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.seleccion-grid button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 8px;
  background: #444;
  color: white;
  font-size: 14px;
  cursor: pointer;
}

.seleccion-grid button:last-child {
  grid-column: 1 / -1;
}

.seleccion-grid button:hover {
  background: #555;
}

.seleccion-grid button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============ COMPATIBILIDAD CON SELECCIÓN ANTERIOR ============ */

.seleccion-info {
  white-space: nowrap;
  font-weight: bold;
}

.seleccion-acciones {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.seleccion-acciones button {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: #444;
  color: white;
  cursor: pointer;
  font-size: 14px;
}

.seleccion-acciones button:hover {
  background: #555;
}

.seleccion-acciones button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.barra-seleccion button {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: #444;
  color: white;
  cursor: pointer;
}

/* ============ MODAL ============ */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  padding: 20px;
}

.modal-contenido {
  background: white;
  max-width: 600px;
  margin: 5vh auto;
  padding: 20px;
  border-radius: 15px;
  max-height: 90vh;
  overflow-y: auto;
}

.cerrar {
  float: right;
  font-size: 28px;
  cursor: pointer;
}

.propiedad {
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.propiedad strong {
  display: block;
  color: #666;
  font-size: 13px;
  margin-bottom: 3px;
}

.propiedad span {
  word-break: break-word;
}

.seccion-exif {
  margin-top: 20px;
  margin-bottom: 5px;
  font-size: 18px;
  font-weight: bold;
}

/* ============ MÓVIL ============ */

@media (max-width: 700px) {
  .seleccion-info {
    text-align: center;
  }

  .seleccion-acciones {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .seleccion-acciones button {
    width: 100%;
    min-height: 42px;
  }
}

@media (max-width: 600px) {
  .barra-seleccion {
    font-size: 14px;
  }

  .barra-seleccion button {
    font-size: 13px;
  }

  .dia-titulo {
    max-width: 45%;
    font-size: 14px;
  }

  .dia-contador {
    font-size: 12px;
  }

  .dia-controles {
    gap: 3px;
  }

  .dia-contenido {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
  }
}

/* ============ VISOR DE MEDIA ============ */

.visor-media {

    position: fixed;

    inset: 0;

    z-index: 2000;

    display: none;

    align-items: center;

    justify-content: center;

    background: rgba(0, 0, 0, 0.94);

    touch-action: none;

}


.visor-media.abierto {

    display: flex;

}


.visor-contenido {

    width: 100%;

    height: 100%;

    display: flex;

    align-items: center;

    justify-content: center;

    overflow: hidden;

}


.visor-contenido img,
.visor-contenido video {

    display: block;

    max-width: 96vw;

    max-height: 94vh;

    width: auto;

    height: auto;

    object-fit: contain;

}


.visor-contenido video {

    background: #000;

}


.visor-cerrar {

    position: absolute;

    top: 15px;

    right: 15px;

    z-index: 2010;

    width: 42px;

    height: 42px;

    border: 0;

    border-radius: 50%;

    background: rgba(0, 0, 0, 0.55);

    color: white;

    font-size: 24px;

    line-height: 42px;

    padding: 0;

    cursor: pointer;

}


.visor-cerrar:hover {

    background: rgba(255, 255, 255, 0.18);

}


@media (max-width: 700px) {

    .visor-cerrar {

        top: 10px;

        right: 10px;

    }


    .visor-contenido img,
    .visor-contenido video {

        max-width: 100vw;

        max-height: 100vh;

    }

}

/* ============ VISTA PREVIA AL MANTENER PULSADO ============ */

.preview-media {

    position: fixed;

    inset: 0;

    z-index: 3000;

    display: none;

    align-items: center;

    justify-content: center;

    background: rgba(0, 0, 0, 0.94);

    padding: 10px;

    box-sizing: border-box;

    /* La preview no debe convertirse en una interacción
       independiente del gesto que la ha creado. */
    pointer-events: none;

    user-select: none;

    -webkit-user-select: none;
}


.preview-media.abierto {

    display: flex;
}


.preview-media img,
.preview-media video {

    display: block;

    max-width: 96vw;

    max-height: 94vh;

    width: auto;

    height: auto;

    object-fit: contain;

    border-radius: 2px;

    user-select: none;

    -webkit-user-select: none;
}


.preview-media video {

    background: #000;
}


@media (max-width: 700px) {

    .preview-media {

        padding: 0;
    }


    .preview-media img,
    .preview-media video {

        max-width: 100vw;

        max-height: 100vh;
    }
}

/* ============ TRANSICIÓN DEL VISOR ============ */

.visor-contenido {
    transition:
        opacity 180ms ease;
}