/**
 * COPEX Core - Ajustes visuales de front-end.
 *
 * Extraído en la v0.16.0 de includes/trait-admin-contexto.php
 * (frontend_css_fixes()), donde antes se imprimía como <style> inline
 * en el <head> de TODAS las páginas del sitio a través de wp_head,
 * generase o no contenido de COPEX en esa página.
 *
 * El contenido es exactamente el mismo CSS; solo cambia la forma de
 * entregarlo: ahora se sirve como archivo estático versionado
 * (wp_enqueue_style con COPEX_CORE_VERSION), así el navegador lo
 * descarga una vez y lo reutiliza en el resto de páginas en vez de
 * recibirlo repetido en cada respuesta HTML.
 */

    /* Portada Cursos y eventos */
    .copex-cursos-portada {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 18px;
        margin: 24px 0;
    }

    .copex-cursos-portada__card {
        display: block;
        padding: 22px;
        border: 1px solid #e5e7eb;
        border-radius: 16px;
        background: #fff;
        color: #1f2937;
        text-decoration: none;
        box-shadow: 0 8px 24px rgba(0,0,0,.04);
        transition: all .2s ease;
    }

    .copex-cursos-portada__card:hover {
        border-color: #873d84;
        transform: translateY(-2px);
        box-shadow: 0 12px 30px rgba(135,61,132,.14);
    }

    .copex-cursos-portada__card strong {
        display: block;
        margin-bottom: 8px;
        font-size: 18px;
        color: #873d84;
    }

    .copex-cursos-portada__card span {
        display: block;
        color: #4b5563;
        line-height: 1.45;
    }



    /* COPEX - Cards Home */
    .copex-home-cards {
        display: grid;
        gap: 18px;
        margin: 24px 0;
    }

    .copex-home-accesos-principales {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .copex-home-servicios-destacados {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .copex-home-card {
        display: flex;
        gap: 22px;
        align-items: flex-start;
        min-height: 132px;
        padding: 28px 30px;
        background: #ffffff;
        border: 1px solid #e6e0e8;
        border-radius: 14px;
        box-shadow: 0 8px 22px rgba(35, 20, 45, 0.06);
        text-decoration: none !important;
        color: #182033;
        transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    }

    .copex-home-card:hover {
        transform: translateY(-3px);
        border-color: rgba(135, 61, 132, 0.38);
        box-shadow: 0 14px 30px rgba(35, 20, 45, 0.10);
        color: #182033;
    }

    .copex-home-card__icon {
        flex: 0 0 58px;
        width: 58px;
        height: 58px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #873d84;
    }

    .copex-home-card__icon-shape {
        display: block;
        width: 58px;
        height: 58px;
        background-color: currentColor;
        -webkit-mask-image: var(--copex-home-icon-url);
        mask-image: var(--copex-home-icon-url);
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: center;
        mask-position: center;
        -webkit-mask-size: contain;
        mask-size: contain;
    }

    .copex-home-card__content {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .copex-home-card__content strong {
        color: #182033;
        font-size: 1.08rem;
        font-weight: 700;
        line-height: 1.25;
    }

    .copex-home-card__content span {
        color: #4d5567;
        font-size: 0.96rem;
        line-height: 1.45;
    }

    @media (max-width: 1100px) {
        .copex-home-accesos-principales,
        .copex-home-servicios-destacados {
            grid-template-columns: repeat(2, minmax(0, 1fr));
        }
    }

    @media (max-width: 680px) {
        .copex-home-accesos-principales,
        .copex-home-servicios-destacados {
            grid-template-columns: 1fr;
        }

        .copex-home-card {
            padding: 22px;
            min-height: auto;
        }

        .copex-home-card__icon,
        .copex-home-card__icon-shape {
            width: 46px;
            height: 46px;
        }
    }

    /* COPEX - Paneles Home: actualidad y próximas actividades */
    .copex-home-panel {
        background: #ffffff;
        border: 1px solid #e6e0e8;
        border-radius: 18px;
        box-shadow: 0 8px 24px rgba(35, 20, 45, 0.05);
        margin: 24px 0;
        padding: 20px;
    }

    .copex-home-panel__title {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 18px;
        margin: 0 0 20px 0;
        color: #873d84;
        font-size: 1.35rem;
        font-weight: 800;
        line-height: 1.25;
        text-align: center;
    }

    .copex-home-panel__title::before,
    .copex-home-panel__title::after {
        content: "";
        height: 1px;
        flex: 1 1 auto;
        max-width: 160px;
        background: #e8ddec;
    }

    .copex-home-news-grid,
    .copex-home-events-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 16px;
    }

    /* ---------------------------------------------------------------
       Carrusel de Actualidad (0.12.8.0)
       El bloque ocupa la fila completa y muestra 4 tarjetas a la vez.
       El desplazamiento usa scroll real con scroll-snap, de modo que
       sigue funcionando con el dedo y con el teclado aunque falle el
       JavaScript.
       --------------------------------------------------------------- */

    .copex-home-panel--wide {
        width: 100%;
    }

    .copex-news-carousel {
        position: relative;
    }

    .copex-news-carousel__viewport {
        min-width: 0;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
        -ms-overflow-style: none;
        scroll-behavior: smooth;
    }

    .copex-news-carousel__viewport::-webkit-scrollbar {
        display: none;
    }

    .copex-news-carousel__track {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: calc((100% - (var(--copex-visible) - 1) * 16px) / var(--copex-visible));
        gap: 16px;
        padding: 4px 2px;
    }

    .copex-news-carousel__track > .copex-home-news-card {
        scroll-snap-align: start;
    }

    .copex-news-carousel__dots {
        display: flex;
        justify-content: center;
        gap: 8px;
        margin-top: 14px;
    }

    .copex-news-carousel__dots button {
        width: 9px;
        height: 9px;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: #d9cfdd;
        cursor: pointer;
        transition: background .18s ease, transform .18s ease;
    }

    .copex-news-carousel__dots button.is-active {
        background: #873d84;
        transform: scale(1.25);
    }

    /* En el carrusel las tarjetas disponen de más ancho, así que la
       imagen crece y el extracto puede respirar hasta cinco líneas. */
    .copex-news-carousel .copex-home-news-card__image {
        height: 200px;
        line-height: 200px;
    }

    .copex-news-carousel .copex-home-news-card p {
        -webkit-line-clamp: 5;
        min-height: 6.9em;
    }

    .copex-news-carousel .copex-home-news-card h3 {
        font-size: 1rem;
    }

    @media (max-width: 1024px) {
        .copex-news-carousel__track {
            grid-auto-columns: calc((100% - 16px) / 2);
        }
    }

    @media (max-width: 600px) {
        .copex-news-carousel__track {
            grid-auto-columns: 100%;
        }
        .copex-news-carousel .copex-home-news-card p {
            -webkit-line-clamp: 4;
            min-height: 5.5em;
        }
    }

    @media (prefers-reduced-motion: reduce) {
        .copex-news-carousel__viewport {
            scroll-behavior: auto;
        }
        .copex-news-carousel__dots button.is-active {
            transform: none;
        }
    }

    .copex-home-news-card,
    .copex-home-event-card {
        display: flex;
        flex-direction: column;
        min-width: 0;
        background: #ffffff;
        border: 1px solid #e6e0e8;
        border-radius: 14px;
        overflow: hidden;
        box-shadow: 0 6px 18px rgba(35, 20, 45, 0.045);
    }

    .copex-home-news-card__image {
        display: block;
        height: 96px;
        background: linear-gradient(135deg, #f6eef8 0%, #ffffff 55%, #eee1f1 100%);
        color: #873d84;
        font-weight: 800;
        text-decoration: none !important;
        text-align: center;
        line-height: 96px;
    }

    .copex-home-news-card__image img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .copex-home-news-card__body,
    .copex-home-event-card {
        padding: 14px;
    }

    .copex-home-news-card time {
        display: block;
        margin: 0 0 8px 0;
        color: #873d84;
        font-size: 0.82rem;
        font-weight: 700;
    }

    .copex-home-news-card h3,
    .copex-home-event-card h3 {
        margin: 0 0 10px 0 !important;
        color: #182033;
        font-size: 0.93rem;
        font-weight: 800;
        line-height: 1.28;
        white-space: normal !important;
        overflow: visible;
        text-overflow: initial;
    }

    .copex-home-news-card h3 a,
    .copex-home-event-card h3 a {
        color: inherit;
        text-decoration: none !important;
        white-space: normal !important;
        overflow-wrap: break-word;
        word-break: normal;
        text-overflow: initial !important;
    }

    .copex-home-news-card h3 a {
        display: -webkit-box !important;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        min-height: 2.55em;
        overflow: hidden !important;
    }

    .copex-home-news-card h3 a:hover,
    .copex-home-event-card h3 a:hover {
        color: #873d84;
    }

    .copex-home-news-card p,
    .copex-home-event-card p {
        margin: 0 0 14px 0 !important;
        color: #4d5567;
        font-size: 0.84rem;
        line-height: 1.38;
        white-space: normal !important;
        overflow-wrap: break-word;
        word-break: normal;
        text-overflow: initial !important;
    }

    .copex-home-news-card p {
        display: -webkit-box !important;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        min-height: 4.14em;
        overflow: hidden !important;
    }

    .copex-home-news-card__body {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
    }

    .copex-home-mini-button {
        align-self: flex-start;
        margin-top: auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 8px 16px;
        border: 2px solid rgba(135, 61, 132, 0.45);
        border-radius: 8px;
        color: #873d84 !important;
        background: #ffffff;
        font-size: 0.86rem;
        font-weight: 800;
        text-decoration: none !important;
        transition: background .18s ease, border-color .18s ease, color .18s ease;
    }

    .copex-home-mini-button:hover,
    .copex-home-panel__button:hover {
        background: #873d84;
        border-color: #873d84;
        color: #ffffff !important;
    }

    .copex-home-event-card {
        min-height: 245px;
    }

    .copex-home-event-card__date {
        margin: 0 0 18px 0;
        color: #873d84;
        line-height: 1;
    }

    .copex-home-event-card__date strong {
        display: block;
        font-size: 1.55rem;
        font-weight: 900;
        letter-spacing: 0.02em;
    }

    .copex-home-event-card__date span {
        display: block;
        margin-top: 4px;
        font-size: 0.85rem;
        font-weight: 800;
        letter-spacing: 0.06em;
    }

    .copex-home-panel__footer {
        display: flex;
        justify-content: center;
        margin-top: 18px;
    }

    .copex-home-panel__button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 210px;
        padding: 10px 22px;
        border: 2px solid rgba(135, 61, 132, 0.45);
        border-radius: 10px;
        color: #873d84 !important;
        background: #ffffff;
        font-weight: 800;
        text-decoration: none !important;
        transition: background .18s ease, border-color .18s ease, color .18s ease;
    }

    .copex-home-panel__empty {
        margin: 0;
        padding: 18px;
        text-align: center;
        color: #4d5567;
        background: #f8fafc;
        border-radius: 12px;
    }

    @media (max-width: 680px) {
        .copex-home-panel {
            padding: 16px;
        }

        .copex-home-panel__title {
            gap: 10px;
            font-size: 1.15rem;
        }

        .copex-home-panel__title::before,
        .copex-home-panel__title::after {
            max-width: 70px;
        }

        .copex-home-news-grid,
        .copex-home-events-grid {
            grid-template-columns: 1fr;
        }
    }

    .copex-hide-extra-participant-link {
        display: none !important;
    }

    .copex-subsanacion-box {
        max-width: 900px;
        margin-bottom: 24px;
    }

    .copex-subsanacion-info {
        background: #fff7ed;
        border-left: 4px solid #c2410c;
        padding: 14px 16px;
        border-radius: 10px;
        margin: 16px 0;
    }

    .copex-subsanacion-info p {
        margin: 0 0 10px;
    }

    .copex-subsanacion-info p:last-child {
        margin-bottom: 0;
    }

    .copex-subsanacion-form label:not(.copex-checkbox) {
        display: block;
        margin: 14px 0 7px;
        font-weight: 700;
    }

    .copex-subsanacion-form input[type="text"],
    .copex-subsanacion-form input[type="file"],
    .copex-subsanacion-form textarea {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .copex-document-upload-list {
        display: grid;
        gap: 14px;
        margin: 16px 0;
    }

    .copex-document-upload-item {
        position: relative;
        border: 1px solid #e5e7eb;
        border-radius: 14px;
        padding: 22px 16px 16px;
        background: #f9fafb;
    }

    .copex-document-upload-item legend {
        padding: 0 8px;
        font-weight: 800;
        color: #873d84;
    }

    .copex-document-remove {
        position: absolute;
        top: 10px;
        right: 12px;
        width: 28px;
        height: 28px;
        border: 0;
        border-radius: 999px;
        background: #873d84;
        color: #ffffff;
        font-size: 22px;
        font-weight: 700;
        line-height: 26px;
        text-align: center;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        transition: all .18s ease;
    }

    .copex-document-remove:hover:not(:disabled) {
        background: #6f2f6d;
        color: #ffffff;
    }

    .copex-document-remove.is-disabled,
    .copex-document-remove:disabled {
        background: #e5e7eb;
        color: #9ca3af;
        cursor: not-allowed;
        opacity: 1;
    }

    .copex-button-secondary {
        background: #f3e8f2;
        color: #873d84;
        border: 1px solid #d8b6d6;
        margin-bottom: 8px;
    }

    .copex-button-secondary:hover {
        background: #ead4e8;
        color: #873d84;
    }

    .copex-documentos-aportados {
        max-width: 900px;
        margin-top: 22px;
        padding-top: 10px;
    }

    .copex-documentos-aportados h3 {
        margin-top: 0;
    }

    /* Buscadores públicos SearchKit */
    .copex-search-publico .crm-search-display table {
        table-layout: fixed;
        width: 100%;
    }

    .copex-search-publico .crm-search-display table th,
    .copex-search-publico .crm-search-display table td {
        padding: 12px 10px !important;
        vertical-align: top;
        line-height: 1.35;
    }

    .copex-search-publico .crm-search-display table th {
        font-size: 0.9rem;
    }

    .copex-search-publico .crm-search-display table td {
        font-size: 0.95rem;
    }

    .copex-search-publico .crm-search-display table td a {
        color: #8d3b8c;
        font-weight: 600;
        text-decoration: none;
    }

    .copex-search-publico .crm-search-display table td a:hover {
        text-decoration: underline;
    }

    /* Ocultar primera columna técnica en displays con selección interna */
    .copex-search-publico .crm-search-display table th:nth-child(1),
    .copex-search-publico .crm-search-display table td:nth-child(1) {
        display: none !important;
        width: 0 !important;
        max-width: 0 !important;
        padding: 0 !important;
        border: 0 !important;
    }

    /* Cursos y seminarios */
    .copex-search-cursos .crm-search-display table th:nth-child(2),
    .copex-search-cursos .crm-search-display table td:nth-child(2) { width: 28% !important; }
    .copex-search-cursos .crm-search-display table th:nth-child(3),
    .copex-search-cursos .crm-search-display table td:nth-child(3) { width: 10% !important; }
    .copex-search-cursos .crm-search-display table th:nth-child(4),
    .copex-search-cursos .crm-search-display table td:nth-child(4) { width: 10% !important; white-space: nowrap; }
    .copex-search-cursos .crm-search-display table th:nth-child(5),
    .copex-search-cursos .crm-search-display table td:nth-child(5) { width: 8% !important; white-space: nowrap; }
    .copex-search-cursos .crm-search-display table th:nth-child(6),
    .copex-search-cursos .crm-search-display table td:nth-child(6) { width: 8% !important; }
    .copex-search-cursos .crm-search-display table th:nth-child(7),
    .copex-search-cursos .crm-search-display table td:nth-child(7) { width: 18% !important; }
    .copex-search-cursos .crm-search-display table th:nth-child(8),
    .copex-search-cursos .crm-search-display table td:nth-child(8) { width: 6% !important; text-align: center; white-space: nowrap; }
    .copex-search-cursos .crm-search-display table th:nth-child(9),
    .copex-search-cursos .crm-search-display table td:nth-child(9) { width: 14% !important; }
    .copex-search-cursos .crm-search-display table th:nth-child(10),
    .copex-search-cursos .crm-search-display table td:nth-child(10) { width: 8% !important; text-align: center; white-space: nowrap; }

    /* Formación externa */
    .copex-search-externa .crm-search-display table th:nth-child(2),
    .copex-search-externa .crm-search-display table td:nth-child(2) { width: 28% !important; }
    .copex-search-externa .crm-search-display table th:nth-child(3),
    .copex-search-externa .crm-search-display table td:nth-child(3) { width: 10% !important; white-space: nowrap; }
    .copex-search-externa .crm-search-display table th:nth-child(4),
    .copex-search-externa .crm-search-display table td:nth-child(4) { width: 9% !important; white-space: nowrap; }
    .copex-search-externa .crm-search-display table th:nth-child(5),
    .copex-search-externa .crm-search-display table td:nth-child(5) { width: 10% !important; }
    .copex-search-externa .crm-search-display table th:nth-child(6),
    .copex-search-externa .crm-search-display table td:nth-child(6) { width: 17% !important; }
    .copex-search-externa .crm-search-display table th:nth-child(7),
    .copex-search-externa .crm-search-display table td:nth-child(7) { width: 6% !important; text-align: center; white-space: nowrap; }
    .copex-search-externa .crm-search-display table th:nth-child(8),
    .copex-search-externa .crm-search-display table td:nth-child(8) { width: 10% !important; }
    .copex-search-externa .crm-search-display table th:nth-child(9),
    .copex-search-externa .crm-search-display table td:nth-child(9) { width: 10% !important; text-align: center; }
    .copex-search-externa .crm-search-display table th:nth-child(10),
    .copex-search-externa .crm-search-display table td:nth-child(10) { width: 8% !important; text-align: center; white-space: nowrap; }

    /* Eventos y agenda */
    .copex-search-agenda .crm-search-display table th:nth-child(2),
    .copex-search-agenda .crm-search-display table td:nth-child(2) { width: 30% !important; }
    .copex-search-agenda .crm-search-display table th:nth-child(3),
    .copex-search-agenda .crm-search-display table td:nth-child(3) { width: 14% !important; }
    .copex-search-agenda .crm-search-display table th:nth-child(4),
    .copex-search-agenda .crm-search-display table td:nth-child(4) { width: 12% !important; white-space: nowrap; }
    .copex-search-agenda .crm-search-display table th:nth-child(5),
    .copex-search-agenda .crm-search-display table td:nth-child(5) { width: 16% !important; }
    .copex-search-agenda .crm-search-display table th:nth-child(6),
    .copex-search-agenda .crm-search-display table td:nth-child(6) { width: 9% !important; white-space: nowrap; }
    .copex-search-agenda .crm-search-display table th:nth-child(7),
    .copex-search-agenda .crm-search-display table td:nth-child(7) { width: 13% !important; }
    .copex-search-agenda .crm-search-display table th:nth-child(8),
    .copex-search-agenda .crm-search-display table td:nth-child(8) { width: 6% !important; text-align: center; white-space: nowrap; }

    /* Agenda interna Junta */
    .copex-search-junta-agenda .crm-search-display table th:nth-child(2),
    .copex-search-junta-agenda .crm-search-display table td:nth-child(2) { width: 26% !important; }
    .copex-search-junta-agenda .crm-search-display table th:nth-child(3),
    .copex-search-junta-agenda .crm-search-display table td:nth-child(3) { width: 14% !important; }
    .copex-search-junta-agenda .crm-search-display table th:nth-child(4),
    .copex-search-junta-agenda .crm-search-display table td:nth-child(4) { width: 11% !important; white-space: nowrap; }
    .copex-search-junta-agenda .crm-search-display table th:nth-child(5),
    .copex-search-junta-agenda .crm-search-display table td:nth-child(5) { width: 10% !important; text-align: center; white-space: nowrap; }
    .copex-search-junta-agenda .crm-search-display table th:nth-child(6),
    .copex-search-junta-agenda .crm-search-display table td:nth-child(6) { width: 14% !important; }
    .copex-search-junta-agenda .crm-search-display table th:nth-child(7),
    .copex-search-junta-agenda .crm-search-display table td:nth-child(7) { width: 13% !important; text-align: center; }
    .copex-search-junta-agenda .crm-search-display table th:nth-child(8),
    .copex-search-junta-agenda .crm-search-display table td:nth-child(8) { width: 12% !important; text-align: center; }

    @media (max-width: 900px) {
        .copex-search-publico .crm-search-display {
            overflow-x: auto;
        }

        .copex-search-publico .crm-search-display table {
            min-width: 760px;
        }
    }
