/* ==========================================================================
   ANXA 2.0 - TERRITORI E COMUNI DEL FRENTANO (css/territori.css)
   Visualizzazione a Riquadri: Card compattate in griglia con dati sintetici
   ========================================================================== */

/* Introduzione */
.territori-intro-section {
    margin-bottom: 24px;
}

.territori-intro-title {
    font-size: 1.75rem;
    font-weight: 900;
    color: #0033A0;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

html.rossonero-mode .territori-intro-title {
    color: var(--yellow-anxa);
}

.territori-intro-desc {
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--text-main);
    opacity: 0.95;
    margin-bottom: 0;
}

/* Barra Cerca & Filtri */
.territori-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 6px 16px;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.territori-search-box:focus-within {
    border-color: #0033A0;
    box-shadow: 0 0 0 3px rgba(0, 51, 160, 0.15);
}

html.rossonero-mode .territori-search-box:focus-within {
    border-color: var(--yellow-anxa);
    box-shadow: 0 0 0 3px rgba(255, 213, 79, 0.2);
}

.territori-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    padding: 8px 0;
}

.territori-search-input::placeholder {
    color: var(--text-main);
    opacity: 0.65;
}

.territori-filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
}

.territori-filter-tab {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-main);
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.territori-filter-tab:hover {
    border-color: #0033A0;
}

html.rossonero-mode .territori-filter-tab:hover {
    border-color: var(--yellow-anxa);
}

.territori-filter-tab.active {
    background: #0033A0;
    color: #ffffff;
    border-color: #0033A0;
    box-shadow: 0 4px 12px rgba(0, 51, 160, 0.3);
}

html.rossonero-mode .territori-filter-tab.active {
    background: var(--yellow-anxa);
    color: #000000;
    border-color: var(--yellow-anxa);
    box-shadow: 0 4px 12px rgba(255, 213, 79, 0.4);
}

/* Griglia Responsive Riquadri Comuni */
.comuni-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 480px) {
    .comuni-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 850px) {
    .comuni-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1200px) {
    .comuni-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Card Riquadro Comune */
.comune-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0,0,0,0.06);
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
    height: auto;
}

.comune-card:hover {
    border-color: #0033A0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

html.rossonero-mode .comune-card:hover {
    border-color: var(--yellow-anxa);
}

.comune-card.highlight {
    border-color: var(--yellow-anxa);
    box-shadow: 0 0 0 3px var(--yellow-anxa);
}

/* Header Riquadro Cliccabile (Stato Chiuso) */
.comune-card-header {
    padding: 16px;
    cursor: pointer;
    user-select: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(0, 0, 0, 0.02);
    flex: 1;
}

.comune-card.open .comune-card-header {
    background: rgba(0, 51, 160, 0.05);
    border-bottom: 1px dashed var(--border-color);
}

html.rossonero-mode .comune-card.open .comune-card-header {
    background: rgba(255, 213, 79, 0.06);
}

.comune-top-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.comune-name {
    font-size: 1.25rem;
    font-weight: 900;
    color: #0033A0;
    margin: 0;
    line-height: 1.2;
}

html.rossonero-mode .comune-name {
    color: var(--yellow-anxa);
}

.btn-share-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 51, 160, 0.08);
    color: #0033A0;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}

.btn-share-icon:hover {
    background: #0033A0;
    color: #ffffff;
    transform: scale(1.1);
}

html.rossonero-mode .btn-share-icon {
    background: rgba(255, 213, 79, 0.12);
    color: var(--yellow-anxa);
}

html.rossonero-mode .btn-share-icon:hover {
    background: var(--yellow-anxa);
    color: #000000;
}

.btn-share-icon svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.comune-area-label {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 10px;
    background: rgba(0, 51, 160, 0.08);
    color: #0033A0;
    align-self: flex-start;
}

html.rossonero-mode .comune-area-label {
    background: rgba(255, 213, 79, 0.15);
    color: var(--yellow-anxa);
}

/* Griglia Sintetica Informazioni nel Riquadro */
.comune-info-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(255,255,255,0.4);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 10px;
    padding: 10px;
    margin-top: 4px;
}

html.rossonero-mode .comune-info-grid {
    background: rgba(0,0,0,0.3);
    border-color: rgba(255,255,255,0.08);
}

.info-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 0.78rem;
}

.info-cell-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    opacity: 0.75;
}

.info-svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    opacity: 0.85;
}

.info-cell-val {
    font-weight: 800;
    color: var(--text-main);
    text-align: right;
}

/* Indicatore Espansione */
.comune-expand-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    font-weight: 800;
    color: #0033A0;
    opacity: 0.85;
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px dashed var(--border-color);
}

html.rossonero-mode .comune-expand-bar {
    color: var(--yellow-anxa);
}

.comune-chevron {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.comune-card.open .comune-chevron {
    transform: rotate(180deg);
}

/* Corpo Card Espansa */
.comune-body {
    display: none;
    padding: 16px;
    background: var(--card-bg);
}

.comune-card.open .comune-body {
    display: block;
}

/* Griglia dei 5 Pulsanti */
.comune-buttons-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.btn-comune-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    text-align: center;
}

.btn-comune-action svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    flex-shrink: 0;
}

.btn-comune-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

/* Stili Pulsanti */
.btn-maps {
    background: #0033A0;
    color: #ffffff;
}

html.rossonero-mode .btn-maps {
    background: #cc232a;
    color: #ffffff;
}

.btn-site {
    background: rgba(0, 51, 160, 0.1);
    color: #0033A0;
    border: 1px solid rgba(0, 51, 160, 0.2);
}

html.rossonero-mode .btn-site {
    background: rgba(255, 213, 79, 0.15);
    color: var(--yellow-anxa);
    border-color: rgba(255, 213, 79, 0.3);
}

.btn-turismo {
    background: rgba(0, 51, 160, 0.1);
    color: #0033A0;
    border: 1px solid rgba(0, 51, 160, 0.2);
}

html.rossonero-mode .btn-turismo {
    background: rgba(255, 213, 79, 0.15);
    color: var(--yellow-anxa);
    border-color: rgba(255, 213, 79, 0.3);
}

.btn-guardia-medica {
    background: #0284c7;
    color: #ffffff;
}

.btn-emergenza {
    background: #dc2626;
    color: #ffffff;
}

/* Sezione Secondaria Espandibile Vetrine nel Comune (Chiusa di default) */
.comune-venues-toggle-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    padding: 10px 12px;
    background: rgba(0, 51, 160, 0.06);
    border: 1px solid rgba(0, 51, 160, 0.15);
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    font-size: 0.8rem;
    font-weight: 800;
    color: #0033A0;
    transition: background 0.2s ease;
}

html.rossonero-mode .comune-venues-toggle-bar {
    background: rgba(255, 213, 79, 0.1);
    border-color: rgba(255, 213, 79, 0.2);
    color: var(--yellow-anxa);
}

.comune-venues-toggle-bar:hover {
    background: rgba(0, 51, 160, 0.12);
}

html.rossonero-mode .comune-venues-toggle-bar:hover {
    background: rgba(255, 213, 79, 0.18);
}

.comune-venues-chevron {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.comune-venues-collapsible {
    margin-top: 10px;
    padding-top: 6px;
}


/* ==========================================================================
   TERRITORI - CORNICI PIU VISIBILI
   ========================================================================== */

/* Delinea meglio ogni riquadro Comune senza appesantire la griglia */
.comune-card {
    border: 2px solid rgba(0, 51, 160, 0.20) !important;
    box-shadow:
        0 4px 14px rgba(0,0,0,0.06),
        inset 0 0 0 1px rgba(255,255,255,0.45) !important;
}

.comune-card:hover {
    border-color: rgba(0, 51, 160, 0.52) !important;
}

.comune-card.open {
    border-color: rgba(0, 51, 160, 0.36) !important;
}

html.rossonero-mode .comune-card {
    border-color: rgba(255, 213, 79, 0.30) !important;
}

html.rossonero-mode .comune-card:hover,
html.rossonero-mode .comune-card.open {
    border-color: rgba(255, 213, 79, 0.68) !important;
}

/* Delinea anche le singole vetrine che appaiono dentro il Comune */
.territori-venue-row {
    border: 1.5px solid rgba(0, 51, 160, 0.20) !important;
    background: rgba(255,255,255,0.48) !important;
    box-shadow: 0 2px 7px rgba(0,0,0,0.045) !important;
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease !important;
}

.territori-venue-row:hover {
    border-color: rgba(0, 51, 160, 0.48) !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08) !important;
    transform: translateY(-1px) !important;
}

html.rossonero-mode .territori-venue-row {
    border-color: rgba(255, 213, 79, 0.28) !important;
    background: rgba(255,255,255,0.055) !important;
}

html.rossonero-mode .territori-venue-row:hover {
    border-color: rgba(255, 213, 79, 0.62) !important;
}

/* Anche il blocco "Attività e vetrine nel Comune" risulta più definito */
.comune-venues-toggle-bar {
    border-width: 1.5px !important;
    border-color: rgba(0, 51, 160, 0.24) !important;
}

html.rossonero-mode .comune-venues-toggle-bar {
    border-color: rgba(255, 213, 79, 0.30) !important;
}


/* ==========================================================================
   FIX TEMA SCURO / ROSSONERO - TERRITORI
   ========================================================================== */

html.rossonero-mode .comune-card {
    background: #121212 !important;
    color: #f5f5f5 !important;
    border-color: rgba(255, 213, 79, 0.34) !important;
    box-shadow: 0 5px 16px rgba(0,0,0,.34) !important;
}

html.rossonero-mode .comune-card-header {
    background: #121212 !important;
}

html.rossonero-mode .comune-card.open .comune-card-header {
    background: rgba(255, 213, 79, 0.055) !important;
    border-bottom-color: rgba(255, 213, 79, 0.22) !important;
}

html.rossonero-mode .comune-name {
    color: #FFD54F !important;
    text-shadow: none !important;
}

html.rossonero-mode .comune-area-label {
    background: rgba(255, 213, 79, 0.12) !important;
    color: #FFD54F !important;
    border: 1px solid rgba(255, 213, 79, 0.18) !important;
}

html.rossonero-mode .comune-info-grid {
    background: #202020 !important;
    border: 1px solid rgba(255,255,255,.10) !important;
    color: #f2f2f2 !important;
}

html.rossonero-mode .info-cell,
html.rossonero-mode .info-cell-label,
html.rossonero-mode .info-cell-val {
    color: #f2f2f2 !important;
}

html.rossonero-mode .info-cell-label {
    opacity: .82 !important;
}

html.rossonero-mode .info-svg {
    color: #FFD54F !important;
    fill: currentColor !important;
    opacity: .95 !important;
}

html.rossonero-mode .comune-expand-bar {
    color: #FFD54F !important;
    border-top-color: rgba(255, 213, 79, .20) !important;
    opacity: 1 !important;
}

html.rossonero-mode .comune-chevron {
    color: #FFD54F !important;
}

html.rossonero-mode .btn-share-icon {
    background: rgba(255, 213, 79, .10) !important;
    color: #FFD54F !important;
    border: 1px solid rgba(255, 213, 79, .16) !important;
}

html.rossonero-mode .btn-share-icon:hover {
    background: #FFD54F !important;
    color: #111 !important;
}

html.rossonero-mode .comune-body {
    background: #121212 !important;
    color: #f5f5f5 !important;
}

html.rossonero-mode .comune-venues-toggle-bar {
    background: #1b1b1b !important;
    color: #FFD54F !important;
    border-color: rgba(255, 213, 79, .28) !important;
}

html.rossonero-mode .comune-venues-toggle-bar:hover {
    background: rgba(255, 213, 79, .08) !important;
}

html.rossonero-mode .territori-venue-row {
    background: #1c1c1c !important;
    color: #f5f5f5 !important;
    border-color: rgba(255, 213, 79, .24) !important;
}

html.rossonero-mode .territori-venue-row:hover {
    border-color: rgba(255, 213, 79, .55) !important;
    background: #232323 !important;
}

/* Barra ricerca e filtri */
html.rossonero-mode .territori-search-box {
    background: #171717 !important;
    border-color: rgba(255, 213, 79, .20) !important;
}

html.rossonero-mode .territori-search-input {
    color: #f5f5f5 !important;
}

html.rossonero-mode .territori-search-input::placeholder {
    color: #d6d6d6 !important;
    opacity: .72 !important;
}

html.rossonero-mode .territori-filter-tab {
    background: #171717 !important;
    color: #f2f2f2 !important;
    border-color: rgba(255,255,255,.12) !important;
}

html.rossonero-mode .territori-filter-tab.active {
    background: #FFD54F !important;
    color: #111 !important;
    border-color: #FFD54F !important;
}

/* Azioni nella card aperta */
html.rossonero-mode .btn-site,
html.rossonero-mode .btn-turismo {
    background: #1d1d1d !important;
    color: #FFD54F !important;
    border-color: rgba(255, 213, 79, .28) !important;
}

html.rossonero-mode .btn-maps {
    background: #cc232a !important;
    color: #fff !important;
}

html.rossonero-mode .btn-guardia-medica,
html.rossonero-mode .btn-emergenza {
    color: #fff !important;
}


/* ==========================================================================
   TERRITORI - TEMA ROSSONERO REALE
   Il theme.js applica la classe html.rossonero-mode.
   ========================================================================== */
html.rossonero-mode .comune-card {
    background: #121212 !important;
    color: #f5f5f5 !important;
    border-color: rgba(255, 213, 79, .42) !important;
}

html.rossonero-mode .comune-card-header {
    background: #121212 !important;
}

html.rossonero-mode .comune-name {
    color: #FFD54F !important;
}

html.rossonero-mode .comune-area-label {
    background: rgba(255, 213, 79, .12) !important;
    border: 1px solid rgba(255, 213, 79, .22) !important;
    color: #FFD54F !important;
}

html.rossonero-mode .comune-info-grid {
    background: #202020 !important;
    border-color: rgba(255,255,255,.12) !important;
}

html.rossonero-mode .info-cell,
html.rossonero-mode .info-cell-label,
html.rossonero-mode .info-cell-val {
    color: #f4f4f4 !important;
}

html.rossonero-mode .info-cell-label {
    opacity: .82 !important;
}

html.rossonero-mode .info-svg {
    fill: #FFD54F !important;
    color: #FFD54F !important;
}

html.rossonero-mode .comune-expand-bar,
html.rossonero-mode .comune-chevron {
    color: #FFD54F !important;
}

html.rossonero-mode .comune-expand-bar {
    border-top-color: rgba(255, 213, 79, .22) !important;
    opacity: 1 !important;
}

html.rossonero-mode .btn-share-icon {
    background: rgba(255, 213, 79, .10) !important;
    border: 1px solid rgba(255, 213, 79, .18) !important;
    color: #FFD54F !important;
}

html.rossonero-mode .btn-share-icon:hover {
    background: #FFD54F !important;
    color: #111 !important;
}

html.rossonero-mode .comune-body {
    background: #121212 !important;
    color: #f5f5f5 !important;
}

html.rossonero-mode .territori-venue-row {
    background: #1d1d1d !important;
    color: #f5f5f5 !important;
    border-color: rgba(255, 213, 79, .30) !important;
}

html.rossonero-mode .comune-venues-toggle-bar {
    background: #1a1a1a !important;
    border-color: rgba(255, 213, 79, .30) !important;
    color: #FFD54F !important;
}

html.rossonero-mode .territori-search-box,
html.rossonero-mode .territori-filter-tab {
    background: #171717 !important;
    color: #f5f5f5 !important;
}

html.rossonero-mode .territori-search-input {
    color: #f5f5f5 !important;
}

html.rossonero-mode .territori-filter-tab.active {
    background: #FFD54F !important;
    color: #111 !important;
    border-color: #FFD54F !important;
}
