/* Mobile-first design - Notizie.css */
:root {
  --primary-color: #007bff;
  --secondary-color: #6c757d;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --info-color: #17a2b8;
  --light-color: #f8f9fa;
  --dark-color: #343a40;
  --white: #ffffff;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --transition: all 0.3s ease;
}

/* Hero Section */
.hero-section {
  background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="75" cy="75" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="50" cy="10" r="0.5" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  opacity: 0.1;
}

.hero-section-notizia {
  background: #ffffff;
  padding: 4rem 0;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid #e9ecef;
}

/* Garantisce spazio in fondo alla hero per evitare che il contenuto successivo
   si sovrapponga visivamente (utile quando si usa margin negativo altrove) */
.hero-section-notizia {
  padding-bottom: 5rem; /* leggero incremento per separazione */
}

.hero-section-notizia::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="%23ffffff" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="%23ffffff" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  opacity: 0.1;
}
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  background: #f8f9fa;
  min-height: 100vh;
  margin: 0;
  color: #333;
}

.main-content {
  background: #ffffff;
  margin-top: 0; /* rimosso margin negativo per evitare sovrapposizioni */
  position: relative;
  padding: 3rem 0;
}

.notizie-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.notizia-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(13, 110, 253, 0.1);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.8);
  position: relative;
  display: flex;
  flex-direction: column;
}

.notizia-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 40px rgba(13, 110, 253, 0.15);
}

.card-image {
  position: relative;
  overflow: hidden;
  height: 150px;
  flex-shrink: 0; /* Previene compressione dell'immagine */
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  min-height: 150px;
}

.card-img[src="/assets/images/Campo.png"] {
  object-fit: contain; /* Centra l'immagine di default se è più piccola */
  background: #f8f9fa; /* Sfondo chiaro per l'immagine di default */
}

.notizia-card:hover .card-img {
  transform: scale(1.05);
}

.card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    rgba(13, 110, 253, 0.9) 0%,
    rgba(34, 177, 76, 0.9) 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.notizia-card:hover .card-overlay {
  opacity: 1;
}

.read-more-btn {
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-content {
  padding: 1rem;
  position: relative;
  z-index: 5;
}

.card-meta {
  margin-bottom: 0.5rem;
}

.date {
  font-size: 0.85rem;
  color: #666;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 0.5rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-excerpt {
  color: #666;
  line-height: 1.5;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.read-full-link {
  color: #0d6efd;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.3s ease;
}

.read-full-link:hover {
  color: #22b14c;
}

.btn-load-more {
  background: linear-gradient(135deg, #0d6efd 0%, #22b14c 100%);
  border: none;
  font-weight: 600;
  letter-spacing: 0.5px;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(13, 110, 253, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: visible;
  color: #fff;
  padding: 1rem 2rem;
  border-radius: 50px;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-load-more:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(13, 110, 253, 0.15);
}

.btn-load-more:active {
  transform: translateY(0);
}

.no-news {
  padding: 4rem 2rem;
  grid-column: 1 / -1;
}

.no-news i {
  opacity: 0.5;
}

/* Search and Filters Styles */
.search-filters-card {
  background: linear-gradient(
    135deg,
    var(--card-bg) 0%,
    rgba(248, 249, 250, 0.8) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow-light);
  margin-bottom: 2rem;
}

.search-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  z-index: 4;
  color: var(--muted-text);
  font-size: 1.1rem;
}

.search-input {
  padding-left: 40px;
  padding-right: 40px;
  border-radius: 25px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.9);
  transition: all 0.3s ease;
  font-size: 1rem;
}

.search-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
  background: white;
}

.clear-btn {
  position: absolute;
  right: 8px;
  z-index: 4;
  border: none;
  background: none;
  color: var(--muted-text);
  padding: 0.375rem 0.75rem;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.clear-btn:hover {
  background-color: var(--muted-text);
  color: white;
}

/* Search Button Styles */
.search-button {
  border-radius: 25px;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid transparent;
  background: var(--btn-bg);
  color: white;
  box-shadow: 0 4px 15px rgba(13, 110, 253, 0.2);
  position: relative;
  overflow: hidden;
}

.search-button::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}

.search-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(13, 110, 253, 0.3);
  background: var(--btn-hover-bg);
}

.search-button:hover::before {
  left: 100%;
}

.search-button:active {
  transform: translateY(0);
}

.filter-select {
  border-radius: 12px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.9);
  transition: all 0.3s ease;
  font-size: 0.95rem;
}

.filter-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
  background: white;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 2rem;
}

.filter-tag {
  display: inline-flex;
  align-items: center;
  background: var(--primary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  animation: fadeInScale 0.3s ease-out;
}

.filter-tag .remove-filter {
  margin-left: 0.5rem;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.3s ease;
}

.filter-tag .remove-filter:hover {
  opacity: 1;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Tablet */
@media (min-width: 768px) {
  .notizie-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }

  .hero-section {
    padding: 6rem 0;
  }

  .main-content {
    margin-top: 0; /* evita overlap su tablet */
    padding: 4rem 0;
  }

  .card-image {
    height: 180px;
  }

  .card-title {
    font-size: 1.2rem;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .notizie-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
  }

  .hero-section {
    padding: 8rem 0;
  }

  .main-content {
    margin-top: 0; /* evita overlap su desktop */
    padding: 5rem 0;
  }

  .card-image {
    height: 200px;
  }

  .card-title {
    font-size: 1.3rem;
  }

  .card-content {
    padding: 1.5rem;
  }
}

/* Large Desktop */
@media (min-width: 1200px) {
  .container {
    max-width: 1400px;
  }
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate__fadeInUp {
  animation: fadeInUp 0.6s ease-out;
}

.animate__fadeInDown {
  animation: fadeInDown 0.6s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Image Preview Styles */
.image-preview-container {
  border: 2px dashed #dee2e6;
  border-radius: 8px;
  padding: 1rem;
  background: #f8f9fa;
  text-align: center;
  transition: all 0.3s ease;
}

.image-preview-container:hover {
  border-color: var(--primary-color);
  background: rgba(13, 110, 253, 0.05);
}

.image-preview {
  max-width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.image-preview[src="/assets/images/Campo.png"] {
  object-fit: contain;
  background: #fff;
  border: 1px solid #dee2e6;
}

/* Fix: ensure the publish checkbox is clickable (z-index issues on some layouts) */
.card-body .form-check-input {
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.card-body .form-check-label {
  cursor: pointer;
}
/* Single News View Styles */
.notizia-article {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-color);
}

.notizia-article h1,
.notizia-article h2,
.notizia-article h3,
.notizia-article h4,
.notizia-article h5,
.notizia-article h6 {
  color: var(--primary-color);
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.notizia-article p {
  margin-bottom: 1.5rem;
}

.notizia-article img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1rem 0;
  box-shadow: var(--shadow-light);
}

.notizia-article blockquote {
  border-left: 4px solid var(--primary-color);
  padding-left: 1rem;
  margin: 2rem 0;
  font-style: italic;
  color: var(--muted-text);
}

.notizia-immagine img {
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 8px 32px var(--shadow-dark);
}

.social-share {
  background: linear-gradient(
    135deg,
    var(--card-bg) 0%,
    rgba(248, 249, 250, 0.8) 100%
  );
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow-light);
}

.social-share h5 {
  color: var(--primary-color);
  font-weight: 600;
}

.share-btn {
  transition: all 0.3s ease;
  border-radius: 25px;
  font-weight: 500;
}

.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.share-btn[data-platform="facebook"]:hover {
  background-color: #1877f2;
  border-color: #1877f2;
  color: white;
}

.share-btn[data-platform="twitter"]:hover {
  background-color: #1da1f2;
  border-color: #1da1f2;
  color: white;
}

.share-btn[data-platform="whatsapp"]:hover {
  background-color: #25d366;
  border-color: #25d366;
  color: white;
}

.share-btn[data-platform="copy"]:hover {
  background-color: var(--secondary-color);
  border-color: var(--secondary-color);
  color: white;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .hero-section {
    padding: 2rem 0;
  }

  .display-4 {
    font-size: 2.5rem;
  }

  .notizia-article {
    font-size: 1rem;
  }

  .social-share {
    padding: 1.5rem;
  }

  .share-btn {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
  }

  /* Search and Filters Styles */
  .search-filters-card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
  }

  .search-input-group {
    margin-bottom: 1rem;
  }

  .search-button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    box-shadow: 0 6px 25px rgba(13, 110, 253, 0.3);
  }

  .search-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(13, 110, 253, 0.4);
  }

  .search-button .search-text {
    display: inline;
  }

  .filter-select {
    font-size: 0.9rem;
  }

  .active-filters {
    justify-content: center;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .search-button {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
  }

  .search-button .search-text {
    display: none; /* Nasconde il testo su schermi molto piccoli */
  }

  .search-button .bi-search {
    font-size: 1.2rem;
  }

  .search-filters-card {
    padding: 1rem;
  }
}

/* Dark-mode fixes: evita che i testi dei card vengano "tagliati" in modalità scura.
   Alcuni sistemi/renderer possono ridurre il rientro dei discendenti o cambiare
   il rendering dei font in dark mode. Aumentiamo leggermente il line-height e
   aggiungiamo un piccolo padding inferiore per evitare che alcune lettere vengano
   ritagliate quando si usa -webkit-line-clamp / overflow:hidden. */
:root[data-theme="dark"] .card-title {
  line-height: 1.4; /* leggermente più alto per evitare taglio dei discendenti */
  padding-bottom: 0.12rem;
  -webkit-line-clamp: 2;
}

:root[data-theme="dark"] .card-excerpt {
  line-height: 1.6;
  padding-bottom: 0.12rem;
  -webkit-line-clamp: 2;
}

:root[data-theme="dark"] .card-content {
  /* Assicuriamo che il contenuto abbia spazio interno sufficiente */
  padding-bottom: 1.05rem; /* leggero incremento per sicurezza */
}

/* Evita che il contenuto principale sovrapponga e "tagli" la hero title in dark mode */
:root[data-theme="dark"] .hero-section-notizia {
  position: relative; /* già lo è ma rimarcato per sicurezza */
  z-index: 3; /* porta la hero sopra il main-content */
}

:root[data-theme="dark"] .main-content {
  position: relative;
  z-index: 1; /* mantiene il contenuto principale sotto la hero */
}
