/* ============================================================
   Festival Results Engine — fre-style.css
   v1.0.0
   ============================================================ */

/* ── Reset / Base ─────────────────────────────────────────── */
.fre-container *,
.fre-container *::before,
.fre-container *::after {
    box-sizing: border-box;
}

.fre-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
    color: #222;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 16px 48px;
}

/* ============================================================
   SEARCH WRAPPER & STICKY BAR
   ============================================================ */
.fre-search-wrapper {
    position: sticky;
    top: 16px;
    z-index: 9999;
    margin-bottom: 40px;
}

/* Barra principale — Opzione A */
.fre-main-search {
    display: flex;
    align-items: stretch;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 40px;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
    transition: box-shadow .25s ease, border-color .25s ease;
    overflow: visible;
    position: relative;
    width: 100%;
    min-width: 0;
}

.fre-main-search:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,.11);
    border-color: #ccc;
}

/* ── Singolo campo ────────────────────────────────────────── */
.fre-field {
    flex: 1;
    min-width: 0;
    padding: 13px 22px;
    cursor: pointer;
    transition: background .15s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 62px;
    position: relative;
    border-radius: 0;
    overflow: hidden;
}

/* Separatori interni sottili invece di border-right pieno */
.fre-field + .fre-field::before {
    content: '';
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 1px;
    background: #e8e8e8;
}

.fre-field:first-child { border-radius: 40px 0 0 40px; }

.fre-field:hover {
    background: #f8f8f8;
    border-radius: 40px;
    z-index: 1;
}
.fre-field:hover + .fre-field::before,
.fre-field.fre-active + .fre-field::before { opacity: 0; }

.fre-field.fre-active {
    background: #fff;
    border-radius: 40px;
    z-index: 2;
    box-shadow: 0 0 0 2px #BD2E27, 0 0 0 5px rgba(189,46,39,.09);
}

.fre-field-label {
    font-size: 10px;
    font-weight: 700;
    color: #444;
    text-transform: uppercase;
    letter-spacing: .7px;
    margin-bottom: 4px;
}

.fre-field-input {
    border: none;
    background: transparent;
    font-size: 13px;
    color: #888;
    outline: none;
    width: 100%;
    min-width: 0;
    padding: 0;
    font-family: inherit;
}
.fre-field-input::placeholder { color: #bbb; }
.fre-field-input.fre-has-value,
.fre-field-input:focus { color: #111; font-weight: 500; }

.fre-field-value-display {
    font-size: 13px;
    color: #aaa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.fre-field-value-display.fre-has-value { color: #111; font-weight: 500; }

/* ── Bottoni nella barra ──────────────────────────────────── */
.fre-btn-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px 0 4px;
    flex-shrink: 0;
}

.fre-search-btn,
.fre-reset-btn {
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s ease, background .15s ease;
    flex-shrink: 0;
}

.fre-search-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: #9EBF44;
    color: #fff;
}
.fre-search-btn svg { width: 19px; height: 19px; }
.fre-search-btn:hover { background: #8aaa38; transform: scale(1.05); }
.fre-search-btn:active { transform: scale(.95); }

.fre-reset-btn {
    width: 34px;
    height: 34px;
    border: 1px solid #e0e0e0;
    background: #fff;
    color: #888;
}
.fre-reset-btn svg { width: 15px; height: 15px; }
.fre-reset-btn:hover { border-color: #ccc; background: #f5f5f5; color: #333; }

/* ============================================================
   DROPDOWN
   ============================================================ */
.fre-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 20px;
    box-shadow: 0 8px 28px rgba(0,0,0,.09), 0 2px 8px rgba(0,0,0,.05);
    padding: 20px;
    display: none;
    z-index: 99999;
    animation: freDropIn .18s ease-out;
}
.fre-dropdown.fre-dd-open { display: block; }

.fre-dropdown-wide { max-width: 680px; }

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

.fre-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}
.fre-dropdown-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #111;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.fre-dropdown-close {
    width: 28px;
    height: 28px;
    background: #f5f5f5;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #777;
    line-height: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.fre-dropdown-close:hover { background: #eaeaea; color: #222; }

/* ── Griglia opzioni (città / tipologia / sottotipo) ─────── */
.fre-grid-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    max-height: 360px;
    overflow-y: auto;
}

.fre-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 10px;
    border: 1.5px solid #ebebeb;
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .15s;
    background: #fff;
    text-align: center;
    gap: 8px;
}
.fre-option:hover {
    border-color: #BD2E27;
    background: #fef8f8;
    transform: translateY(-1px);
}
.fre-option.fre-selected {
    border-color: #BD2E27;
    background: #fef5f5;
}
.fre-option-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    object-position: center;
    display: block;
}
.fre-option-name {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}
.fre-option.fre-selected .fre-option-name { color: #BD2E27; }
.fre-option.fre-selected .fre-option-img { filter: none; }

/* ── Date picker ─────────────────────────────────────────── */
.fre-date-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
}
.fre-col-title {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* Quick dates */
.fre-quick-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.fre-quick-btn {
    display: block;
    width: 100%;
    text-align: left;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all .18s ease;
    line-height: 1.3;
}
.fre-quick-btn strong { display: block; font-weight: 600; color: #222; }
.fre-quick-btn small  { display: block; color: #777; font-size: 11px; margin-top: 2px; }
.fre-quick-btn:hover {
    border-color: #c5c5c5;
    background: #f9fafb;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.fre-quick-btn.fre-selected {
    border-color: #BD2F27;
    background: #fef5f5;
}
.fre-quick-btn.fre-selected strong { color: #BD2F27; }

/* Datepicker jQuery UI override */
#fre-calendar .ui-datepicker {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: none;
    padding: 12px;
    font-family: inherit;
    font-size: 13px;
    width: 100%;
}
#fre-calendar .ui-datepicker-header {
    background: none;
    border: none;
    font-weight: 600;
    color: #111;
    padding: 6px 0 12px;
}
#fre-calendar .ui-datepicker table { width: 100%; border-collapse: separate; border-spacing: 3px; }
#fre-calendar .ui-datepicker td { padding: 0; }
#fre-calendar .ui-datepicker td a,
#fre-calendar .ui-datepicker td span {
    display: block;
    text-align: center;
    padding: 6px 4px;
    border-radius: 6px;
    font-size: 13px;
    color: #333;
    text-decoration: none;
    transition: background .15s;
}
#fre-calendar .ui-datepicker td a:hover { background: #f3f4f6; }
#fre-calendar .ui-datepicker td.fre-weekend a { background: #fff8f0; color: #c05c0a; font-weight: 600; }
#fre-calendar .ui-datepicker td.fre-in-range a { background: #fef0f0; }
#fre-calendar .ui-datepicker td.fre-range-edge a,
#fre-calendar .ui-state-active { background: #BD2F27 !important; color: #fff !important; border-radius: 6px; }
#fre-calendar .ui-datepicker th { font-size: 11px; color: #888; font-weight: 600; padding: 4px; text-align: center; }
#fre-calendar .ui-datepicker .ui-datepicker-prev,
#fre-calendar .ui-datepicker .ui-datepicker-next {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    width: 28px; height: 28px;
    cursor: pointer;
}

.fre-cal-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.fre-cal-btn {
    flex: 1;
    padding: 9px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all .15s;
}
.fre-cal-btn:hover { background: #f3f4f6; }
.fre-cal-btn-primary {
    background: #111;
    border-color: #111;
    color: #fff;
}
.fre-cal-btn-primary:hover { background: #333; border-color: #333; }

/* ============================================================
   SEZIONE RISULTATI
   ============================================================ */
.fre-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}
.fre-results-count { font-size: 15px; color: #444; }
.fre-results-count strong { color: #111; font-weight: 700; }
.fre-results-count em { color: #BD2F27; font-style: normal; }

.fre-clear-link {
    background: none;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}
.fre-clear-link:hover { background: #f3f4f6; border-color: #aaa; color: #222; }

/* ── Card Grid ────────────────────────────────────────────── */
.fre-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 28px;
}

/* ── Singola card ─────────────────────────────────────────── */
.fre-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
    transition: transform .22s ease, box-shadow .22s ease;
}
.fre-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 36px rgba(0,0,0,.13);
}

/* Immagine */
.fre-card-media {
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #f0f0f0;
    flex-shrink: 0;
    position: relative;
}
.fre-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .35s ease;
}
.fre-card:hover .fre-card-img { transform: scale(1.05); }

.fre-card-no-img {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 56px;
    color: #ccc;
}

/* Badge tipologia — sovrapposto sull'immagine */
/* Overlay badge — indipendente da overflow:hidden del parent */
.fre-badge-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    pointer-events: none !important;
    z-index: 20 !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    padding: 14px !important;
}

.fre-badge {
    pointer-events: auto;
    display: inline-block;
    font-family: 'Lato', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .3px;
    color: #fff !important;
    border-radius: 28px;
    padding: 5px 12px;
    text-transform: capitalize;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

/* Body card */
.fre-card-body {
    padding: 18px 18px 14px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
}

.fre-card-title {
    font-family: 'Lato', sans-serif;
    font-size: 17px;
    font-weight: 800;
    color: #222323;
    margin: 0;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fre-card-excerpt {
    font-size: 13px;
    color: #666;
    line-height: 1.55;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Info: luogo, data, durata */
.fre-card-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 4px;
}
.fre-card-luogo,
.fre-card-date,
.fre-card-durata {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #777;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
}
.fre-card-luogo {
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .4px;
    color: #555;
    text-transform: uppercase;
}
.fre-card-luogo svg,
.fre-card-date svg,
.fre-card-durata svg { flex-shrink: 0; color: #aaa; }

/* Footer: disponibilità */
.fre-card-footer {
    display: flex;
    align-items: center;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

/* Disponibilità */
.fre-disp {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
}
.fre-disp-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}
.fre-disp-ended { color: #888; }
.fre-disp-ended .fre-disp-dot { background: #aaa; }
.fre-disp-none  { color: #c0392b; }
.fre-disp-none  .fre-disp-dot { background: #FF0000; }
.fre-disp-few   { color: #e67e22; }
.fre-disp-few   .fre-disp-dot { background: #FFA500; }
.fre-disp-ok    { color: #027a00; }
.fre-disp-ok    .fre-disp-dot { background: #029100; }


/* ── Loading ──────────────────────────────────────────────── */
.fre-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 64px 20px;
    grid-column: 1 / -1;
    font-size: 15px;
    color: #888;
}
.fre-loading-inline { padding: 24px; }
.fre-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f0f0f0;
    border-top-color: #BD2F27;
    border-radius: 50%;
    animation: freSpin .8s linear infinite;
    flex-shrink: 0;
}
@keyframes freSpin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────────────────────── */
.fre-empty-state {
    text-align: center;
    padding: 64px 20px;
    grid-column: 1 / -1;
}
.fre-empty-icon { font-size: 56px; margin-bottom: 16px; }
.fre-empty-state h3 { font-size: 22px; font-weight: 700; color: #222; margin: 0 0 10px; }
.fre-empty-state p  { font-size: 15px; color: #777; line-height: 1.5; margin: 0 auto 24px; max-width: 440px; }

.fre-btn-secondary {
    background: none;
    border: 1.5px solid #333;
    border-radius: 8px;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    font-family: inherit;
    transition: all .15s;
}
.fre-btn-secondary:hover { background: #333; color: #fff; }

/* ── Load more ────────────────────────────────────────────── */
.fre-load-more-wrap {
    text-align: center;
    margin-top: 36px;
}
.fre-load-more-btn {
    background: #fff;
    border: 1.5px solid #333;
    border-radius: 10px;
    padding: 13px 36px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    font-family: inherit;
    transition: all .18s;
}
.fre-load-more-btn:hover { background: #333; color: #fff; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .fre-main-search {
        flex-direction: column;
        border-radius: 16px;
        overflow: hidden;
    }
    .fre-field {
        border-radius: 0;
        min-height: 54px;
        padding: 12px 18px;
    }
    .fre-field + .fre-field::before {
        top: 0; bottom: 0; width: 100%; height: 1px; left: 0;
        background: #f0f0f0;
    }
    .fre-field:hover { border-radius: 0; }
    .fre-field.fre-active {
        border-radius: 0;
        box-shadow: inset 0 0 0 2px #BD2E27;
    }
    .fre-btn-group {
        padding: 10px 12px;
        justify-content: space-between;
    }
    .fre-search-btn {
        flex: 1;
        border-radius: 10px;
        height: 44px;
        width: auto;
    }
    .fre-dropdown { border-radius: 14px; top: calc(100% + 6px); }
    .fre-dropdown-wide { max-width: 100%; }
    .fre-date-grid { grid-template-columns: 1fr; gap: 20px; }
    .fre-quick-dates { grid-template-columns: 1fr 1fr; }
    .fre-results-grid { grid-template-columns: 1fr; gap: 16px; }
    .fre-results-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .fre-search-wrapper { top: 8px; }
}

@media (max-width: 480px) {
    .fre-container { padding: 0 10px 32px; }
    .fre-grid-options { grid-template-columns: repeat(2, 1fr); }
    .fre-card-body { padding: 14px; }
}

/* ── Accessibility ────────────────────────────────────────── */
.fre-field:focus-within {
    outline: 2px solid #BD2F27;
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* ── Campo ricerca testo ──────────────────────────────────── */
.fre-field-search {
    flex: 1.4;
    cursor: text;
    justify-content: center;
}

.fre-field-search .fre-field-input {
    cursor: text;
    font-size: 13px;
}

.fre-field-search.fre-active {
    box-shadow: 0 0 0 2px #BD2E27, 0 0 0 5px rgba(189,46,39,.09);
}

@media (max-width: 768px) {
    .fre-field-search { flex: unset; }
}

/* ── Mobile overlay ───────────────────────────────────────── */
.fre-mob-overlay {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
body.fre-mob-open { overflow: hidden !important; position: fixed !important; width: 100% !important; }

.fre-mob-header {
    flex-shrink: 0;
    padding: 16px 16px 18px;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
    background: #fff;
    z-index: 10;
}
.fre-mob-close {
    position: absolute;
    top: 14px; right: 14px;
    width: 36px; height: 36px;
    border: 1.5px solid #e5e7eb;
    border-radius: 50%;
    background: #f9fafb;
    cursor: pointer;
    font-size: 20px;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.fre-mob-header h4 {
    font-size: 18px;
    font-weight: 700;
    color: #111;
    margin: 14px 0 0;
    padding-right: 50px;
}
.fre-mob-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.fre-mob-footer {
    flex-shrink: 0;
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
}
.fre-mob-btn-cancel, .fre-mob-btn-apply {
    flex: 1;
    padding: 14px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    border: none;
}
.fre-mob-btn-cancel { background: #f3f4f6; color: #444; border: 1.5px solid #e5e7eb; }
.fre-mob-btn-apply  { flex: 2; background: #BD2E27; color: #fff; }
.fre-mob-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 68px;
    font-size: 16px;
    font-weight: 600;
    color: #111;
}
.fre-mob-option:active { background: #fef8f8; }

/* ── Header risultati actions ─────────────────────────────── */
.fre-results-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Toggle switch */
.fre-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.fre-toggle-track {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    background: #ddd;
    border-radius: 11px;
    transition: background .2s ease;
    flex-shrink: 0;
}
.fre-toggle-track input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.fre-toggle-track input:checked + .fre-toggle-thumb { transform: translateX(16px); }
.fre-toggle-track:has(input:checked) { background: #029100; }
.fre-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.fre-toggle-label {
    font-size: 13px;
    font-weight: 500;
    color: #444;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .fre-results-actions { flex-wrap: wrap; gap: 10px; }
}

/* ── Icona sottotipo sulla card ───────────────────────────── */
.fre-card-subtype {
    position: absolute !important;
    bottom: 10px !important;
    right: 10px !important;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,.92);
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.15);
    z-index: 10;
}
.fre-card-subtype-img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    display: block;
}
