/* Titillium Web, il carattere di Designers Italia / AgID, servito dal
   nostro server invece che da Google Fonts. Licenza: fonts/titillium-web/OFL.txt */
@font-face {
    font-family: 'Titillium Web';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('../fonts/titillium-web/titillium-web-v10-latin-ext_latin-300.woff2') format('woff2'),
         url('../fonts/titillium-web/titillium-web-v10-latin-ext_latin-300.woff') format('woff');
}

@font-face {
    font-family: 'Titillium Web';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/titillium-web/titillium-web-v10-latin-ext_latin-regular.woff2') format('woff2'),
         url('../fonts/titillium-web/titillium-web-v10-latin-ext_latin-regular.woff') format('woff');
}

@font-face {
    font-family: 'Titillium Web';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/titillium-web/titillium-web-v10-latin-ext_latin-600.woff2') format('woff2'),
         url('../fonts/titillium-web/titillium-web-v10-latin-ext_latin-600.woff') format('woff');
}

@font-face {
    font-family: 'Titillium Web';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/titillium-web/titillium-web-v10-latin-ext_latin-700.woff2') format('woff2'),
         url('../fonts/titillium-web/titillium-web-v10-latin-ext_latin-700.woff') format('woff');
}

    :root {
        --ita-blue: #0066cc;
        --ita-dark-blue: #00264d;
        --ita-footer-blue: #004b91;
        --ita-footer-dark: #003366;
        --ita-green: #008055;
        /* Il tema di un software (templates/base.html) le ridefinisce con i suoi colori */
        --ita-blue-hover: #0b2a47;
        --ita-link: #004d99;
    }

    body, h1, h2, h3, h4, h5, h6, button, input, select, textarea,
    .btn, .italia-it-button, .italia-it-button-text {
        font-family: 'Titillium Web', Geneva, Tahoma, sans-serif !important;
    }

    body {
        background-color: #ffffff;
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    /* Il footer resta in fondo anche quando la pagina è più corta della finestra */
    #main-wrapper {
        flex: 1 0 auto;
        display: flex;
        flex-direction: column;
    }

    #main-wrapper > main {
        flex: 1 0 auto;
    }

    .row.align-items-stretch {
        display: flex;
    }

    img {
        max-width: 100%;
        height: auto;
    }

    .it-header-center-wrapper {
        background-color: var(--ita-dark-blue) !important;
        padding: 30px 0;
    }

    .header-logo-img {
        height: 80px;
        width: auto;
    }

    .login-container-card {
        border-radius: 10px !important;
        border: 0px solid #ffffff !important;
        overflow: visible !important;
    }

    .card-header-custom {
        border-radius: 10px !important;
        background-color: #f6f7f8;
        border-bottom: 0px solid #dae4f1;
    }

    /* Stessi margini della card operatore (p-4 p-md-5): i pulsanti SPID e CIE
       risultano larghi quanto il pulsante ACCEDI. */
    .login-options-wrapper {
        padding: 0 24px;
    }

    @media (min-width: 768px) {
        .login-options-wrapper {
            padding: 0 48px;
        }
    }

    .login-options-wrapper h4 {
        margin-top: 0;
        margin-bottom: 2px !important;
        color: #00264d;
        font-size: 1rem !important;
    }

    .login-options-wrapper p.small {
        line-height: 1.2 !important;
        margin-bottom: 0.8rem !important;
       /* margin-right: 50px;
        margin-left: 70px;*/
    }

    .access-single-pane .badge {
        font-size: 0.75rem;
        font-weight: 600;
        color: #6c757d;
        background-color: #fff !important;
    }

    .my-3 {
        margin-top: 1rem !important;
        margin-bottom: 1rem !important;
    }


    .spid-button-container {
        text-align: center;
        width: 100%;
    }

    /* SPID, CIE e "Cambia comune" uno sotto l'altro, larghi al massimo 300px e centrati */
    .italia-it-button {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        max-width: 300px !important;
        min-height: 56px !important;
        border-radius: 5px !important;
        box-shadow: none;
    }

    .italia-it-button-icon {
        flex-shrink: 0;
    }

    .italia-it-button-icon img {
        height: 28px !important;
        width: auto !important;
    }

    .spid-idp-button.spid-idp-button-open {
        display: block !important;
        opacity: 1 !important;
    }

    #spid-pane .text-center {
        position: relative !important;
    }

    #spid-idp-button-large-post {
        position: absolute !important;
        top: 100% !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        margin-top: 5px !important;
        width: 320px !important;
        max-width: 90vw !important;
        z-index: 999 !important;
    }

    .spid-idp-button-menu {
        max-height: none !important;
        overflow: visible !important;
        list-style: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .spid-idp-button-menu .spid-idp-button-link {
        border-bottom: 1px solid #eee !important;
    }

    .spid-idp-button-menu .idp-button-idp-logo {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        height: 56px !important;
        border-bottom: 0 !important;
    }

    .spid-idp-button-menu .idp-button-idp-logo img {
        height: 26px !important;
        width: auto !important;
        margin: 0 auto !important;
    }

    .spid-idp-button-menu .dropdown-item.small {
        display: block;
        width: 100%;
        padding: 10px 15px;
        color: #0066cc;
        text-align: center;
        text-decoration: none;
        background-color: #fff;
        font-size: 0.85rem !important;
    }

    /* "Cambia comune": pulsante secondario a tutta larghezza sotto SPID e CIE */
    /* "Scegli un altro comune": pulsante secondario azzurro tenue, largo come SPID e CIE */
    .back-to-comune {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        max-width: 300px;
        min-height: 48px;
        margin: 1.25rem auto 0;
        border-radius: 5px;
        background-color: #ffffff;
        color: #004d99;
        font-size: 1rem;
        font-weight: 600;
        text-decoration: none;
        transition: background-color 0.2s ease;
    }

    .back-to-comune i {
        font-size: 0.85rem;
        transition: transform 0.5s ease;
    }

    .back-to-comune:hover, .back-to-comune:focus {
        color: #bddaf7;
    }

    .back-to-comune:hover i {
        transform: translateX(-5px);
    }

    .forgot-password-link {
        font-size: 0.85rem;
        color: var(--ita-link);
        text-decoration: none;
        font-weight: 600;
        opacity: 0.8;
        transition: opacity 0.1s;
    }

    .forgot-password-link:hover {
        opacity: 1;
        text-decoration: none;
        color: #bddaf7;
    }

    .modal-content {
        border-radius: 10px !important;
        overflow: hidden;
        border: none !important;
        box-shadow: 0 15px 50px rgba(0,0,0,0.2) !important;
    }

    .modal-header {
        border-bottom: none !important;
        padding: 25px 30px 10px !important;
        position: relative;
    }

    .modal-header .btn-close {
        position: absolute;
        top: 20px;
        right: 20px;
        background-size: 12px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        padding: 15px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        opacity: 1;
    }

    .modal-body {
        padding: 10px 30px 30px !important;
    }

    /* Cambio password: requisiti come lista con spunte (cerchio grigio -> spunta verde) */
    .pwd-requisiti {
        list-style: none;
        margin: 10px 0 0;
        padding: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px 16px;
        font-size: 0.85rem;
        color: #5d7083;
    }

    .pwd-requisiti li {
        position: relative;
        padding-left: 24px;
        line-height: 1.4;
        transition: color 0.15s ease;
    }

    .pwd-requisiti li::before {
        content: "";
        position: absolute;
        left: 0;
        top: 50%;
        width: 16px;
        height: 16px;
        margin-top: -8px;
        border: 1.5px solid #b1b1b3;
        border-radius: 50%;
        background: #fff center / 10px 10px no-repeat;
        box-sizing: border-box;
        transition: background-color 0.15s ease, border-color 0.15s ease;
    }

    .pwd-requisiti li.ok {
        color: var(--ita-green);
    }

    .pwd-requisiti li.ok::before {
        border-color: var(--ita-green);
        background-color: var(--ita-green);
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3e%3cpath d='M2 5.2l2 2L8 3' fill='none' stroke='%23fff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
    }

    /* Conferma: is-invalid di Bootstrap Italia, ma con una X al posto del punto esclamativo */
    #cambioPwdConferma.is-invalid {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3e%3cpath d='M3 3l6 6M9 3l-6 6' fill='none' stroke='%23d9364f' stroke-width='1.6' stroke-linecap='round'/%3e%3c/svg%3e");
    }

    @media (max-width: 400px) {
        .pwd-requisiti { grid-template-columns: 1fr; }
    }

    @media (prefers-reduced-motion: reduce) {
        .pwd-requisiti li, .pwd-requisiti li::before { transition: none; }
    }

    /* Stessa misura del pulsante ACCEDI */
    #btnFinalizzaLogin {
        border-radius: 5px !important;
        min-height: 60px;
        padding: 15px !important;
        font-size: 1rem !important;
        font-weight: 700;
        letter-spacing: 0.5px;
        background-color: var(--ita-blue);
        border: none;
        box-shadow: 0 4px 12px rgba(0, 102, 204, 0.2);
    }

    #btnFinalizzaLogin:hover {
        background-color: var(--ita-blue-hover);
    }

    .section-label-modern {
        font-size: 0.75rem !important;
        font-weight: 800 !important;
        color: #64748b !important;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-top: 10px;
        margin-bottom: 10px !important;
        display: block;
    }

    .step-indicator {
        font-size: 0.7rem;
        font-weight: 700;
        color: var(--ita-dark-blue);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 8px;
        display: block;
    }

    .custom-list-group {
        max-height: 250px;
        overflow-y: auto;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        background-color: #fff;
        margin-bottom: 20px;
    }

    .custom-list-group::-webkit-scrollbar { width: 6px; }
    .custom-list-group::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 10px; }

    .custom-list-item {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        padding: 12px 15px !important;
        border-bottom: 1px solid #f1f5f9;
        cursor: pointer;
        transition: all 0.2s ease;
        border-left: 4px solid transparent;
        text-align: left !important;
    }

    .custom-list-item:hover {
        background-color: #f8fbff;
    }

    .custom-list-item.selected, .custom-list-item.active {
        background-color: #e6f0ff !important;
        border-left: 5px solid var(--ita-blue) !important;
        transition: all 0.2s ease;
    }

    /* Logo del comune o del software, nello stesso riquadro per tutte le voci */
    .item-icon-wrapper {
        width: 40px;
        height: 40px;
        margin-right: 15px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        color: var(--ita-blue);
    }

    .item-icon-wrapper img {
        max-width: 32px;
        max-height: 32px;
        object-fit: contain;
    }

    .item-icon-wrapper i {
        font-size: 1rem;
    }

    .item-text {
        font-weight: 600;
        color: #334155;
        font-size: 0.95rem;
    }

    .selected-icon {
        display: none;
        color: var(--ita-blue);
        font-size: 1.1rem;
        margin-left: auto;
    }

    .custom-list-item.selected .selected-icon {
        display: block;
    }

    /* Ricerca dei comuni */
    .comuni-search {
        padding: 0 20px;

    }

    .comuni-search-field {
        position: relative;
    }

    .comuni-search-field i {
        position: absolute;
        left: 8px;
        top: 50%;
        transform: translateY(-50%);
        color: #cfd3d6;
        pointer-events: none;
    }

    .comuni-search-field .form-control {
        padding-left: 2.25rem;
        border-bottom: 1px solid #ececec;
    }

    .comuni-conteggio {
        min-height: 1.2em;
        margin: 6px 0 4px;
        font-size: 0.8rem;
        color: #6c757d;
    }

    .comuni-vuoto {
        padding: 0 20px 20px;
        font-size: 0.9rem;
        color: #6c757d;
    }

    .selection-list-item.comune-nascosto {
        display: none !important;
    }

    .selection-scroll-group {
        max-height: 400px;
        overflow-y: auto;
        overflow-x: hidden;
        border-radius: 12px;
        background-color: #fff;
        margin-bottom: 20px;
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.03);
    }

    .selection-list-item {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 12px 20px !important;
        border-bottom: 1px solid #f1f5f9;
        cursor: pointer;
        transition: all 0.2s ease;
        width: 100%;
        background-color: #fff;
    }

    .item-left-content {
        display: flex;
        align-items: center;
        justify-content: flex-start;
    }

    .mini-logo-wrapper {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 15px;
    }

    .mini-logo {
        max-width: 100%;
        max-height: 32px;
        object-fit: contain;
    }

    .selection-text {
        font-weight: 600;
        font-size: 0.95rem;
        color: #334155;
        margin: 0;
        text-align: left;
    }

    .chevron-icon {
        color: #cbd5e1;
        font-size: 0.8rem;
        transition: transform 0.2s;
    }

    .selection-list-item:hover {
        background-color: #e6f4ff !important;
        padding-left: 25px !important;
    }

    .selection-list-item:hover .chevron-icon {
        color: var(--ita-blue);
        transform: translateX(3px);
    }

    .list-disabled {
        opacity: 0.5;
        pointer-events: none;
        background-color: #f9f9f9;
    }

    .it-footer {
        background-color: var(--ita-footer-blue);
        color: white;
        font-family: 'Titillium Web', sans-serif;
    }

    .footer-col-title {
        font-size: 0.95rem;
        font-weight: 700;
        margin-bottom: 1.5rem;
        letter-spacing: 0.5px;
    }

    .footer-contact-info p {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .footer-email-link {
        color: white;
        text-decoration: underline;
        font-size: 0.9rem;
    }

    .footer-email-link:hover {
        color: #e0e0e0;
    }

    .footer-link-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .footer-link-list li {
        margin-bottom: 0.7rem;
    }

    .footer-link-list li a {
        color: white;
        text-decoration: none;
        font-size: 0.9rem;
    }

    .footer-link-list li a:hover {
        text-decoration: underline;
    }

    .footer-social-icons i {
        font-size: 1.4rem;
        color: white;
        transition: opacity 0.2s;
    }

    .footer-social-icons a {
        display: inline-flex;
        width: 40px;
        height: 40px;
        background: rgba(255,255,255,0.1);
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        transition: background 0.3s;
    }

    .footer-social-icons a:hover {
        background: var(--ita-blue);
        color: white !important;
    }

    .it-footer-small-prints {
        background-color: var(--ita-dark-blue);
        border-top: 1px solid rgba(255,255,255,0.1);
    }

    .footer-bottom-link {
        color: white;
        text-decoration: underline;
        font-size: 0.85rem;
    }

    .small-text {
        font-size: 0.85rem;
        opacity: 0.9;
    }

    .footer-logos-container {
        opacity: 0.6;
        padding: 20px;
        transition: opacity 0.3s;
    }

    .footer-logos-container:hover {
        opacity: 1;
    }

    .inst-logo {
        height: 30px;
        width: auto;
    }

    .btn-back-to-top {
        background-color: var(--ita-blue);
        color: white;
        border: none;
        width: 40px;
        height: 60px;
        border-radius: 5px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background 0.3s;
    }

    .btn-back-to-top:hover {
        background-color: var(--ita-blue-hover);
    }

    /* Nella barra in fondo il pulsante "torna su" è più piccolo, così la barra è più bassa
       (ACCEDI usa la stessa classe e resta alto 60px) */
    .it-footer-small-prints .btn-back-to-top {
        width: 36px;
        height: 36px;
    }

    @media (max-width: 991.98px) {
        .display-4 { font-size: 2.5rem; }
        .display-5 { font-size: 2rem; }
        .login-container-card { margin-bottom: 2rem; }
        .it-footer .row.g-4 { text-align: center; }
        .footer-col-title { margin-top: 20px; }
        .footer-social-icons { justify-content: center; }
    }

    @media (max-width: 767.98px) {
        .it-header-center-wrapper { padding: 15px 0 !important; }
        .header-logo-img { height: 50px !important; }
        .it-brand-text h2 { font-size: 1.2rem !important; }
        .it-brand-text p { display: none; }
        main.container { margin-top: 1.5rem !important; margin-bottom: 1.5rem !important; padding-left: 15px; padding-right: 15px; }
        .p-md-5 { padding: 1.5rem !important; }
        .italia-it-button-text { font-size: 14px !important; }
        .it-footer-small-prints .row { flex-direction: column; gap: 15px; }
        .it-footer-small-prints [class*="col-"] { text-align: center !important; }
        .footer-logos-container { padding: 15px; gap: 1.5rem !important; }
    }

    @media (max-width: 575.98px) {
        .display-4 { font-size: 1.8rem; }
        .display-5 { font-size: 1.6rem; }
        .lead { font-size: 1rem; }
        .selection-scroll-group, .custom-list-group { max-height: 300px; }
        .selection-list-item, .custom-list-item { padding: 12px 10px; }
        .footer-logos-container { padding: 10px; gap: 1rem !important; flex-wrap: wrap; }
        .inst-logo { height: 22px; }
        #spid-idp-button-large-post {
            width: 100vw !important;
            max-width: 100vw !important;
            position: fixed !important;
            bottom: 0 !important;
            top: auto !important;
            left: 0 !important;
            transform: none !important;
            border-radius: 20px 20px 0 0 !important;
            box-shadow: 0 -5px 20px rgba(0,0,0,0.2) !important;
        }
        .spid-idp-button-menu { max-height: 80vh !important; overflow-y: auto !important; }
    }

    @media (max-height: 600px) and (orientation: landscape) {
        .header-sticky-wrapper { position: relative; }
    }

    @media (pointer: coarse) {
        .selection-scroll-group::-webkit-scrollbar,
        .custom-list-group::-webkit-scrollbar {
            width: 8px;
        }
    }