/* ============================================================
   KIDSTRIBE — CSS OTTIMIZZATO PER WEB APP
   Palette Verde Salvia + Layout a Griglia Orizzontale
   ============================================================ */

/* --- VARIABILI E BASI --- */
:root {
    --sage-pastel:   #E1F2E5;
    --sage-medium:   #A8CBB3;
    --sage-dark:     #77B28C;
    --sage-deep:     #2D3E33;
    --cream:         #F9FCF9;
    --cream-darker:  #F1F8F2;
    --kids-blue:     #007AFF;
    --gray-light:    #f5f5f5;
    --gray-active:   #e0e0e0;

    /* Layout */
    --navbar-h:      70px;
    --sticky-h:      80px; /* search + filtri + location */
    --card-radius:   20px;
    --card-gap:      7px;
}

/* --- RESET & BASE --- */
*, *::before, *::after { box-sizing: border-box; }

body {
    background-color: #fff;
    font-family: 'Inter', sans-serif;
    color: var(--sage-deep);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    /* Rende la pagina una vera web-app: no scroll bounce laterale */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: none;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
    height: var(--navbar-h);
    display: flex;
    align-items: center;
    border-bottom: 3px solid var(--sage-dark);
    background-color: #fff !important;
    padding: 0 1rem;
}

.nav-social        { flex: 1; display: flex; align-items: center; gap: 8px; }
.nav-social a      { color: var(--sage-dark) !important; font-size: 1.1rem; }
.social-label      { font-size: .65rem; font-weight: 800; text-transform: uppercase; color: var(--sage-deep); }

.nav-logo          { flex: 0 0 auto; text-align: center; }
#main-logo         { height: 60px; width: auto; }

.nav-profile       { flex: 1; display: flex; justify-content: flex-end; align-items: center; gap: 10px; }


/* ============================================================
   STICKY HEADER (Location + Filtri)
   ============================================================ */
#sticky-header-container {
    position: fixed;
    top: var(--navbar-h);
    left: 0; right: 0;
    z-index: 99;
    background: #fff;
    border-bottom: 1px solid var(--sage-pastel);
    box-shadow: 0 4px 10px rgba(0,0,0,.03);
    transition: transform .28s ease-in-out;
    will-change: transform;
}

.header-hidden { transform: translateY(-110%); }

/* ============================================================
   BARRA LOCALIZZAZIONE
   ============================================================ */
.location-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--cream-darker);
    padding: 8px 12px;
    border-radius: 15px;
    border: 1px solid var(--sage-pastel);
    gap: 8px;
}

.text-distance {
    font-size: .8rem;
    font-weight: 800;
    margin: 0;
    color: var(--sage-deep);
}

/* Pulsanti raggio + select provincia — stile unificato */
.btn-location,
.btn-raggio,
#filtro-provincia {
    background-color: var(--sage-pastel) !important;
    border: 2px solid var(--sage-dark) !important;
    color: var(--sage-dark) !important;
    border-radius: 12px;
    font-weight: 800;
    padding: 5px 12px;
    font-size: .7rem;
    white-space: nowrap;
    transition: all .2s;
    cursor: pointer;
    outline: none;
}

.btn-location.active,
.btn-raggio.active,
#filtro-provincia:not([value=""]) {
    background-color: var(--sage-dark) !important;
    color: #fff !important;
}

#filtro-provincia {
    appearance: none;
    -webkit-appearance: none;
    text-align: center;
}

/* ============================================================
   FILTRI ORIZZONTALI SCROLLABILI
   ============================================================ */
.filter-wrapper {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}
.filter-wrapper::-webkit-scrollbar { display: none; }

.filter-container {
    display: inline-flex;
    gap: 8px;
    padding: 3px 5px;
}

.btn-filter {
    background-color: var(--gray-light);
    border: none;
    color: var(--sage-deep);
    border-radius: 15px;
    padding: 5px 12px;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-filter.active { background-color: var(--sage-dark); color: #fff; }

/* Cuore nel filtro preferiti */
.icon-fav-filter {
    fill: none;
    stroke: #000;
    stroke-width: 2px;
    transition: all .3s ease;
}
.btn-filter.active .icon-fav-filter { fill: #ff4757; stroke: #ff4757; }

/* ============================================================
   MAIN CONTENT — GRIGLIA LOCALI OTTIMIZZATA WEB APP
   ============================================================ */
.main-content {
    margin-top: calc(var(--navbar-h) + var(--sticky-h)) !important;
    padding: 8px !important;
    width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Griglia responsiva: 1 colonna su mobile, 2 su tablet e desktop */
#lista-locali.row {
    margin-left: 0;
    margin-right: 0;
    display: grid !important;
    grid-template-columns: 1fr;
    gap: var(--card-gap);
}

@media (min-width: 576px)  { #lista-locali.row { grid-template-columns: repeat(2, 1fr); } }

/* Ogni colonna generata da JS deve occupare l'intera cella */
#lista-locali.row > [class*="col"] {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    /* Stretch verticale: tutte le card nella stessa riga raggiungono la stessa altezza */
    display: flex;
}

/* ============================================================
   CARD LOCALE
   ============================================================ */
.card-locale {
    border: none;
    border-radius: var(--card-radius);
    position: relative;
    overflow: hidden;
    background-color: transparent;
    box-shadow: 0 4px 15px rgba(0,0,0,.06);
    width: 100%;
    display: flex;
    flex-direction: column;
    transition: box-shadow .2s ease, transform .15s ease;
}
.card-locale:active { transform: scale(.98); box-shadow: 0 2px 8px rgba(0,0,0,.08); }

/* Il card-body ha sfondo semitrasparente: l'immagine ::after rimane visibile */
.card-locale .card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 10px !important;
    background-color: rgba(255,255,255,0.4);
    position: relative;
    z-index: 1;
}

/* Immagine di sfondo lato destro — nessun z-index negativo */
.card-locale::after {
    content: "";
    position: absolute;
    inset: 0;
    background-size: contain;
    background-position: right center;
    background-repeat: no-repeat;
    -webkit-mask-image: linear-gradient(to right, transparent 40%, black 85%);
    mask-image:         linear-gradient(to right, transparent 40%, black 85%);
    pointer-events: none; /* non intercetta i click sui badge e sui bottoni */
}

.card-locale::after      { background-image: url('img/card-bg.png'); }

/* --- Titolo card --- */
.card-locale h5 {
    font-size: .95rem;
    font-weight: 800;
    color: var(--sage-deep);
    line-height: 1.2;
    margin-bottom: 4px;
    /* Taglia titoli lunghissimi su 2 righe max */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Badge categoria (blu) --- */
.text-primary {
    color: var(--kids-blue) !important;
    font-weight: 800 !important;
    background: rgba(0, 122, 255, .1);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: .68rem;
    display: inline-block;
    width: auto;
}

/* --- GPS info card --- */
#gps-help {
    margin: 8px;
    border-radius: 16px;
}

/* ============================================================
   BADGE KIDS (caratteristiche del locale)
   ============================================================ */
.badges-container { max-width: 100%; gap: 8px; margin-top: 8px; }

.badges-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    width: 100%;
    /* Spinge i bottoni azione verso il basso occupando lo spazio libero */
    flex: 1;
    align-content: flex-start;
}

.badge-kids {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: .65rem;
    font-weight: 700;
    transition: all .2s ease;
    background-color: transparent;
}

.badge-kids.grey {
    /* Nessuna conferma: trasparente, bordo leggero */
    color: var(--sage-medium);
    border: 1px solid var(--sage-pastel);
}

.badge-kids.confirmed {
    /* Confermato dalla community (non da me): come prima "active" */
    color: var(--sage-deep);
    border: 2px solid var(--sage-medium);
}

.badge-kids.active {
    /* Confermato anche da me: sfondo verde chiaro */
    color: var(--sage-deep);
    border: 2px solid var(--sage-medium);
    background-color: rgba(119, 178, 140, 0.15); /* verde chiaro trasparente */
}

.badge-kids strong {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 16px; height: 16px;
    background-color: var(--sage-pastel);
    color: var(--sage-dark);
    border-radius: 4px;
    font-size: .6rem;
    padding: 0 3px;
}

.badge-kids.confirmed strong,
.badge-kids.active strong {
    background-color: var(--sage-medium);
    color: #fff;
}

.icona-badge {
    width: 13px; height: 13px;
    stroke-width: 4;
    flex-shrink: 0;
}

.badge-kids.confirmed .icona-badge { color: var(--sage-dark); }
.badge-kids.active    .icona-badge { color: var(--sage-dark); }
.badge-kids.grey      .icona-badge { color: var(--sage-dark); }

/* ============================================================
   PULSANTI AZIONE CARD
   ============================================================ */
/* Contenitore bottoni: sempre in fondo alla card */
.card-locale .card-body > .row:last-child {
    margin-top: auto;
    padding-top: 8px;
}

.btn-dettagli,
.btn-maps,
.btn-prenota {
    background-color: transparent;
    color: var(--sage-deep);
    border: 2px solid var(--sage-pastel);
    border-radius: 12px;
    font-weight: 800;
    font-size: .72rem;
    padding: 6px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 36px;
    transition: all .2s ease;
    white-space: nowrap;
}

.btn-dettagli:active,
.btn-maps:active { background-color: var(--sage-pastel); }

/* Bottone cuore */
.btn-heart svg {
    pointer-events: none;
    fill: none;
    stroke: #000;
    stroke-width: 2px;
    transition: all .3s ease;
}
.btn-heart.active svg     { fill: #ff4757; stroke: #ff4757; }
.btn-heart:active          { transform: scale(1.2); }
.btn-heart:focus           { outline: none; box-shadow: none; }

/* ============================================================
   MODAL QUANTITÀ
   ============================================================ */
.btn-qty {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 2px solid var(--sage-dark);
    background: #fff;
    color: var(--sage-dark);
    font-weight: bold;
    display: flex; align-items: center; justify-content: center;
}

.qty-input {
    width: 36px;
    border: none;
    background: transparent;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
}

/* ============================================================
   OVERRIDE BOOTSTRAP (colore warning → verde salvia)
   ============================================================ */
.btn-warning,
.text-warning {
    background-color: var(--sage-dark) !important;
    border-color:     var(--sage-dark) !important;
    color: #fff !important;
}
.spinner-border.text-warning { color: var(--sage-dark) !important; }

/* ============================================================
   PWA INSTALL BANNER
   ============================================================ */
.pwa-banner {
    position: fixed;
    bottom: 15px; left: 15px; right: 15px;
    background: #fff;
    z-index: 9999;
    border-radius: 18px;
    box-shadow: 0 8px 25px rgba(0,0,0,.15);
    border: 2px solid var(--sage-dark);
}

/* ============================================================
   SWEETALERT2
   ============================================================ */
.swal2-popup    { border-radius: 25px !important; }
.swal2-confirm,
.swal2-cancel   { border-radius: 12px !important; }

/* ============================================================
   UTILITY
   ============================================================ */
.x-small {
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* Badge utente — solo livello numerico, sempre visibile */
.user-badge-info {
    display: block !important;
}

.user-level-badge {
    font-size: .75rem;
    font-weight: 800;
    color: var(--sage-dark);
    display: inline-block;
    line-height: 1;
    letter-spacing: .3px;
}

.user-badge-name {
    font-size: .6rem;
    font-weight: 700;
    color: var(--sage-deep);
    margin: 0;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-avatar-circle {
    width: 46px; height: 46px;
    background: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--sage-dark);
    color: var(--sage-dark);
    transition: transform .2s ease;
    overflow: hidden;
    padding: 0;
}

/* Avatar picker nel modal */
.avatar-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 8px;
    border-radius: 20px;
    border: 3px solid transparent;
    transition: all .2s ease;
}

.avatar-picker-item img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--sage-pastel);
    transition: transform .2s ease;
}

.avatar-picker-item:hover img,
.avatar-picker-item.selected img {
    transform: scale(1.06);
    border-color: var(--sage-dark);
}

.avatar-picker-item.selected {
    border-color: var(--sage-dark);
    background-color: var(--sage-pastel);
}

/* Nasconde elementi decorativi su schermi molto piccoli */
@media (max-width: 360px) {
    .user-badge-info { display: none !important; }

    /* Su schermi molto piccoli forza 1 colonna (già default) */
    #lista-locali.row { grid-template-columns: 1fr; }
}

/* Input numerici: rimuove frecce */
input[type=number]                            { -moz-appearance: textfield; }
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button              { -webkit-appearance: none; margin: 0; }

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar-wrapper {
    padding: 0 1px;
}

.search-bar-inner {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--cream-darker);
    border: 1.5px solid var(--sage-medium);
    border-radius: 14px;
    padding: 5px 8px;
    transition: border-color .2s ease;
}

.search-bar-inner:focus-within {
    border-color: var(--sage-dark);
    box-shadow: 0 0 0 3px rgba(119,178,140,.12);
}

.search-icon {
    color: var(--sage-dark);
    flex-shrink: 0;
}

#search-nome {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: .82rem;
    font-weight: 600;
    color: var(--sage-deep);
    min-width: 0;
}

#search-nome::placeholder {
    color: var(--sage-medium);
    font-weight: 500;
}

/* Nasconde la X nativa dei browser su input[type=search] */
#search-nome::-webkit-search-cancel-button { display: none; }

#search-clear {
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--sage-medium);
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    color: #fff;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0;
    transition: background .15s ease;
}

#search-clear:hover { background: var(--sage-dark); }


/* ============================================================
   GDPR COOKIE BANNER
   Posizionato in basso, sopra tutto (z-index > PWA banner).
   Animazione slide-up al primo render.
   ============================================================ */
.gdpr-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000; /* sopra il PWA banner (9999) */
    background: #fff;
    border-top: 2px solid var(--sage-pastel);
    box-shadow: 0 -4px 20px rgba(0,0,0,.12);
    padding: 14px 16px 18px;
    animation: slideUpBanner .35s ease;
}

.gdpr-banner-inner {
    max-width: 640px;
    margin: 0 auto;
}

.gdpr-text {
    font-size: 0.78rem;
    color: #555;
    line-height: 1.55;
    margin-bottom: 10px;
}

.gdpr-link {
    color: var(--sage-dark);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.gdpr-link:hover { color: var(--sage-deep); }

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

/* Checkbox consenso nel form registrazione */
#gdpr-reg-check .form-check-input:checked {
    background-color: var(--sage-dark);
    border-color: var(--sage-dark);
}

/* ── Avatar picker: stati locked / selected ───────────────── */
.avatar-picker-item {
    cursor: pointer;
    opacity: 1;
    transition: transform 0.15s, opacity 0.15s;
    text-align: center;
}
.avatar-picker-item img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid transparent;
    object-fit: cover;
    transition: border-color 0.15s;
}
.avatar-picker-item.selected img {
    border-color: var(--sage-dark, #77B28C);
}
.avatar-picker-item.locked {
    opacity: 0.45;
    cursor: not-allowed;
}
.avatar-picker-item.locked img {
    filter: grayscale(80%);
}
.avatar-label {
    font-size: 0.72rem;
    color: #888;
}

/* ── Logo cliccabile ──────────────────────────────────────── */
#main-logo {
    cursor: pointer;
    transition: transform 0.15s;
}
#main-logo:hover {
    transform: scale(1.08);
}
