@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Caveat:wght@400;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --verde: #5a8a4a;
  --verde-chiaro: #7ab560;
  --verde-pale: #e8f4e0;
  --arancio: #e07b39;
  --arancio-pale: #fdebd0;
  --marrone: #8b5e3c;
  --crema: #fdf6ec;
  --testo: #3d2b1f;
  --testo-light: #7a6558;
  --shadow: 0 4px 16px rgba(90,138,74,0.13);
  --radius: 18px;
  --radius-sm: 10px;
}

html { font-size: 16px; }
body {
  font-family: 'Nunito', sans-serif;
  background: var(--crema);
  color: var(--testo);
  min-height: 100vh;
  line-height: 1.6;
}

/* ---- HEADER NAV ---- */
.top-nav {
  background: var(--verde);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.top-nav .brand {
  font-weight: 800;
  font-size: 1.05rem;
  text-decoration: none;
  color: #fff;
}
.top-nav .nav-actions { display: flex; gap: 0.5rem; align-items: center; }
.btn-nav {
  background: rgba(255,255,255,0.18);
  border: none;
  color: #fff;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}
.btn-nav:hover { background: rgba(255,255,255,0.3); }
.btn-nav.accent { background: var(--arancio); }
.btn-nav.accent:hover { background: #c96a28; }

/* ---- HERO (index) ---- */
.hero {
  min-height: 100vh;
  background: linear-gradient(160deg, var(--verde) 0%, var(--verde-chiaro) 60%, var(--arancio) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.5rem;
  color: #fff;
}
.hero-logo { font-size: 3.5rem; margin-bottom: 0.5rem; }
.hero h1 {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.hero p {
  font-size: 1.05rem;
  opacity: 0.92;
  margin-bottom: 2.5rem;
  max-width: 320px;
}
.btn-hero {
  background: #fff;
  color: var(--verde);
  font-family: 'Nunito', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 0.85rem 2.2rem;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-hero:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,0.25); }

/* ---- PAGE TITLE ---- */
.page-header {
  background: linear-gradient(135deg, var(--verde) 0%, var(--verde-chiaro) 100%);
  color: #fff;
  padding: 1.5rem 1rem 1.2rem;
  text-align: center;
}
.page-header h1 { font-size: 1.5rem; font-weight: 800; }
.page-header p { opacity: 0.88; font-size: 0.9rem; margin-top: 0.25rem; }

/* ---- GRID COMUNITA ---- */
.grid-comunita {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1.2rem;
}
.card-comunita {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: var(--testo);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.card-comunita:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(90,138,74,0.2); }
.card-comunita .thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--verde-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}
.card-comunita .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-comunita .info { padding: 0.75rem; }
.card-comunita .info h3 { font-size: 0.95rem; font-weight: 800; color: var(--verde); }
.card-comunita .info p { font-size: 0.78rem; color: var(--testo-light); margin-top: 0.2rem; line-height: 1.4; }

/* ---- LISTA MINORI ---- */
.list-minori { padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.card-minore {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: var(--testo);
  transition: transform 0.15s;
}
.card-minore:hover { transform: translateX(4px); }
.card-minore .avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--verde-pale);
  flex-shrink: 0;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(90,138,74,0.2);
}
.card-minore .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.card-minore .nome { font-weight: 700; font-size: 1rem; }
.card-minore .comunita-tag {
  font-size: 0.78rem;
  color: var(--testo-light);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* ---- PROFILO ---- */
.profilo-hero {
  background: linear-gradient(135deg, var(--verde) 0%, var(--verde-chiaro) 100%);
  padding: 2rem 1rem 3.5rem;
  text-align: center;
  color: #fff;
  position: relative;
}
.profilo-avatar-wrap {
  width: 110px; height: 110px;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  margin: 0 auto 0.75rem;
  overflow: hidden;
  background: var(--verde-pale);
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
  cursor: pointer;
  position: relative;
}
.profilo-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }
.profilo-avatar-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s;
  border-radius: 50%;
  font-size: 1.5rem; color: #fff;
}
.profilo-avatar-wrap:hover .profilo-avatar-overlay { opacity: 1; }
.profilo-nome { font-size: 1.5rem; font-weight: 800; }
.profilo-comunita { opacity: 0.88; font-size: 0.9rem; margin-top: 0.2rem; }

.profilo-content {
  margin-top: -2rem;
  padding: 0 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.section-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.section-card .section-title {
  font-weight: 800;
  font-size: 1rem;
  padding: 0.9rem 1rem 0.5rem;
  color: var(--verde);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-card .section-body { padding: 0 1rem 1rem; }

/* Audio player */
.audio-player {
  background: var(--verde-pale);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.audio-player audio { width: 100%; }

/* Mi Presento */
.mi-presento-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--testo);
  white-space: pre-wrap;
}
.mi-presento-empty { color: var(--testo-light); font-style: italic; font-size: 0.9rem; }

/* Diario */
.diario-list { display: flex; flex-direction: column; gap: 0.75rem; }
.card-diario {
  border-left: 4px solid var(--arancio);
  background: var(--arancio-pale);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.75rem;
  font-family: 'Caveat', cursive;
  font-size: 1.05rem;
  position: relative;
}
.card-diario .diario-data {
  font-size: 0.75rem;
  color: var(--testo-light);
  font-family: 'Nunito', sans-serif;
  margin-bottom: 0.3rem;
}
.card-diario .diario-img {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
  max-height: 200px;
  object-fit: cover;
}
.card-diario .btn-delete {
  position: absolute; top: 0.5rem; right: 0.5rem;
  background: none; border: none; cursor: pointer;
  color: var(--testo-light); font-size: 1rem; padding: 0.2rem;
  opacity: 0.6; transition: opacity 0.2s;
}
.card-diario .btn-delete:hover { opacity: 1; color: #c0392b; }

/* Messaggi in bottiglia */
.bottiglia-list { display: flex; flex-direction: column; gap: 0.75rem; }
.card-bottiglia {
  background: #fff7e6;
  border: 1px solid #f0d9a0;
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  position: relative;
}
.card-bottiglia .bottiglia-header {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; color: var(--testo-light);
  margin-bottom: 0.4rem;
}
.card-bottiglia .bottiglia-testo { font-size: 0.95rem; }
.card-bottiglia .btn-delete {
  position: absolute; top: 0.5rem; right: 0.5rem;
  background: none; border: none; cursor: pointer;
  color: var(--testo-light); font-size: 1rem; padding: 0.2rem;
  opacity: 0.6; transition: opacity 0.2s;
}
.card-bottiglia .btn-delete:hover { opacity: 1; color: #c0392b; }

/* ---- BUTTONS ---- */
.btn-primary {
  background: var(--verde);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 0.65rem 1.4rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn-primary:hover { background: var(--verde-chiaro); transform: translateY(-1px); }
.btn-secondary {
  background: transparent;
  color: var(--verde);
  border: 2px solid var(--verde);
  border-radius: 50px;
  padding: 0.55rem 1.2rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-secondary:hover { background: var(--verde-pale); }
.btn-arancio {
  background: var(--arancio);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 0.65rem 1.4rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-arancio:hover { background: #c96a28; }

/* ---- MODAL / OVERLAY ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 1000;
  padding: 0;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5rem 1rem 2rem;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-box h3 { font-size: 1.1rem; font-weight: 800; margin-bottom: 1rem; color: var(--verde); }
.modal-box textarea {
  width: 100%;
  border: 1.5px solid #d0c9c0;
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-family: 'Caveat', cursive;
  font-size: 1.05rem;
  resize: vertical;
  min-height: 120px;
  outline: none;
  transition: border-color 0.2s;
}
.modal-box textarea:focus { border-color: var(--verde); }
.modal-box textarea.nunito { font-family: 'Nunito', sans-serif; font-size: 0.95rem; }
.modal-actions { display: flex; gap: 0.75rem; margin-top: 1rem; justify-content: flex-end; }

/* ---- LOGIN ---- */
.login-wrap {
  min-height: 100vh;
  background: linear-gradient(160deg, var(--verde) 0%, var(--verde-chiaro) 60%, var(--arancio) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.login-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  width: 100%; max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.login-box .logo { text-align: center; font-size: 2.5rem; margin-bottom: 0.5rem; }
.login-box h1 { text-align: center; font-size: 1.3rem; font-weight: 800; color: var(--verde); margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { font-size: 0.85rem; font-weight: 700; color: var(--testo-light); display: block; margin-bottom: 0.3rem; }
.form-group input {
  width: 100%;
  border: 1.5px solid #d0c9c0;
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--verde); }
.login-error { color: #c0392b; font-size: 0.85rem; margin-bottom: 0.75rem; text-align: center; }

/* ---- UTILITIES ---- */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.hidden { display: none !important; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--verde-pale);
  border-top-color: var(--verde);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-msg { color: var(--testo-light); text-align: center; padding: 1.5rem; font-size: 0.9rem; }

/* ---- FAB (diario input) ---- */
.fab-wrap { padding: 0.5rem 1rem 0; }
.fab-input {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--verde-pale);
  border-radius: 50px;
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: background 0.2s;
}
.fab-input:hover { background: #d4eac8; }
.fab-input span { color: var(--testo-light); font-size: 0.9rem; }
