:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 10px 24px rgba(37, 99, 235, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 3rem;
}

/* =========================================================
   HEADER & NAVBAR DESKTOP
   ========================================================= */
header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.logo {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-decoration: none;
  letter-spacing: -0.5px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  background: #f8fafc;
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 9999px;
  border: 1px solid var(--border);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.nav-pill:hover {
  background: #ffffff;
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.nav-pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.nav-pill-admin {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.nav-pill-admin:hover {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}

.notif-badge {
  background: var(--danger);
  color: #ffffff;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  min-width: 18px;
  text-align: center;
}

/* =========================================================
   LAYOUT PRINCIPALE DESKTOP
   ========================================================= */
.main-container {
  max-width: 1300px;
  margin: 1.5rem auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 2rem;
}

.card {
  background: var(--card-bg);
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 1.3rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Sidebar & Menu Pillole */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar h3, .sidebar h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.menu-pills, .cat-pills-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.pill-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.1rem;
  border-radius: 9999px;
  background: #f8fafc;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.pill-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateX(4px);
}

.pill-btn.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border-color: var(--primary);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

/* Form, Input e Bottoni */
.btn {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 9999px;
  padding: 0.55rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-del-pill {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 9999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn-del-pill:hover {
  background: #fca5a5;
}

.pill-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.pill-action.liked {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fecaca;
}

.input-pill, .select-pill, .comment-pill-input {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.88rem;
  outline: none;
  background: #fff;
}

.input-pill:focus, .comment-pill-input:focus {
  border-color: var(--primary);
}

.card textarea, .post-box textarea {
  width: 100%;
  min-height: 110px;
  font-size: 1rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  resize: vertical;
}

.card textarea:focus {
  border-color: var(--primary);
}

/* Post e Feed */
.post-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.post-author {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.post-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.post-image {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 12px;
  margin-top: 0.8rem;
}

.comments-section {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}

.comment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  padding: 0.45rem 0.8rem;
  border-radius: 10px;
  margin-bottom: 0.4rem;
  font-size: 0.88rem;
}

/* Widget Meteo Sidebar */
.weather-widget {
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: #ffffff;
  border-radius: 16px;
  padding: 1.1rem;
  margin-top: 1rem;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.2);
}

.weather-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.weather-city-name {
  font-weight: 700;
  font-size: 1rem;
}

.weather-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.4rem 0;
}

.weather-temp {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
}

.weather-icon {
  font-size: 2.3rem;
}

.weather-details {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  opacity: 0.85;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding-top: 0.5rem;
  margin-top: 0.4rem;
}

.weather-search-box {
  margin-top: 0.6rem;
  display: flex;
  gap: 0.3rem;
}

.weather-search-box input {
  flex: 1;
  padding: 0.35rem 0.6rem;
  border-radius: 9999px;
  border: none;
  font-size: 0.78rem;
  outline: none;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.weather-search-box button {
  background: #ffffff;
  color: #1e3a8a;
  border: none;
  border-radius: 9999px;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: bold;
  cursor: pointer;
}

/* Banner Welcome */
.welcome-hero-banner {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 1.2rem;
  min-height: 190px;
  background: url('https://images.unsplash.com/photo-1451187580459-43490279c0fa?auto=format&fit=crop&w=1600&q=80') center/cover no-repeat;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
}

.welcome-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(10, 15, 30, 0.88) 0%, rgba(20, 45, 95, 0.65) 100%);
}

.welcome-hero-content {
  position: relative;
  z-index: 2;
  padding: 1.6rem 2rem;
  color: #ffffff;
  width: 100%;
}

.mobile-bottom-nav {
  display: none !important;
}

/* =========================================================
   OTTIMIZZAZIONE MOBILE (Smartphone < 768px - APP STYLE)
   ========================================================= */
@media (max-width: 768px) {
  body {
    padding-bottom: 80px !important; /* Spazio per non coprire nulla sotto la bottom bar */
  }

  /* 1. Header su 1 sola riga pulita */
  .header-container {
    padding: 0.6rem 1rem !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
  }

  .logo {
    font-size: 1.25rem !important;
  }

  /* Nascondi la lista infinita di pillole nell'header (la gestisce la Bottom Bar) */
  .nav-links .nav-pill {
    display: none !important;
  }

  /* Mantieni nell'header solo il selettore lingue ed eventuale icona rapida */
  .nav-links {
    gap: 0.3rem !important;
    flex-wrap: nowrap !important;
  }

  .lang-switcher {
    padding: 0.2rem 0.45rem !important;
  }

  /* 2. Layout principale: 1 colonna a tutta larghezza */
  .main-container {
    display: block !important;
    width: 100% !important;
    padding: 0 0.65rem !important;
    margin: 0.6rem auto !important;
  }

  /* 3. Nascondi la Sidebar su mobile per evitare scroll inutili */
  .sidebar {
    display: none !important;
  }

  .feed {
    width: 100% !important;
  }

  /* 4. Banner compatto */
  .welcome-hero-banner {
    min-height: 130px !important;
    margin-bottom: 0.8rem !important;
    border-radius: 14px !important;
  }

  .welcome-hero-content {
    padding: 1rem !important;
  }

  .welcome-hero-content h2 {
    font-size: 1.15rem !important;
    margin-bottom: 0.2rem !important;
  }

  .welcome-hero-content p {
    font-size: 0.8rem !important;
    margin-bottom: 0.6rem !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .hero-shortcuts {
    display: none !important; /* Rimosse scorciatoie doppie dal banner */
  }

  /* 5. Box Post e Input senza zoom fastidioso su iPhone */
  .card {
    padding: 0.9rem !important;
    border-radius: 14px !important;
    margin-bottom: 0.8rem !important;
  }

  .card textarea, .post-box textarea {
    font-size: 16px !important; /* 16px impedisce a Safari/iOS di zoomare lo schermo quando clicchi */
    min-height: 80px !important;
    padding: 0.7rem !important;
  }

  /* 6. Griglie Annunci e Schede a 1 colonna pulita */
  .market-grid, .group-grid, .user-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  .item-img {
    height: 180px !important;
  }

  /* 7. Bottom Navigation Bar Fissa in Basso (Stile Instagram/App) */
  .mobile-bottom-nav {
    display: flex !important;
    justify-content: space-around;
    align-items: center;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 58px;
    background: #ffffff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    z-index: 999999;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    position: relative;
    padding: 0.2rem 0;
  }

  .mobile-bottom-nav .nav-icon {
    font-size: 1.25rem;
    line-height: 1.1;
  }

  .mobile-bottom-nav .nav-item.active {
    color: var(--primary);
    font-weight: 700;
  }

  .mobile-bottom-nav .bottom-badge {
    position: absolute;
    top: -2px;
    right: 20%;
    background: var(--danger);
    color: #ffffff;
    border-radius: 9999px;
    font-size: 0.65rem;
    padding: 0.05rem 0.35rem;
    font-weight: 800;
    border: 2px solid #ffffff;
  }
}
/* Container Video Responsivo */
.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* Rapporto 16:9 */
  height: 0;
  border-radius: 14px;
  overflow: hidden;
  margin-top: 0.8rem;
  background: #000;
}

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

.tiktok-container {
  width: 100%;
  max-width: 340px;
  margin: 0.8rem auto 0;
  border-radius: 12px;
  overflow: hidden;
}

.tiktok-container iframe {
  width: 100%;
  height: 580px;
  border: 0;
}
/* VARIABILI MODALITÀ SCURA */
body.dark-mode {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    background-color: var(--bg) !important;
    color: var(--text) !important;
}

body.dark-mode .card,
body.dark-mode .post-box,
body.dark-mode .post-card,
body.dark-mode .stat-card,
body.dark-mode header,
body.dark-mode .dock-box {
    background-color: var(--card-bg) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select {
    background-color: #0f172a !important;
    color: #f8fafc !important;
    border-color: var(--border) !important;
}

body.dark-mode .btn-react,
body.dark-mode .pill-btn,
body.dark-mode .emoji-btn-mini {
    background-color: #334155 !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
}

body.dark-mode .admin-table th,
body.dark-mode .admin-table td {
    border-color: var(--border) !important;
    color: var(--text) !important;
}

body.dark-mode code {
    background-color: #334155 !important;
    color: #38bdf8 !important;
}
/* ==========================================
   MODALITÀ SCURA (FORZATURA COLORI)
   ========================================== */
html body.dark-mode {
    background-color: #0b1120 !important;
    color: #f1f5f9 !important;
}

html body.dark-mode header,
html body.dark-mode .card,
html body.dark-mode .post-box,
html body.dark-mode .post-card,
html body.dark-mode .stat-card,
html body.dark-mode .dock-box,
html body.dark-mode .comments-section {
    background-color: #1e293b !important;
    background: #1e293b !important;
    color: #f1f5f9 !important;
    border-color: #334155 !important;
}

/* Testi, link e titoli */
html body.dark-mode h1, 
html body.dark-mode h2, 
html body.dark-mode h3, 
html body.dark-mode h4,
html body.dark-mode strong,
html body.dark-mode .post-author {
    color: #f8fafc !important;
}

html body.dark-mode .post-content,
html body.dark-mode p,
html body.dark-mode span {
    color: #e2e8f0;
}

html body.dark-mode .post-date,
html body.dark-mode .stat-label {
    color: #94a3b8 !important;
}

/* Campi di testo e form */
html body.dark-mode input[type="text"],
html body.dark-mode input[type="number"],
html body.dark-mode input[type="email"],
html body.dark-mode textarea,
html body.dark-mode select {
    background-color: #0f172a !important;
    color: #f8fafc !important;
    border: 1px solid #334155 !important;
}

/* Pulsanti, pillole ed emoji */
html body.dark-mode .pill-btn,
html body.dark-mode .btn-react,
html body.dark-mode .emoji-btn-mini {
    background-color: #334155 !important;
    color: #f1f5f9 !important;
    border-color: #475569 !important;
}

html body.dark-mode .nav-pill {
    background-color: #334155 !important;
    color: #f8fafc !important;
}

/* Tabelle Admin */
html body.dark-mode .admin-table th {
    background-color: #0f172a !important;
    color: #94a3b8 !important;
    border-color: #334155 !important;
}

html body.dark-mode .admin-table td {
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

html body.dark-mode code {
    background-color: #0f172a !important;
    color: #38bdf8 !important;
    border: 1px solid #334155 !important;
}
.btn-share-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
    line-height: 1.2;
}
.btn-share-pill:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}
/* ========================================================
   FIX RESPONSIVE MOBILE: TASTI SONDAGGI, AZIONI E CONTAINER
   ======================================================== */
.post-actions, 
.post-box form > div, 
.menu-pills, 
.action-buttons {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 0.45rem !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.pill-action, 
.pill-btn, 
.btn-poll, 
button[type="button"], 
button[type="submit"] {
    max-width: 100% !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
}

@media (max-width: 600px) {
    .pill-action, 
    .pill-btn {
        font-size: 0.8rem !important;
        padding: 0.4rem 0.65rem !important;
    }
    .post-box {
        overflow: hidden !important;
    }
}
/* ========================================================
   FIX IMMAGINI POST: PROPORZIONI PERFETTE (DESKTOP & MOBILE)
   ======================================================== */

.post-image,
.post-content img,
.card img.post-media,
.feed .card img:not(.avatar):not(.brand-logo-img) {
    width: 100% !important;
    max-width: 100% !important;
    /* Su desktop limita l'altezza massima per non farla diventare gigante */
    max-height: 520px !important;
    height: auto !important;
    /* MOSTRA L'IMMAGINE INTERA SENZA TAGLIARLA */
    object-fit: contain !important;
    background-color: #0b0f19 !important; /* Sfondo scuro elegante tipo Facebook/Twitter se la foto non è 16:9 */
    border-radius: 12px !important;
    display: block !important;
    margin: 0.75rem auto !important;
}

/* Su smartphone si adatta alla dimensione dello schermo */
@media screen and (max-width: 768px) {
    .post-image,
    .post-content img,
    .feed .card img:not(.avatar):not(.brand-logo-img) {
        max-height: 420px !important;
        background-color: transparent !important;
    }
}
/* ========================================================
   FIX TESTATA POST & AVATAR (SMARTPHONE & DESKTOP)
   ======================================================== */

/* Contenitore della testata del post (Autore, Data, Menu) */
.post-header,
.feed .card > div:first-child:has(img) {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 0.65rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Blocca l'avatar a 42px precisi: NON può più ingrandirsi */
.avatar,
.post-header img,
.post-user-info img,
.feed .card .avatar {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    max-width: 42px !important;
    max-height: 42px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    flex-shrink: 0 !important; /* Impedisce che venga schiacciato o allargato */
    display: inline-block !important;
    margin: 0 !important;
    background: transparent !important;
}

/* Avatar generico/lettera se l'utente non ha la foto */
.avatar-placeholder,
.default-avatar {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    border-radius: 50% !important;
    background: var(--primary, #2563eb) !important;
    color: #ffffff !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
}

/* Informazioni utente (Nome utente sopra, data sotto) */
.post-user-info,
.post-author-meta {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    flex: 1 !important;
    min-width: 0 !important; /* Impedisce al testo lungo di spingere fuori i tasti */
}

.post-user-info strong,
.post-author-meta strong,
.post-user-info a {
    font-size: 0.92rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    text-decoration: none !important;
}

.post-user-info small,
.post-user-info span.date,
.post-time {
    font-size: 0.75rem !important;
    color: var(--text-muted, #64748b) !important;
}

/* Menu opzioni post (i 3 puntini o pulsante elimina/segnala) a destra */
.post-options,
.post-header-actions {
    margin-left: auto !important;
    flex-shrink: 0 !important;
}
/* ==========================================
   BARRA DI RICERCA ESPANDIBILE NELL'HEADER
   ========================================== */
.expandable-search {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.search-trigger-btn {
    background: transparent;
    border: none;
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: 9999px;
    transition: background 0.2s;
    line-height: 1;
}

.search-trigger-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.search-expand-form {
    display: flex;
    align-items: center;
    width: 0;
    opacity: 0;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: #ffffff;
    border-radius: 9999px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
    border: 1px solid var(--border, #cbd5e1);
    z-index: 100;
}

.expandable-search.active .search-expand-form {
    width: 260px; /* Larghezza da aperto su Desktop */
    opacity: 1;
    padding: 0.25rem 0.5rem 0.25rem 0.8rem;
}

.expandable-search.active .search-trigger-btn {
    opacity: 0;
    pointer-events: none;
}

.search-expand-form input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 0.9rem;
    background: transparent;
    color: inherit;
    font-family: inherit;
}

.search-close-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    line-height: 1;
    border-radius: 50%;
}

.search-close-btn:hover {
    color: #0f172a;
}

/* Su smartphone la barra si adatta allo spazio disponibile */
@media screen and (max-width: 600px) {
    .expandable-search.active .search-expand-form {
        width: 200px;
    }
}
/* Tendina risultati ricerca live */
.search-results-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    background: #ffffff;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 14px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
    z-index: 1000;
    max-height: 360px;
    overflow-y: auto;
    padding: 0.5rem;
}

.search-res-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    font-size: 0.88rem;
}

.search-res-item:hover {
    background: #f1f5f9;
}

.search-res-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 9999px;
    background: #eff6ff;
    color: #1d4ed8;
    margin-left: auto;
    font-weight: 700;
}
/* ==========================================
   BARRA FOOTER / COPYRIGHT IN FONDO
   ========================================== */
.site-footer {
    width: 100%;
    margin-top: 3rem;
    padding: 1.5rem 1rem 2rem 1rem;
    background: #ffffff;
    border-top: 1px solid var(--border, #e2e8f0);
    box-sizing: border-box;
}

.footer-inner {
    max-width: 1300px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8rem;
    font-size: 0.85rem;
    color: var(--text-muted, #64748b);
}

.footer-links {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s;
}

.footer-links a:hover {
    color: var(--primary, #2563eb);
}

.footer-links .sep {
    color: #cbd5e1;
}

.footer-copy {
    font-size: 0.82rem;
}

/* Su smartphone lascia spazio per non finire sotto bottom_nav.php */
@media screen and (max-width: 768px) {
    .site-footer {
        padding-bottom: 5.5rem; /* Margine di sicurezza per la barra inferiore */
        text-align: center;
    }
    .footer-inner {
        flex-direction: column;
        justify-content: center;
    }
}
/* ========================================================
   FIX TABELLA VISITATORI & WIDGET PAESI (PANNELLO ADMIN)
   ======================================================== */

/* Contenitore con scroll orizzontale: impedisce alla tabella di allargare la pagina */
.table-responsive,
.admin-table-wrap {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border, #e2e8f0);
    background: #ffffff;
}

/* Tabella compatta */
.table-responsive table,
.admin-table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 0.85rem !important;
    white-space: nowrap !important; /* Mantiene la tabella pulita */
}

.table-responsive th,
.table-responsive td {
    padding: 0.65rem 0.85rem !important;
    text-align: left !important;
    border-bottom: 1px solid var(--border, #f1f5f9) !important;
}

/* Tronca il testo troppo lungo dell'User Agent / Pagina con i puntini (...) */
.table-responsive td.cell-truncate,
.table-responsive td:nth-child(3),
.table-responsive td:nth-child(4) {
    max-width: 180px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* LAYOUT GRIGLIA ADMIN (Tabella a sinistra + Top 5 Paesi a destra su Desktop) */
.admin-grid-visitors {
    display: grid !important;
    grid-template-columns: 2fr 1fr !important; /* 2/3 tabella, 1/3 top paesi */
    gap: 1.2rem !important;
    align-items: start !important;
    width: 100% !important;
}

/* Su schermi più piccoli torna in colonna singola ordinata */
@media screen and (max-width: 1024px) {
    .admin-grid-visitors {
        grid-template-columns: 1fr !important;
    }
}
/* ==========================================
   TICKER LIVE SERIE A
   ========================================== */
.seriea-ticker-wrap {
    width: 100%;
    overflow: hidden;
    background: #0f172a;
    color: #f8fafc;
    border-radius: 12px;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    border: 1px solid #1e293b;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.seriea-ticker-label {
    background: #2563eb;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 0.65rem 0.9rem;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    z-index: 2;
}

.seriea-ticker-track {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    white-space: nowrap;
    padding: 0.55rem 0.8rem;
    scrollbar-width: none; /* Nasconde barra su Firefox */
}

.seriea-ticker-track::-webkit-scrollbar {
    display: none; /* Nasconde barra su Chrome/Safari */
}

.seriea-match-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.06);
    padding: 0.3rem 0.7rem;
    border-radius: 8px;
    font-size: 0.84rem;
}

.seriea-match-item .teams {
    font-weight: 700;
    color: #ffffff;
}

.seriea-match-item .score {
    background: #3b82f6;
    color: #ffffff;
    font-weight: 800;
    padding: 0.1rem 0.45rem;
    border-radius: 6px;
    font-size: 0.78rem;
}

.seriea-match-item .status {
    color: #94a3b8;
    font-size: 0.72rem;
    text-transform: uppercase;
}