/* ============================================================
   CEDAL SPECIALIZATIONS - Frontend styles
   ============================================================ */

/* Reset di sicurezza: il tema OneLife usa box-sizing variabile,
   imponiamo il border-box su tutto il sottoalbero del plugin */
.csp-spec-page,
.csp-spec-page *,
.csp-spec-page *::before,
.csp-spec-page *::after {
    box-sizing: border-box;
}

.csp-spec-page {
    padding: 2rem 1rem;
    width: 100%;
    background: transparent;
}

.csp-spec-page__container {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

/* ============================================================
   LAYOUT 2 COLONNE - flexbox (piu' robusto del grid coi temi old)
   ============================================================ */

.csp-spec-page .csp-layout {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 2rem;
    align-items: flex-start;
    width: 100%;
}

.csp-spec-page .csp-main {
    flex: 1 1 auto;
    min-width: 0; /* IMPORTANTE: impedisce al main di "esplodere" oltre il container */
    width: auto;
}

.csp-spec-page .csp-sidebar {
    flex: 0 0 280px;
    width: 280px;
    max-width: 280px;
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    position: sticky;
    top: 100px;
}

/* ---- Sidebar contenuto ---- */
.csp-sidebar__title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 1rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid #2271b1;
    color: #2271b1;
    text-transform: uppercase;
    letter-spacing: .05em;
    line-height: 1.3;
}

.csp-sidebar__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.csp-sidebar__item {
    margin: 0;
    padding: 0;
}

.csp-sidebar__item a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .55rem .75rem;
    color: #444;
    text-decoration: none;
    border-radius: 4px;
    font-size: .95rem;
    line-height: 1.35;
    transition: background .12s ease, color .12s ease;
}

.csp-sidebar__item a:hover {
    background: #f5f7fa;
    color: #2271b1;
}

.csp-sidebar__item.is-current a {
    background: #2271b1;
    color: #fff;
    font-weight: 600;
}

.csp-sidebar__item.is-current .csp-sidebar__count {
    background: rgba(255, 255, 255, .25);
    color: #fff;
}

.csp-sidebar__name {
    flex: 1 1 auto;
    min-width: 0;
}

.csp-sidebar__count {
    flex: 0 0 auto;
    background: #e7eef7;
    color: #2271b1;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: .75rem;
    font-weight: 600;
    min-width: 22px;
    text-align: center;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet: sidebar leggermente piu' stretta */
@media (max-width: 1024px) {
    .csp-spec-page .csp-layout {
        gap: 1.5rem;
    }
    .csp-spec-page .csp-sidebar {
        flex: 0 0 240px;
        width: 240px;
        max-width: 240px;
        padding: 1rem 1.1rem;
    }
}

/* Mobile: tutto in colonna unica, sidebar sotto */
@media (max-width: 768px) {
    .csp-spec-page .csp-layout {
        flex-direction: column;
        gap: 1.5rem;
    }
    .csp-spec-page .csp-main,
    .csp-spec-page .csp-sidebar {
        flex: 1 1 auto;
        width: 100%;
        max-width: 100%;
    }
    .csp-spec-page .csp-sidebar {
        position: static;
        order: 2;
    }
    .csp-spec-page .csp-main {
        order: 1;
    }
    /* Su mobile lista a 2 colonne per occupare meno spazio verticale */
    .csp-sidebar__list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2px;
    }
}

/* Phone piccoli: una colonna */
@media (max-width: 480px) {
    .csp-sidebar__list {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   INDEX SHORTCODE [specializzazioni]
   ============================================================ */
.csp-index {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    margin: 2rem auto;
    max-width: 1200px;
    padding: 0 1rem;
}
.csp-index--cols-2 { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.csp-index--cols-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.csp-index--cols-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.csp-index--cols-5 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.csp-index__card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 1.25rem 1.5rem;
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    min-height: 90px;
}
.csp-index__card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,.08);
    border-color: #c0c0c0;
}
.csp-index__name {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: .35rem;
}
.csp-index__count {
    font-size: .85rem;
    color: #777;
}

/* ============================================================
   SINGLE SPECIALIZATION
   ============================================================ */

.csp-spec__header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #ececec;
}
.csp-spec__title {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    margin: 0 0 1rem;
    line-height: 1.15;
}
.csp-spec__description {
    font-size: 1.05rem;
    line-height: 1.6;
    color: #444;
    max-width: 75ch;
}
.csp-spec__description p:first-child { margin-top: 0; }
.csp-spec__description p:last-child  { margin-bottom: 0; }

.csp-spec__section-title {
    font-size: 1.5rem;
    margin: 0 0 1.25rem;
}

/* ---- Doctors fieldset (inserito dentro CF7 via JS) ---- */
.csp-doctors-source { /* visibile come fallback se CF7 manca */ }
.csp-doctors-slot   { margin: 1rem 0 1.25rem; }
.csp-doctors-fieldset {
    border: 1px solid #e2e2e2;
    border-radius: 6px;
    padding: 1rem 1.25rem 1.25rem;
    margin: 0;
    background: #fff;
}
.csp-doctors-legend {
    font-weight: 700;
    padding: 0 .5rem;
    font-size: 1rem;
}
.csp-doctors-help {
    margin: .25rem 0 1rem;
    font-size: .9rem;
    color: #666;
    font-weight: 400;
}

/* ---- Doctors grid ---- */
.csp-doctors {
    display: grid;
    gap: .75rem;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.csp-doctor {
    cursor: pointer;
    position: relative;
    display: block;
}
.csp-doctor input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.csp-doctor__inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
    border: 2px solid #e2e2e2;
    border-radius: 8px;
    padding: 1rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.csp-doctor:hover .csp-doctor__inner { border-color: #b8d4f0; }
.csp-doctor input:checked + .csp-doctor__inner {
    border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34,113,177,.15);
}
.csp-doctor input:focus-visible + .csp-doctor__inner {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.csp-doctor__thumb-wrap {
    display: block;
    width: 100%;
    aspect-ratio: 16/10;
    overflow: hidden;
    border-radius: 4px;
    margin-bottom: .5rem;
    background: #f0f0f0;
}
.csp-doctor__thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.csp-doctor__title {
    display: block;
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: .35rem;
    line-height: 1.3;
}
.csp-doctor__summary {
    display: block;
    font-size: .9rem;
    color: #666;
    line-height: 1.45;
}

/* "Non ho preferenza" - card speciale */
.csp-doctor--no-preference .csp-doctor__inner {
    background: #f5faff;
    border-style: dashed;
    justify-content: center;
    align-items: flex-start;
    text-align: left;
}
.csp-doctor__no-pref-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2271b1;
    color: #fff;
    font-size: 1.1rem;
    margin-bottom: .75rem;
}

/* ---- CF7 wrapper ---- */
.csp-spec__cf7-wrap {
    background: #fafafa;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 800px;
    /* Contiene i margini dei figli per evitare margin-collapse */
    display: flow-root;
}
.csp-spec__cf7-wrap .wpcf7-form { margin: 0; }
.csp-spec__cf7-wrap .wpcf7-form > *:first-child { margin-top: 0; }
.csp-spec__cf7-wrap .wpcf7-form > *:last-child { margin-bottom: 0; }

.csp-spec__cf7-wrap label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 600;
}
.csp-spec__cf7-wrap input[type="text"],
.csp-spec__cf7-wrap input[type="email"],
.csp-spec__cf7-wrap input[type="date"],
.csp-spec__cf7-wrap textarea {
    width: 100%;
    padding: .6rem .75rem;
    font: inherit;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-top: .35rem;
    font-weight: 400;
}
.csp-spec__cf7-wrap input[readonly] {
    background: #f0f0f0;
    color: #555;
}
.csp-spec__cf7-wrap textarea { min-height: 100px; }
.csp-spec__cf7-wrap .wpcf7-submit,
.csp-spec__cf7-wrap input[type="submit"] {
    background: #2271b1;
    color: #fff;
    padding: .75rem 2rem;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    margin-top: .5rem;
    transition: background .15s ease;
}
.csp-spec__cf7-wrap .wpcf7-submit:hover,
.csp-spec__cf7-wrap input[type="submit"]:hover {
    background: #185a8c;
}

/* ---- Mobile doctors grid ---- */
@media (max-width: 640px) {
    .csp-doctors {
        grid-template-columns: 1fr;
    }
    .csp-doctor__thumb-wrap {
        aspect-ratio: 16/9;
    }
}
