/*============================================
  STILE.CSS - FOGLIO DI STILE SITO PUBBLICO
  ============================================*/


/*--------------------------------------------
  2. STILI GLOBALI E FONDAMENTALI
  --------------------------------------------*/
html {
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    margin: 0;
    padding-top: 50px; /* Spazio per la navbar */
    font-family: Arial, sans-serif;
    background-color: var(--colore-sfondo);
    color: var(--colore-testo);
    max-width: 100%;
    /* Stili per il contenitore principale: */
    /* .e.g., max-width: 1200px;
    margin: 0 auto; */
}

a {
    text-decoration: none;
    color: var(--colore-link);
}

a:hover {
    text-decoration: underline;
    color: var(--colore-link-hover);
}

h1, h2, h3 {
    color: var(--colore-primario);
    margin-bottom: 0.3rem;
}

/* --- Immagini Responsive --- */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Regola per le immagini dei box articoli, per sicurezza */
.articolo-box img {
    width: 100%;
    height: auto;
    object-fit: cover;
    margin-bottom: 5px;
}

/* Regola per l'immagine del banner quando non è un carosello */
.banner-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/*------------------------------------------------------
  3. LAYOUT PRINCIPALE E A COLONNE
  ------------------------------------------------------*/
.container-layout {
    display: flex;
    gap: 13px;
    margin: 13px auto;
    padding: 0 13px;
    align-items: flex-start;
}

.colonna-laterale {
    flex: 0 0 250px;
    padding: 15px;
    background-color: var(--colore-box-bg);
    border-radius: 8px;
    box-shadow: 0 3px 5px rgba(0,0,0,0.1);
    min-height: 100%;
    display: flex;
    flex-wrap: wrap;
}

.contenuto-principale {
    flex-grow: 1;
    padding: 21px;
    background-color: var(--colore_sfondo_contenuto_pubblico, var(--colore-box-bg));
    border-radius: 8px;
    box-shadow: 0 3px 5px rgba(0,0,0,0.1);
    min-height: 100%;
}

/*------------------------------------------------------
  5. COMPONENTI (PULSANTI PUBBLICI, FORM, MODALI)
  ------------------------------------------------------*/
/* Pulsanti Generali */
.btn, button.btn, input[type="submit"].btn {
    display: inline-block;
    padding: 5px 13px;
    font-weight: 600;
    font-size: 14px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.3s ease;
    margin-right: 8px;
    color: #fff;
    background-color: #007bff;
}
.btn:hover, .btn-primary:hover {
    background-color: #0056b3;
}
.btn-primary { background-color: var(--colore-primario); }
.btn-primary:hover { background-color: #005fa3; }
.btn-success { background-color: var(--colore-btn-success); }
.btn-success:hover { background-color: #218838; }
.btn-danger { background-color: var(--colore-btn-danger); }
.btn-danger:hover { background-color: #bd2130; }
.btn-secondary {
    background-color: #6c757d;
    color: #fff;
}
.btn-secondary:hover {
    background-color: #5a6268;
}

/* Form Generici */
.form-cerca, form {
    margin-bottom: 1rem;
}
.form-cerca input[type="text"],
form input[type="text"],
form input[type="number"],
form select,
form textarea {
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 0.3rem;
    font-size: 0.9rem;
    font-family: Calibri, sans-serif;
    width: 250px;
    max-width: 100%;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
}
form textarea {
    resize: vertical;
    width: 100% !important;
    max-width: 400px;
}
form label {
    vertical-align: middle;
    font-weight: 400;
    display: block;
    margin-bottom: 0.1rem;
    margin-top: 0.3rem;
    font-size: 0.8rem;
}

/* Modali Login / Register */
.modal {
    display: none;
    position: fixed;
    z-index: 300;
    padding-top: 21px;
    left: 0; top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}
.modal-content {
    background-color: var(--colore-cpanel-bg); /* Mantenuto per coerenza con il colore di sfondo del modale */
    margin: 8% auto;
    padding: 8px;
    border-radius: 5px;
    width: 90%;
    max-width: 340px;
    position: relative;
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
}
.modal-content h2 {
    text-align: center;
    color: var(--colore-primario); /* Usato primario come fallback */
    margin-top: 0;
    font-size: 24px;
}
.modal-content input {
    width: 100%;
    padding: 3px 6px 9px 2px;
    margin: 8px 0;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 5px;
}
.modal-content button {
    width: 70%;
    padding: 8px;
    background-color: #007bff;
    border: none;
    color: white;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    margin-left: 15%;
    margin-right: 15%;
    margin-top: 0px;
    text-align: center;
}
.modal-content .close {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 26px;
    color: #999;
    font-weight: bold;
    cursor: pointer;
}
.modal-content .close:hover {
    color: #000;
}
#loginMessage, #registerMessage {
    text-align: center;
    margin-top: 10px;
    color: red;
    font-weight: bold;
}
.login-message, .login-message-tb {
    background-color: #dff0d8;
    color: #3c763d;
    border: 0.8px solid #d6e9c6;
    padding: 13px;
    border-radius: 8px;
    margin-top: 15px;
    margin-bottom: 5px;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    opacity: 1;
    animation: fadeOut 3s 13s forwards;
}
.login-message {
    width: 20px;
}
.login-message-tb {
    width: 33%;
}
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; display: none; }
}

/*------------------------------------------------------
  6. BANNER & BOX (CAROUSEL & GRID)
  ------------------------------------------------------*/
.banner {
    background-size: cover;
    background-position: center;
    height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.6);
    position: relative;
    width: 100%;
}
.banner h1 {
    font-size: 2.5rem;
    margin: 0px;
}
.banner p {
    margin: 0px;
}
.banner-carousel {
    position: relative;
    width: 100%;
    height: 300px;
    overflow: hidden;
}
.carousel-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}
.carousel-item.active {
    opacity: 1;
}
.carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.carousel-caption {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 15px;
    border-radius: 8px;
}
.carousel-control {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    padding: 10px;
    cursor: pointer;
    z-index: 10;
}
.carousel-control.prev { left: 10px; }
.carousel-control.next { right: 10px; }
.carousel-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}
.dot {
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    cursor: pointer;
}
.dot.active { background: #fff; }

/* Box Section */
.box-sito-pubblico {
    margin-top: -100px;
    position: relative;
    z-index: 5;
}
.box-container {
    width: 100%;
    display: flex;
    gap: 34px;
    padding: 21px;
    justify-content: center;
    background: #fff;
    flex-wrap: wrap;
}
.box-container .box img {
    width: 100%;
    height: auto;
    display: block;
    margin: 10 auto;
}
.enne-box {
    background-color: var(--colore-box-bg);
    color: var(--colore-box-testo);
    display: flex;
    gap: 0.8rem;
    padding: 8px 5px;
    justify-content: space-between;
    flex-wrap: wrap;
    margin: 0.5rem 0;
    align-items: stretch;
}
.box {
    flex-grow: 0;
    flex-shrink: 0;
    box-sizing: border-box;
    background: white;
    background-size: cover;
    background-position: center;
    border-radius: 12px;
    padding: 5px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    color: #fff;
    min-height: 210px;
}
.box-auto {
    flex: 1 1 0;
    width: auto !important;
    flex-basis: auto !important;
}
.box-25 { flex-basis: calc(25% - (3 * 1.3rem / 4)); }
.box-33 { flex-basis: calc(33.333% - (2 * 1.3rem / 3)); }
.box-50 { flex-basis: calc(50% - (1 * 1.3rem / 2)); }
.box-100 { flex-basis: 100%; }
.box.with-image {
    background-size: cover;
    background-repeat: no-repeat;
}
.box.with-image .icon,
.box.with-image h3,
.box.with-image p,
.box.with-image .btn-box {
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}
.box .icon {
    font-size: 2.1rem;
    margin-bottom: 0.1rem;
    color: #ff6600;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}
.box h3 {
    font-size: 1.0rem;
    margin: 0.1rem 0;
}
.box p {
    font-size: 1.0rem;
    margin: 0.2rem 0;
    color: #555;
}
.enne-box .btn-box {
    margin: 0 auto;
    margin-top: auto;
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background-color: #007acc;
    color: #fff;
    text-decoration: none;
    border-radius: 5px;
    max-width: 89px;
}
.enne-box .btn-box:hover,
.enne-box .btn-box:focus {
    background-color: #005fa3;
}

/*------------------------------------------------------
  7. ARTICOLI E PAGINAZIONE
  ------------------------------------------------------*/
.sezione-articoli {
    padding: 2rem;
}

.articolo-singolo {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #eee;
    gap: 1.5rem;
}
.articolo-singolo .articolo-immagine-principale {
    max-width: 40%;
    height: min-content;
    object-fit: cover;
    float: left; margin-right: 13px;
}
.articolo-singolo .text-container {
    font-size: 1.3rem;
    font-family: Arial, sans-serif;
}
.anteprima-articolo-con-immagine {
    display: flex;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #eee;
    gap: 1.5rem;
}
.anteprima-articolo-con-immagine .articolo-img {
    width: 33%;
    max-width: 250px;
    height: auto;
    flex-shrink: 0;
    object-fit: cover;
}
.anteprima-articolo-con-immagine .articolo-info {
    flex-grow: 1;
}
.anteprima-articolo-con-immagine h2,
.anteprima-articolo-con-immagine h3 {
    margin: 0 0 0.5rem 0;
}
.anteprima-articolo-con-immagine p {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
}
.paginazione {
    margin-top: 1rem;
    font-size: 0.92rem;
}
.paginazione a {
    text-decoration: none;
    padding: 4px 8px;
    color: #007acc;
    border: 1px solid transparent;
    margin: 0 3px;
    border-radius: 3px;
    transition: background-color 0.3s ease;
}
.paginazione a:hover,
.paginazione a:focus {
    background-color: #cce5ff;
    border-color: #007acc;
}
.paginazione strong {
    padding: 4px 8px;
    background-color: #007acc;
    color: #fff;
    border-radius: 3px;
    margin: 0 3px;
}
.articolo-dettaglio {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 0;
}
.immagine-articolo-principale {
    margin: 0 -2rem 2rem;
    line-height: 0;
}
.immagine-articolo-principale img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}
.immagine-articolo-principale figcaption {
    font-size: 0.8rem;
    text-align: center;
    color: #666;
    margin-top: 0.5rem;
}
.titolo-articolo {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}
.articolo-meta {
    color: #888;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
.contenuto-formattato {
    line-height: 1.6;
    font-size: 1.1rem;
    color: var(--colore-testo);
}
/* ------NUOVA STESURA 33 - 30 AGO --------------------*/
.articoli-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin: 20px 0;
}
.articolo-card {
  background: var(--colore-box-bg);
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease-in-out;
}
.articolo-card:hover {
  transform: translateY(-4px);
}
.articolo-card.popolare {
  border: 2px solid var(--colore_btn_success);
}
.articolo-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}
.articolo-card .card-body {
  padding: 15px;
}
.articolo-card h3 {
  margin-top: 0;
  font-size: 1.2em;
  color: var(--colore-box-titolo);
}
.articolo-card h3 a {
  text-decoration: none;
  color: inherit;
}
.articolo-card .data {
  font-size: 0.85em;
  color: #777;
}
.articolo-card p {
  font-size: 0.95em;
  margin: 10px 0;
  color: var(--colore-box-testo);
}
.articolo-card .btn {
  display: inline-block;
  background: var(--colore_btn_success);
  color: #fff;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.9em;
}
.articolo-card .btn:hover {
  background: var(--colore_btn_danger);
}
.badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 0.75em;
  border-radius: 4px;
  margin-right: 6px;
}
.badge-warning {
  background: orange;
  color: white;
}

/* Stile singolo articolo */
.articolo-singolo {
  max-width: 800px;
  margin: 20px auto;
}
.articolo-singolo img.articolo-immagine-principale {
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 15px;
}
.articolo-singolo h1 {
  color: var(--colore-box-titolo);
  margin-bottom: 10px;
}
.articolo-singolo .articolo-data {
  font-size: 0.9em;
  color: #666;
  margin-bottom: 20px;
}
.articolo-singolo .contenuto-formattato {
  font-size: 1em;
  line-height: 1.6;
  color: var(--colore-box-testo);
}

/*------------------------------------------------------
  9. RESPONSIVE (PUBLIC)
  ------------------------------------------------------*/
@media (max-width: 768px) {
    .container-layout {
        flex-direction: column;
    }
    .colonna-laterale {
        flex: 1 1 auto;
    }
    .anteprima-articolo-con-immagine {
        flex-direction: column;
        align-items: center;
    }
    .anteprima-articolo-con-immagine .articolo-img {
        width: 100%;
        margin-bottom: 1rem;
    }
    .enne-box .box {
        flex-basis: 100% !important;
        width: 100% !important;
    }
}

