﻿/* --- Base / brand --- */
:root {
    --brand: #00a084; /* primario IFM */
    --brand-2: #00c3a5; /* accento */
    --ink: #333;
    --muted: #6d6d6d;
    --card-bg: #ffffffcc;
    --chip: #f2f4f5;
}

.bandi-title {
    font-family: "Merriweather";
    font-weight: 400;
    font-size: 42px;
    margin: 0;
    color: var(--brand);
}

.bandi-subtitle {
    font-family: "Chivo";
    font-weight: 400;
    color: var(--muted);
    margin-top: 8px;
}

#bandi-hero {
    background: linear-gradient(rgba(0,0,0,.00),rgba(0,0,0,.00));
}

/* --- Filters --- */
.bandi-filters {
    z-index: 8;
    background: transparent;
    padding: 8px 0 0;
    top: 82px; /* allineato alla navbar */
}

@media (max-width: 992px) {
    .bandi-filters {
        top: 96px;
    }
}

.filters-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
    background: var(--card-bg);
    padding: 16px 24px;
    margin: 24px 50px;
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
}

@media (max-width: 992px) {
    .filters-row {
        grid-template-columns: 1fr;
        gap: 12px;
        margin: 16px;
    }
}

.chips {
    display: flex;
    gap: 10px;
    overflow: auto;
    padding-bottom: 8px;
}

.chip {
    font-family: "Montserrat";
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    padding: 10px 14px;
    border: 1px solid #e5e8ea;
    background: #fff;
    color: var(--ink);
    transition: .2s;
}

    .chip:hover {
        border-color: var(--brand-2);
        color: var(--brand);
    }

    .chip.is-active {
        background: var(--brand);
        color: #fff;
        border-color: var(--brand);
    }

.filter-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    min-width: 260px;
    flex: 1;
}

.search-input {
    width: 100%;
    height: 44px;
    border: 1px solid #e5e8ea;
    padding: 0 12px;
    font-family: "Chivo";
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: .6;
}

.select {
    height: 44px;
    border: 1px solid #e5e8ea;

    padding: 0 12px;
    min-width: 220px;
    font-family: "Chivo";
}

.btn-green {
    height: 44px;
    padding: 0 16px;

    background: var(--brand);
    color: #fff;
    border: 1px solid var(--brand);
    font-family: "Montserrat";
    font-weight: 600;
}

    .btn-green:hover {
        filter: brightness(1.05);
    }

/* --- Grid --- */
.bandi-grid {
    display: grid;
    grid-template-columns: repeat(3,1fr);
    gap: 24px;
    margin: 32px 50px;
}

@media (max-width: 1200px) {
    .bandi-grid {
        grid-template-columns: repeat(2,1fr);
        margin: 24px;
    }
}

@media (max-width: 600px) {
    .bandi-grid {
        grid-template-columns: 1fr;
        margin: 16px;
    }
}

/* --- Card --- */
.bando-card {
    display: flex;
    flex-direction: column;
    min-height: 320px;
    background: var(--card-bg);

    overflow: hidden;
    box-shadow: 0 10px 26px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.08);
}

.bando-card__head {
    padding: 14px 16px 0;
}

.bando-card__image > img{
    width: 100%   
}

.bando-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.bando-meta__pill {
    background: var(--brand);
    color: #fff;

    padding: 6px 10px;
    font-size: 12px;
    font-family: "Montserrat";
    font-weight: 600;
}

.bando-meta__tag {
    background: #eef7f5;
    border: 1px solid #d0efe8;
    color: var(--brand);

    padding: 6px 10px;
    font-size: 12px;
    font-family: "Montserrat";
}

.bando-card__body {
    padding: 12px 16px 0;
}

.bando-title {
    font-family: "Montserrat";
    font-weight: 600;
    color: var(--ink);
    font-size: 20px;
    margin: 0 0 6px;
}

.bando-desc {
    font-family: "Chivo";
    color: #444;
    margin: 0 0 8px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bando-card__footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between; /* stats a sinistra, bottoni a destra */
    align-items: flex-end; /* allinea entrambi al fondo */
    gap: 12px;
    padding: 16px;
    border-top: 1px solid #e9eef0;
}

.bando-stat {
    padding: 10px;
}

.bando-stats {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.bando-card__footer-btn {
    margin-left: auto; /* li spinge a destra */
    align-self: flex-end; /* resta in basso */
    display: flex; /* li mette in riga */
    gap: 8px; /* spazio orizzontale fra bottoni */
}

.btn-delete {
    color: red !important;
    background-color: none !important;
    border-color: red !important;
}

    .btn-delete:hover {
        color: white !important;
        background-color: red !important;
        border-color: red !important;
    }


.stat-label {
    font-size: 11px;
    color: var(--muted);
    font-family: "Chivo";
}

.stat-value {
    font-size: 14px;
    color: var(--ink);
    font-family: "Chivo";
}

.btn-outline {
    display: inline-block;
    border: 1px solid var(--brand);
    color: var(--brand);
    padding: 10px 14px;

    text-decoration: none;
    font-family: "Montserrat";
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: 
        background-color 0.35s ease,
        color 0.35s ease,
        border-color 0.35s ease
}

    .btn-outline:hover {
        background: var(--brand);
        color: #fff;
    }

.empty-state {
    grid-column: 1/-1;
    background: #fff;

    padding: 32px;
    text-align: center;
    color: var(--muted);
    font-family: "Chivo";
}

.btn-create-bando {
    position: fixed;
    right: 24px;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px)); /* iPhone notch safe */
    z-index: 1050; /* sopra il contenuto */

    padding: 10px 16px;
    box-shadow: 0 10px 24px rgba(0,0,0,.18), 0 6px 12px rgba(0,0,0,.12);
    font-weight: 600;
}

/* === Layout fix solo per pagina Bandi === */
/* il body della pagina bandi gestisce lo sticky footer */
body.page-bandi {
    display: flex;
    flex-direction: column;
    min-height: 100dvh; /* viewport reale, niente buchi */
    margin-bottom: 0 !important; /* annulla site.css (60px) */
}

    /* il main della pagina si espande, il footer resta in fondo */
    body.page-bandi main {
        flex: 1 0 auto;
    }

    /* il footer deve stare nel flusso, non absolute */
    body.page-bandi .footer {
        position: static !important;
        bottom: auto !important;
        margin: 0 !important;
        flex-shrink: 0;
    }

    /* distanza dal menu fixed-top (circa 70px) */
    body.page-bandi #bandi-hero {
        padding-top: 82px;
    }
    /* 70 + 12 di aria */
    body.page-bandi .bandi-filters {
        top: 82px;
    }

/* === Layout fix solo per pagina Bandi (definitivo) === */
body.page-bandi {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    margin-bottom: 0 !important; /* override site.css */
}

    /* Il wrapper che contiene <main> deve partecipare al flex del body */
    body.page-bandi > .container-fluid {
        flex: 1 0 auto;
        display: flex;
        flex-direction: column;
        padding: 0; /* già p-0 da layout, qui è difensivo */
    }

        /* Ora il <main> del layout può espandersi */
        body.page-bandi > .container-fluid > main {
            flex: 1 0 auto;
        }

    /* Footer nel flusso (override del site.css dove è absolute) */
    body.page-bandi .footer {
        position: static !important;
        bottom: auto !important;
        margin: 0 !important;
        flex-shrink: 0;
    }

    /* Offset dal menu fixed-top */
    body.page-bandi #bandi-hero {
        padding-top: 82px;
        
    }

    body.page-bandi .bandi-filters {
        top: 82px;
    }

main.page-bandi {
    background: linear-gradient( rgba(0, 0, 0, 0.75), /* colore scuro sopra */
    rgba(0, 0, 0, 0.5) );
}


/* === Offset affidabile rispetto alla navbar fixed === */
:root {
    --nav-h: 150px; /* imposta qui l’altezza "percepita" della tua navbar su desktop */
}

/* mobile/tablet: di solito la navbar è più alta */
@media (max-width: 992px) {
    :root {
        --nav-h: 108px;
    }
}

/* Applica l’offset al titolo/hero e ai filtri sticky SOLO nella pagina Bandi */
body.page-bandi #bandi-hero {
    padding-top: calc(var(--nav-h) + 16px); /* un po’ di aria extra sotto la barra */
}

body.page-bandi .bandi-filters {
    top: var(--nav-h);
}





/* --- AREA PREVIEW IMMAGINE (CREATE) --- */
:root {
    /* Larghezza massima desktop della box di crop */
    --crop-w: 720px;
    /* In mobile useremo vw, vedi media query più sotto */
}

.bando-image-wrap {
    position: relative;
    width: 100%;
    max-width: var(--crop-w);
    /* Mantieni SEMPRE 16:9 */
    aspect-ratio: 16 / 9;
    background: #f2f3f5; /* il “riquadro grigio” */
    border: 1px dashed #cfd3d7;
    border-radius: 8px;
    overflow: hidden; /* niente overflow nel modal */
    margin: 0 auto; /* centrata nella colonna */
}

/* L’immagine è gestita da Cropper.js, ma prima che parta… */
#cropperImage {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain; /* non deformare mai */
}

/* Forza il contenitore generato da Cropper a riempire la box */
.bando-image-wrap .cropper-container {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
}

/* Non far uscire la modale: se il contenuto è lungo, scrolla il body */
#createBandoModal .modal-dialog.modal-xl.modal-dialog-scrollable,
#createBandoModal .modal-content,
#createBandoModal .modal-body {
    max-height: 90vh;
}

#createBandoModal .modal-body {
    overflow: auto;
}

/* Mobile: la box scala ma resta coerente */
@media (max-width: 576px) {
    :root {
        --crop-w: 92vw;
    }
    /* occupa quasi tutta la larghezza */
}



.btn-reset {
    width: 100%;
    margin-top: 5%;
}

.btn-standard {
    background-color: #00a084;
    color: white;
    border-color: #00a084;
    transition: all 0.35s ease;
}

    .btn-standard:hover {
        background-color: white;
        color: #00a084;
        border-color: #00a084;
    }

    select {
        cursor: pointer;
    }

    @media (max-width: 576px){
        select {
            width: 100%;
        }

    }
