@import url("https://fonts.googleapis.com/css2?family=Rubik&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Rubik", sans-serif;
}

html,
body {
  height: 100%;
  min-height: 100vh;
  display: flex; /* struttura verticale */
  flex-direction: column; /* header > main > footer */
  background: none;
}

body {
  position: relative;
  background-image: url("../images/body-bg.webp");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: #e0e0e0;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Velo sfocato sul body */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: inherit;
  background-size: inherit;
  background-position: inherit;
  background-repeat: inherit;
  filter: blur(1 px) brightness(0.9);
  transform: scale(1.02); /* evita bordi tagliati */
}

/* --- HEADER con effetto vetro satinato --- */
header {
  position: relative;
  background-image: url("../images/header-bg.webp");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  min-height: 120px;
  color: white;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  animation: slideDown 0.5s ease-in-out;
  border-bottom: 1px solid rgba(255, 255, 255, 0.25); /* bordo vetro */
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
}

/* Velo con sfocatura per leggibilità */
header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 0;
}

/* NAVBAR */
nav {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 0.5rem 0;
}

nav .logo img {
  height: 50px;
  width: auto;
  margin-right: 1rem;
  transition: transform 0.2s ease;
  cursor: pointer;
}

nav .logo img:hover {
  transform: scale(1.05);
}

nav ul {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  justify-content: center;
  gap: 1.5rem;
}

nav a {
  color: #ffffff;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
  text-decoration: none;
  font-weight: bold;
  transition: color 0.3s, transform 0.2s;
}

nav a:hover {
  color: #90caf9;
  transform: scale(1.1);
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* --- Main con sfondo più opaco e sfocatura leggera --- */
main {
  flex: 1;
  padding: 2rem;
  max-width: 900px;
  margin: 2rem auto;
  width: 100%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px) saturate(160%);
  -webkit-backdrop-filter: blur(4px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
  animation: fadeIn 1s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Titoli e testo --- */
h1,
h2 {
  color: #90caf9;
  margin-bottom: 1rem;
}

p {
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
}

a {
  color: #bb86fc;
  transition: color 0.3s;
}

a:hover {
  color: #ff8a65;
}

/* --- Form --- */
form input,
form textarea {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: none;
  border-radius: 5px;
  background: #1f1f1f;
  color: #e0e0e0;
  font-size: 1rem;
  outline: none;
  transition: box-shadow 0.3s;
}

form input:focus,
form textarea:focus {
  box-shadow: 0 0 5px #90caf9;
}

form button {
  background: #90caf9;
  color: #121212;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.3s, transform 0.2s;
}

form button:hover {
  background: #42a5f5;
  transform: scale(1.05);
}

/* --- Footer --- */
footer {
  background: rgba(31, 31, 31, 0.9);
  color: #e0e0e0;
  text-align: center;
  padding: 1rem;
  margin-top: auto;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.5);
}

/* --- Responsive header --- */
@media (max-width: 1024px) {
  header {
    background-position: center bottom;
    min-height: 120px;
    padding-bottom: 1rem;
  }
}

@media (max-width: 768px) {
  body {
    background-attachment: scroll;
  }

  header {
    background-size: cover;
    background-position: center bottom;
    min-height: 200px; /* più alto per non tagliare */
  }

  nav {
    flex-direction: column;
    gap: 0.8rem;
    padding-bottom: 1rem;
  }

  nav .logo img {
    margin-right: 0;
    margin-bottom: 0.4rem;
  }

  main {
    padding: 1rem;
    backdrop-filter: blur(1px) saturate(160%);
    -webkit-backdrop-filter: blur(1px) saturate(160%);
  }

  iframe {
    height: 250px;
  }
}

.carousel-container {
  position: relative;
  max-width: 800px;
  margin: 20px auto;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  background: #333;
}

.carousel-wrapper {
  display: flex;
  transition: transform 0.5s ease;
  height: 350px;
}

.carousel-slide {
  min-width: 100%;
  position: relative;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: white;
  padding: 20px;
  font-size: 18px;
  font-weight: bold;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.3);
  border: none;
  color: white;
  font-size: 24px;
  padding: 10px 15px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.3s ease;
  backdrop-filter: blur(5px);
}

.carousel-btn:hover {
  background: rgba(255, 255, 255, 0.5);
  transform: translateY(-50%) scale(1.1);
}

.carousel-btn.prev {
  left: 15px;
}

.carousel-btn.next {
  right: 15px;
}

.carousel-dots {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.carousel-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.carousel-dot:hover {
  background: rgba(255, 255, 255, 0.8);
}

.carousel-dot.active {
  background: white;
  transform: scale(1.2);
}

.carousel-counter {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 14px;
  backdrop-filter: blur(5px);
}

@media (max-width: 768px) {
  .carousel-container {
    margin: 15px;
  }

  .carousel-wrapper {
    height: 250px;
  }

  .carousel-title {
    font-size: 16px;
    padding: 15px;
  }

  .carousel-btn {
    padding: 8px 12px;
    font-size: 20px;
  }
}

.contact-container {
  margin-top: 2rem;
  padding: 2rem;
  background-color: #1f1f1f;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.contact-email {
  margin-top: 1.5rem;
  padding: 1rem;
  background-color: #2a2a2a;
  border-radius: 8px;
  border: 2px solid #90caf9;
}

.email-link {
  color: #90caf9;
  text-decoration: none;
  font-size: 1.4rem;
  font-weight: bold;
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  transition: all 0.3s ease;
  word-break: break-all;
}

.email-link:hover {
  background-color: #90caf9;
  color: #1f1f1f;
  transform: scale(1.05);
}

.copy-button {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  background-color: #4caf50;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.copy-button:hover {
  background-color: #45a049;
  transform: scale(1.05);
}

.copy-button:active {
  transform: scale(0.95);
}

.copy-feedback {
  margin-top: 0.5rem;
  color: #4caf50;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.copy-feedback.show {
  opacity: 1;
}

@media (max-width: 768px) {
  .contact-container {
    margin-top: 1rem;
    padding: 1.5rem;
  }

  .email-link {
    font-size: 1.1rem;
    padding: 0.8rem;
    word-break: break-word;
    line-height: 1.4;
  }

  .copy-button {
    padding: 0.7rem 1.2rem;
    font-size: 1.1rem;
    width: 100%;
    max-width: 200px;
  }
}

@media (max-width: 480px) {
  .contact-container {
    padding: 1rem;
    margin: 1rem 0.5rem;
  }

  .email-link {
    font-size: 1rem;
    padding: 0.6rem;
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

.pulse {
  animation: pulse 0.3s ease;
}

/* Combo box in admin */
select {
  background: #1f1f1f;
  color: #e0e0e0;
  border: 2px solid #90caf9;
  border-radius: 6px;
  padding: 10px;
  font-size: 1rem;
  transition: border-color 0.3s, box-shadow 0.3s;
  width: 100%;
}

select:hover {
  border-color: #42a5f5;
}

select:focus {
  outline: none;
  box-shadow: 0 0 6px #90caf9;
}

/* Tabelle libri – versione pulita e coerente */
.table-responsive {
  width: 100%;
  overflow-x: auto; /* fallback su schermi piccoli */
}

#tabellaLibri {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto; /* <— fondamentale per non “allargare” la tabella */
}

#tabellaLibri th,
#tabellaLibri td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  white-space: normal; /* permetti andare a capo */
  word-break: break-word; /* compat vecchia */
  overflow-wrap: anywhere; /* spezza parole lunghissime */
  border-bottom: 1px solid #333;
}

#tabellaLibri thead th {
  background: #1f1f1f;
  color: #90caf9;
  border-bottom: 2px solid #90caf9;
}

#tabellaLibri tbody tr:nth-child(even) {
  background-color: #181818;
}

/* Colonna azioni comoda (solo admin) */
#tabellaLibri td.actions {
  white-space: nowrap;
  text-align: right;
}
#tabellaLibri td.actions .btn {
  background: #2a2a2a;
  color: #e0e0e0;
  border: 1px solid #444;
  padding: 6px 10px;
  border-radius: 6px;
  margin-left: 6px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
#tabellaLibri td.actions .btn:hover {
  background: #3a3a3a;
  transform: translateY(-1px);
}
#tabellaLibri td.actions .btn.delete {
  border-color: #e57373;
  color: #ffcdd2;
}
#tabellaLibri td.actions .btn.save {
  border-color: #90caf9;
  color: #bbdefb;
}

/* Celle editabili (admin) */
#tabellaLibri td[contenteditable="true"] {
  background: #1a1a1a;
  outline: none;
}
#tabellaLibri td[contenteditable="true"]:focus {
  box-shadow: inset 0 0 0 2px #90caf9;
  background: #121212;
}

/* ---------- Tabelle responsive per telefono ---------- */
@media (max-width: 768px) {
  .table-responsive {
    overflow-x: auto;
  }

  #tabellaLibri {
    display: block;
    width: 100%;
    border: none;
  }

  #tabellaLibri thead {
    display: none; /* nasconde l'intestazione classica */
  }

  #tabellaLibri tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  #tabellaLibri tr {
    display: grid;
    grid-template-columns: 1fr; /* una colonna sola */
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px;
  }

  #tabellaLibri td {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border: none;
  }

  #tabellaLibri td::before {
    content: attr(data-label);
    font-weight: bold;
    color: #90caf9;
    flex: 1;
    margin-right: 10px;
  }

  /* Pulsanti azioni: più grandi e centrati */
  #tabellaLibri td.actions {
    justify-content: center;
    gap: 10px;
    margin-top: 8px;
  }

  #tabellaLibri td.actions .btn {
    padding: 8px 14px;
    font-size: 1rem;
  }
}

/* micro-ottimizzazione: telefoni molto piccoli (<480px) */
@media (max-width: 480px) {
  #tabellaLibri tr {
    padding: 10px;
  }

  #tabellaLibri td {
    flex-direction: column;
    align-items: flex-start;
  }

  #tabellaLibri td::before {
    margin-bottom: 3px;
  }

  #tabellaLibri td.actions {
    flex-direction: row;
    justify-content: center;
  }
}

/* --- Google Maps responsive --- */
.map-container {
  position: relative;
  width: 100%;
  max-width: 800px; /* opzionale: limite massimo */
  margin: 1rem auto;
  aspect-ratio: 16 / 9; /* mantiene le proporzioni */
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.map-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Adattamento su schermi piccoli */
@media (max-width: 768px) {
  .map-container {
    aspect-ratio: 4 / 3;
    border-radius: 6px;
  }
}
