/* ═══════════════════════════════════════════
   CatMap – Profilo (stili specifici)
   ═══════════════════════════════════════════ */

.profile-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(var(--nav-h) + 16px); scrollbar-width: thin; scrollbar-color: var(--sand) transparent; }
.profile-scroll::-webkit-scrollbar { width: 4px; }
.profile-scroll::-webkit-scrollbar-thumb { background: var(--sand); border-radius: 2px; }

/* ── HERO ── */
.profile-hero { background: linear-gradient(135deg, var(--terra-pale), var(--cream-mid)); padding: 28px 20px 22px; text-align: center; position: relative; }
.profile-hero-settings { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; box-shadow: var(--shadow-sm); }
/* Stessa posizione dell'ingranaggio impostazioni, ma per il profilo
   pubblico (utente.php) — a differenza di quello resta visibile anche
   su desktop: lì non esiste una colonna impostazioni che la sostituisca. */
.profile-hero-share { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; box-shadow: var(--shadow-sm); }
/* Su profilo.php (mobile) coesiste con la rotella impostazioni: si sposta
   a sinistra di quella invece di sovrapporvisi. */
.profile-hero-share--with-settings { right: 56px; }
.icon-btn { background: var(--white); cursor: pointer; transition: transform .15s; }
.icon-btn:hover { transform: scale(1.05); }
.profile-avatar-wrap { position: relative; display: inline-block; margin-bottom: 12px; }
.profile-avatar { width: 96px; height: 96px; border-radius: 50%; background: var(--terra); color: white; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 38px; font-weight: 600; box-shadow: var(--shadow-md); border: 4px solid var(--white); overflow: hidden; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.profile-avatar-edit { position: absolute; bottom: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; background: var(--white); display: flex; align-items: center; justify-content: center; font-size: 13px; box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .15s; }
.profile-avatar-edit:hover { transform: scale(1.1); }
.profile-name { font-family: var(--font-display); font-size: 26px; font-weight: 600; color: var(--brown); line-height: 1.1; }
.profile-username { font-size: 13px; color: var(--brown-mid); font-weight: 600; margin-top: 3px; }
.profile-bio { font-size: 13px; color: var(--brown-mid); font-weight: 500; margin-top: 8px; max-width: 280px; line-height: 1.5; margin-left: auto; margin-right: auto; }
.profile-joined { margin-top: 8px; display: inline-flex; align-items: center; gap: 5px; background: var(--white); border-radius: var(--radius-pill); padding: 5px 12px; font-size: 11px; font-weight: 700; color: var(--brown-mid); }

/* ── STATS ── */
.profile-stats { display: flex; background: var(--white); border-bottom: 1px solid var(--cream-mid); }
.profile-stat { flex: 1; padding: 18px 8px; text-align: center; cursor: pointer; transition: background .15s; border-right: 1px solid var(--cream-mid); }
.profile-stat:last-child { border-right: none; }
.profile-stat:hover { background: var(--cream); }
.profile-stat-val { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--terra); line-height: 1; }
.profile-stat-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--sand-dark); margin-top: 3px; }

/* ── LIVELLO ── */
.level-section { padding: 20px 16px 0; }
.section-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; color: var(--sand-dark); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--cream-mid); }
.level-card { background: var(--white); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.level-badge { width: 56px; height: 56px; border-radius: var(--radius-md); background: linear-gradient(135deg, var(--terra), var(--terra-dark)); display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.level-info { flex: 1; min-width: 0; }
.level-name { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--brown); }
.level-sub { font-size: 12px; color: var(--brown-mid); font-weight: 500; margin-top: 2px; }
.level-progress-wrap { margin-top: 8px; }
.level-progress-bar { height: 6px; background: var(--cream-mid); border-radius: 3px; overflow: hidden; }
.level-progress-fill { height: 100%; background: linear-gradient(90deg, var(--terra), var(--terra-light)); border-radius: 3px; transition: width .8s ease; }
.level-progress-label { display: flex; justify-content: space-between; font-size: 10px; font-weight: 700; color: var(--sand-dark); margin-top: 4px; }

/* ── BADGES ── */
.badges-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 0 16px; margin-bottom: 16px; }
.badge-item { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.badge-icon { width: 54px; height: 54px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 24px; transition: transform .2s; }
.badge-icon:hover { transform: scale(1.08); }
.badge-icon.earned { box-shadow: var(--shadow-sm); }
.badge-icon.locked { opacity: .35; filter: grayscale(1); }
.badge-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--brown-mid); text-align: center; line-height: 1.2; }

/* ── TABS ── */
.tabs-wrap { padding: 20px 16px 0; }
.tabs { display: flex; background: var(--cream-mid); border-radius: var(--radius-md); padding: 4px; gap: 4px; margin-bottom: 16px; }
.tab { flex: 1; text-align: center; padding: 9px 8px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 700; color: var(--brown-mid); cursor: pointer; transition: all .18s; }
.tab.active { background: var(--white); color: var(--terra); box-shadow: var(--shadow-sm); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp .3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── AVVISTAMENTI ── */
.sightings-list { padding: 0 16px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.sighting-item { background: var(--white); border-radius: var(--radius-md); padding: 14px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-sm); cursor: pointer; border: 1.5px solid transparent; transition: all .18s; }
.sighting-item:hover { border-color: var(--terra); }
.sighting-photo { width: 56px; height: 56px; border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; background: var(--cream-mid); }
.sighting-photo img, .sighting-photo .lqip-img { width: 100%; height: 100%; object-fit: cover; filter: blur(6px); transition: filter .4s; }
.sighting-photo img.loaded, .sighting-photo .lqip-img.loaded { filter: blur(0); }
.cat-card-like { background: none; border: none; font-size: 18px; cursor: pointer; padding: 6px; line-height: 1; transition: transform .2s; }
.cat-card-like:hover { transform: scale(1.2); }
.sighting-info { flex: 1; min-width: 0; }
.sighting-name { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--brown); }
.sighting-meta { font-size: 12px; color: var(--brown-mid); font-weight: 500; margin-top: 2px; }
.sighting-time { font-size: 10px; font-weight: 700; color: var(--sand-dark); display: flex; align-items: center; gap: 3px; margin-top: 4px; }
.sighting-badge { padding: 3px 10px; border-radius: var(--radius-pill); font-size: 10px; font-weight: 800; background: var(--sage-light); color: #3A6A3A; }
.sighting-badge--pending { background: #F5DDA8; color: #8A5A00; }

/* Variante a due colonne per le schede gatto (sperimentale, su richiesta
   dell'utente — "invece di occupare tutta la vista, proviamo a dividerle
   in due"). Card verticale (foto sopra, testo sotto) invece della riga
   orizzontale, altrimenti in metà larghezza sarebbe troppo schiacciata. */
.sightings-list-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.sightings-list-grid .sighting-item { flex-direction: column; align-items: stretch; text-align: center; gap: 8px; padding: 10px; }
.sightings-list-grid .sighting-photo { width: 100%; height: 100px; }
.sightings-list-grid .sighting-meta,
.sightings-list-grid .sighting-time { justify-content: center; }
.sightings-list-grid .sighting-badge { align-self: center; }

/* Su mobile le card in griglia mostrano solo l'essenziale (troppe righe
   di metadati affollano una card larga metà schermo): "gatti caricati" e
   "avvistamenti" tengono solo la data, "preferiti" solo il nome. Su
   desktop (vedi media query più sotto) tutto torna visibile. */
#addedByMeList .sighting-breed, #addedByMeList .sighting-meta, #addedByMeList .sighting-avv-count,
#sightingsList .sighting-breed, #sightingsList .sighting-meta, #sightingsList .sighting-avv-count {
  display: none;
}
#favList .sighting-breed, #favList .sighting-meta, #favList .sighting-time {
  display: none;
}

/* Tasto "Mostra tutti" sotto ciascuna delle 3 liste. */
.show-all-btn {
  font-size: 12px; font-weight: 700; color: var(--terra);
  background: var(--terra-pale); border: none; border-radius: var(--radius-pill);
  padding: 8px 18px; cursor: pointer;
}
.show-all-btn:hover { background: var(--terra); color: #fff; }

/* ── PREFERITI ── */
.fav-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 0 16px; margin-bottom: 16px; }
.fav-item { aspect-ratio: 1; background: var(--cream-mid); overflow: hidden; position: relative; cursor: pointer; }
.fav-item img { width: 100%; height: 100%; object-fit: cover; filter: blur(8px); transition: filter .4s; }
.fav-item img.loaded { filter: blur(0); }
.fav-item:first-child { border-radius: var(--radius-sm) 0 0 0; }
.fav-item:nth-child(3) { border-radius: 0 var(--radius-sm) 0 0; }

.desktop-settings-col { display: none; }
.desktop-layout { display: block; padding: 0; }

/* ── IMPOSTAZIONI ── */
.settings-list { padding: 0 16px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.settings-item { background: var(--white); border-radius: var(--radius-md); padding: 14px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer; border: 1.5px solid transparent; transition: all .18s; box-shadow: var(--shadow-sm); }
.settings-item:hover { border-color: var(--terra); }
.settings-item-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.settings-item-label { flex: 1; font-size: 14px; font-weight: 600; color: var(--brown); }
.settings-item-sub { font-size: 11px; color: var(--sand-dark); font-weight: 500; margin-top: 1px; }
.settings-item-arr { color: var(--sand-dark); }
.settings-toggle { width: 42px; height: 24px; border-radius: 12px; background: var(--sand); position: relative; flex-shrink: 0; transition: background .25s; }
.settings-notif-badge { flex-shrink: 0; background: var(--terra); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 2px 7px; line-height: 1.4; margin-right: 4px; }
.settings-toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .25s; }
.settings-toggle.on { background: var(--terra); }
.settings-toggle.on::after { transform: translateX(18px); }
.settings-section-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; color: var(--sand-dark); padding: 0 16px; margin: 16px 0 8px; }
.logout-btn { margin: 0 16px 20px; width: calc(100% - 32px); padding: 14px; border-radius: var(--radius-pill); border: 1.5px solid #E8CACA; color: #C44545; font-family: var(--font-ui); font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; transition: all .15s; background: var(--white); cursor: pointer; }
.logout-btn:hover { background: #FDF0F0; }

/* ══ MODALI ══ */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(61,43,31,.52); z-index: 600; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--white); border-radius: var(--radius-lg); width: 100%; max-width: 440px; overflow: hidden; box-shadow: var(--shadow-lg); animation: fadeUp .25s ease; }
.modal-head { padding: 22px 22px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--brown); }
.modal-close { width: 34px; height: 34px; border-radius: 50%; background: var(--cream); display: flex; align-items: center; justify-content: center; color: var(--brown-mid); font-size: 18px; transition: background .15s; flex-shrink: 0; cursor: pointer; }
.modal-close:hover { background: var(--cream-mid); }
.modal-body { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-field label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--sand-dark); display: block; margin-bottom: 7px; }
.modal-field input { width: 100%; padding: 12px 14px; border: 1.5px solid var(--sand); border-radius: var(--radius-md); font-family: var(--font-ui); font-size: 15px; color: var(--brown); outline: none; }
.modal-field input:focus { border-color: var(--terra); }
.modal-field-hint { font-size: 11px; color: var(--sand-dark); font-weight: 500; margin-top: 5px; }
.modal-field-err { font-size: 11px; color: #C44545; font-weight: 600; margin-top: 5px; display: none; }
.modal-btn-primary { background: var(--terra); color: white; border-radius: var(--radius-pill); padding: 13px; font-family: var(--font-ui); font-size: 15px; font-weight: 700; cursor: pointer; box-shadow: 0 3px 12px rgba(196,112,79,.35); transition: background .15s; border: none; }
.modal-btn-primary:hover { background: var(--terra-dark); }
.modal-divider { height: 1px; background: var(--cream-mid); margin: 2px 0; }
.modal-subtitle { font-size: 12px; color: var(--brown-mid); font-weight: 500; line-height: 1.5; }
.modal-pass-toggle { position: relative; }
.modal-pass-toggle input { padding-right: 44px; }
.modal-pass-toggle button { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--sand-dark); padding: 4px; background: none; border: none; cursor: pointer; }

/* ══ MODAL CAMBIO AVATAR ══ */
.avatar-modal-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 8px 0 4px;
}
.avatar-modal-circle {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: var(--terra);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 50px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  border: 4px solid var(--white);
  overflow: hidden;
  position: relative;
}
.avatar-modal-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.avatar-modal-hint {
  font-size: 12px;
  color: var(--brown-mid);
  font-weight: 500;
  text-align: center;
  line-height: 1.5;
  max-width: 280px;
}
.avatar-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.avatar-btn-upload {
  background: var(--terra);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  padding: 13px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(196,112,79,.35);
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.avatar-btn-upload:hover { background: var(--terra-dark); }
.avatar-btn-remove {
  background: var(--white);
  color: #C44545;
  border: 1.5px solid #E8CACA;
  border-radius: var(--radius-pill);
  padding: 12px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.avatar-btn-remove:hover { background: #FDF0F0; }
.avatar-modal-input { display: none; }

/* ══ DESKTOP ══ */
@media (min-width: 768px) {
  .profile-scroll { padding-bottom: 32px; }

  .desktop-layout { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; padding: 28px; max-width: 1080px; margin: 0 auto; }
  .desktop-main { min-width: 0; display: flex; flex-direction: column; }

  .profile-hero { flex-direction: row; text-align: left; align-items: center; padding: 26px 28px; gap: 22px; border-radius: var(--radius-lg); margin-bottom: 2px; }
  .profile-avatar-wrap { margin-bottom: 0; flex-shrink: 0; }
  .profile-bio { max-width: 100%; margin-left: 0; margin-right: 0; }
  .profile-hero-content { flex: 1; min-width: 0; }
  .profile-hero-settings { display: none; }
  /* Su desktop la rotella impostazioni sparisce (sostituita dalla colonna
     a destra): il pulsante condividi torna da solo nell'angolo. */
  .profile-hero-share--with-settings { right: 14px; }

  /* Su desktop c'è più spazio: tutti i metadati tornano visibili
     (span → inline, div → block, coerente coi tag reali usati). */
  #addedByMeList .sighting-meta, #sightingsList .sighting-meta, #favList .sighting-meta,
  #favList .sighting-time {
    display: block;
  }
  #addedByMeList .sighting-breed, #addedByMeList .sighting-avv-count,
  #sightingsList .sighting-breed, #sightingsList .sighting-avv-count,
  #favList .sighting-breed {
    display: inline;
  }

  .profile-stats { border-radius: var(--radius-md); overflow: hidden; margin-top: 16px; margin-bottom: 16px; border-bottom: none; box-shadow: var(--shadow-sm); }

  .level-section { padding: 16px 0 0; }
  .badges-grid { padding: 0; }
  .tabs-wrap { padding: 16px 0 0; }
  .sightings-list { padding: 0; }
  .fav-grid { padding: 0; }

  .desktop-settings-col { display: block; position: sticky; top: 0; background: var(--white); border-radius: var(--radius-lg); border: 1px solid var(--cream-mid); box-shadow: var(--shadow-sm); overflow: hidden; }
  .desktop-settings-col .settings-section-title { padding: 12px 16px 6px; margin: 0; font-size: 10px; border-top: 1px solid var(--cream-mid); }
  .desktop-settings-col .settings-section-title:first-child { border-top: none; }
  .desktop-settings-col .settings-list { padding: 0 12px; gap: 5px; margin-bottom: 10px; }
  .desktop-settings-col .settings-item { padding: 10px 12px; box-shadow: none; background: var(--cream); border-radius: var(--radius-sm); }
  .desktop-settings-col .settings-item:hover { background: var(--white); }
  .desktop-settings-col .settings-item-icon { width: 30px; height: 30px; font-size: 15px; }
  .desktop-settings-col .settings-item-label { font-size: 13px; }
  .desktop-settings-col .settings-item-sub { font-size: 10px; }
  .desktop-settings-col .logout-btn { margin: 0 12px 14px; width: calc(100% - 24px); padding: 11px; font-size: 13px; }
  .desktop-settings-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 4px; }
  .desktop-settings-header-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--brown); }
}
