/* ==========================================
   HERO
========================================== */

.obras-hero {
  background-color: #030f27;
  padding: 2rem 1rem;
  text-align: center;
}

.obras-hero-title {
  font-weight: 900;
  font-size: 3rem;
  color: #fff;
}

.obras-hero-accent {
  width: 60px;
  height: 4px;
  background-color: #d42233;
  margin: 1rem auto 0;
  border-radius: 10px;
}


/* ==========================================
   LAYOUT PRINCIPAL (DESKTOP BASE)
========================================== */

.obras-main {
  background-color: #f4f4f4;
  padding: 2rem 1rem;
}

.obras-container {
  max-width: 1200px;
  margin: 0 auto;

  display: grid;
  grid-template-columns: 280px 1fr; /* 🔥 desktop directo */
  align-items: start;
  gap: 2rem;
}


/* ==========================================
   SIDEBAR
========================================== */

.side {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden; /* 🔥 MUY importante */
}

.obras-sidebar {
  display: flex;
  flex-direction: column; /* 🔥 desktop base */

  gap: 0.8rem;

  max-height: 92vh;       /* 🔥 más usable que 92vh */
  overflow-y: auto;
  overflow-x: hidden;

  padding-right: 5px;
}


/* ITEMS */

.obra-thumb {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;

  background: #ffffff;
  border: 2px solid transparent;
  border-radius: 10px;

  cursor: pointer;
  transition: all 0.2s ease;
}

.obra-thumb:hover {
  border-color: rgba(212, 34, 51, 0.4);
}

.obra-thumb.active {
  border-color: #d42233;
  box-shadow: 0 4px 10px rgba(212, 34, 51, 0.2);
}

.obra-thumb img {
  width: 70px;
  height: 50px;
  object-fit: cover;
  border-radius: 6px;
}

.obra-thumb-info {
  overflow: hidden;
}

.obra-thumb-name {
  font-weight: bold;
  font-size: 0.9rem;
  margin: 0;
}

.obra-thumb-empresa {
  font-size: 0.75rem;
  color: #666;
}


/* ==========================================
   VISOR
========================================== */

.obras-viewer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}


/* IMAGEN PRINCIPAL */

.obras-viewer-main {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background-color: #ddd;
}

.obras-viewer-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
}


/* ==========================================
   MINIATURAS
========================================== */

.obras-viewer-thumbs {
  display: flex;
  gap: 0.5rem;
}

.viewer-thumb {
  width: 90px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
}

.viewer-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.viewer-thumb:hover {
  border-color: rgba(212, 34, 51, 0.4);
}

.viewer-thumb.active {
  border-color: #d42233;
}


/* ==========================================
   INFO PANEL
========================================== */

.obras-info-panel {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid #ddd;
}

.obras-info-title {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.obras-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 🔥 desktop base */
  gap: 1rem;
}

.obras-info-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #888;
}

.obras-info-value {
  font-size: 0.95rem;
  font-weight: 500;
}


/* ==========================================
   ADMIN
========================================== */

.opciones-obra {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.opciones-obra button {
  width: 100%;
}


/* ==========================================
   SCROLL
========================================== */

.obras-sidebar::-webkit-scrollbar {
  width: 6px;
}

.obras-sidebar::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
}


/* ==========================================
   CREACION DE OBRA
========================================== */

.crearObra {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #ab556a;
  padding: 2rem;
}

#crearObra {
  padding: 2rem;
  border-radius: 12px;
  width: 900px;
  box-shadow: 0px 4px 8px rgba(0,0,0,0.2);
}

#crearObra h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: #333;
}

.form-layout {
  display: flex;
  gap: 2rem;
  justify-content: center;
  align-items: flex-start;
}


#preview-img-obra {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid #ccc;
}


/* Campos en dos columnas */
.fields-2col {
  display: flex;
  gap: 2rem;
}

.fields-2col .col {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 200px;
}


/* ==========================================
   MODALES — BASE
========================================== */

/* Ocultos por defecto */
.modal,
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

  justify-content: center;
  align-items: center;

  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);

  z-index: 9999;

  overflow-y: auto;        /* 🔥 IMPORTANTE */
  padding: 20px;           /* 🔥 evita cortes */
}

/* Cuando se abre */
.modal.active,
.modal-overlay.active {
  display: flex;
}


/* ==========================================
   CONTENIDO DEL MODAL
========================================== */

.modal {
  overflow-y: auto;   /* 🔥 clave */
  padding: 20px;      /* evita que toque bordes */
}

.modal-content {
  background: #ab556a;
  padding: 25px;
  border-radius: 12px;

  width: 100%;
  max-width: 600px;

  max-height: 90vh;        /* 🔥 clave */
  overflow-y: auto;        /* 🔥 clave */

  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}


/* ==========================================
   ANIMACIÓN
========================================== */

@keyframes modalFade {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


/* ==========================================
   BOTÓNES ADMIN
========================================== */

.obras-admin {
  max-width: 1200px;
  margin: 2rem auto 0;
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}


/* ==========================================
   BOTÓN CERRAR
========================================== */

.close {
  position: absolute;
  top: 15px;
  right: 20px;

  font-size: 22px;
  color: #fff;
  cursor: pointer;

  transition: 0.2s;
}

.close:hover {
  color: #d42233;
  transform: scale(1.2);
}


/* ==========================================
   TEXTO DEL MODAL
========================================== */

.modal-content h2 {
  margin-bottom: 15px;
  text-align: center;
  color: #fff;
}

.modal-content p {
  background-color: #030f27;
  color: #ffffff;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}

.modal-content p b {
  color: #d42233;
}


/* ==========================================
   FORM EDITAR
========================================== */

.modal-content.editar {
  display: flex;
  flex-direction: column;
}

.modal-content.editar input {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px;

  border-radius: 6px;
  border: 1px solid #ccc;
}

.modal-content.editar label {
  font-weight: bold;
  color: #fff;
}


/* BOTONES */
.modal-content .acciones {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
}


/* ==========================================
   MOBILE
========================================== */
@media (max-width: 1024px) {

  .obras-container {
    grid-template-columns: 1fr;
  }

  .side {
    order: -1; /* 🔥 lo manda arriba de todo */
  }

  .side {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  
  .obras-sidebar {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;           /* 🔥 clave */
    max-width: 100%;       /* 🔥 clave */
    gap: 0.8rem;
    padding-bottom: 10px;

    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .obra-thumb {
    min-width: 220px; /* 🔥 esto hace el efecto slider */
    flex-shrink: 0;

    scroll-snap-align: start;
  }
  
  .obras-admin {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .opciones-obra {
    display: flex;
    flex-direction: row;
    gap: 10px;
  }

  .opciones-obra button {
    width: 100%;
  }
  
  .obras-viewer-main {
    aspect-ratio: 16 / 9;
  }

  .viewer-thumb {
    width: 80px;
    height: 55px;
  }

  .obras-info-grid {
    grid-template-columns: 1fr; /* 🔥 más legible en mobile */
  }

}