/* CSS para el widget TN Ficha Planta */
.elementor-widget-tn-ficha-planta-list .hfg-species-grid-page { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
}


/* --- INICIO ESTILOS FORMULARIO DE BÚSQUEDA Y FILTRO --- */
.elementor-widget-tn-ficha-planta-list .tn-species-filters-container {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f8f9fa; 
    border: 1px solid #dee2e6;
    border-radius: 6px;
}
.elementor-widget-tn-ficha-planta-list .tn-species-search-form {
    display: flex;
    flex-wrap: wrap; 
    gap: 15px; 
    align-items: flex-end; 
}
.elementor-widget-tn-ficha-planta-list .tn-search-field-wrapper {
    flex-grow: 1; 
    min-width: 250px;
    position: relative;
}
.elementor-widget-tn-ficha-planta-list .tn-genus-filter-wrapper {
    min-width: 200px; 
    flex-basis: 200px; 
    flex-grow: 0;
}
.elementor-widget-tn-ficha-planta-list .tn-species-search-form .search-field,
.elementor-widget-tn-ficha-planta-list .tn-species-search-form .tn-select-filter {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1em;
    box-sizing: border-box; 
}
.elementor-widget-tn-ficha-planta-list .tn-species-search-form .search-submit,
.elementor-widget-tn-ficha-planta-list .tn-species-search-form .reset-filters-btn {
    padding: 10px 12px; 
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none; 
    line-height: 1.5; 
    flex-shrink: 0;
}
.elementor-widget-tn-ficha-planta-list .tn-species-search-form .search-submit {
    background-color: #5a8a30;
}
.elementor-widget-tn-ficha-planta-list .tn-species-search-form .search-submit:hover {
    background-color: #4a7a20;
}
.elementor-widget-tn-ficha-planta-list .tn-species-search-form .reset-filters-btn {
    background-color: #6c757d; 
}
.elementor-widget-tn-ficha-planta-list .tn-species-search-form .reset-filters-btn:hover {
    background-color: #5a6268;
}
.elementor-widget-tn-ficha-planta-list .tn-species-search-form .dashicons {
    font-size: 20px; 
    height: auto;
    width: auto;
    line-height: 1; 
}

/* Estilos para jQuery UI Autocomplete */
.ui-autocomplete { 
    position: absolute; 
    z-index: 100001 !important; 
    max-height: 250px; 
    overflow-y: auto; 
    overflow-x: hidden; 
    border: 1px solid #ccc; 
    background-color: white; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); 
    list-style: none; 
    padding: 0; margin: 0; 
    width: auto !important; 
}
.ui-menu-item { 
    padding: 6px 10px; 
    cursor: pointer; 
    border-bottom: 1px solid #eee; 
}
.ui-menu-item .ui-menu-item-wrapper:hover { 
    background-color: #f0f0f0; 
}
.ui-menu-item:last-child { 
    border-bottom: none; 
}
.ui-autocomplete-category { 
    font-weight: bold; padding: .3em .5em; margin: .5em 0 .2em; 
    line-height: 1.4; border-bottom: 1px dotted #ccc; 
    color: #2c3e50; background-color: #ecf0f1; 
    display: block; 
}
/* --- FIN ESTILOS FORMULARIO --- */


/* Estilos de la cuadrícula de especies */
.elementor-widget-tn-ficha-planta-list .hfg-species-grid-container {
    display: grid;
    gap: 20px;
    margin-top: 20px;
}

.elementor-widget-tn-ficha-planta-list .hfg-species-grid-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}
.elementor-widget-tn-ficha-planta-list .hfg-item-image-wrapper {
    width: 100%;
    padding-top: 75%; 
    position: relative;
    background-color: #f0f0f0;
}
.elementor-widget-tn-ficha-planta-list .hfg-item-image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.elementor-widget-tn-ficha-planta-list .hfg-item-info {
    padding: 12px;
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.elementor-widget-tn-ficha-planta-list .hfg-item-species-name {
    font-size: 1.1em; 
    font-weight: 600; 
    margin-top: 0;
    margin-bottom: 4px;
    color: #333;
}
.elementor-widget-tn-ficha-planta-list .hfg-item-family {
    font-size: 0.85em; 
    color: #555; 
    margin-top: 0;
    margin-bottom: 10px;
}
.elementor-widget-tn-ficha-planta-list .hfg-ver-ficha-btn {
    display: inline-block;
    padding: 8px 12px;
    background-color: #5a8a30;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s;
    margin-top: auto;
}
.elementor-widget-tn-ficha-planta-list .hfg-ver-ficha-btn:hover {
    background-color: #4a7a20;
}

/* --- INICIO ESTILOS DEL MODAL MEJORADO Y GALERÍA CON SCROLL --- */

.hfg-modal-tn {
    position: fixed;
    z-index: 100000; 
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; 
    background-color: rgba(0,0,0,0.7);
    display: none; 
    align-items: center;
    justify-content: center;
}
body .hfg-modal-tn[style*="display: block;"],
body .hfg-modal-tn[style*="display: flex;"] {
    display: flex !important; 
    align-items: center !important;
    justify-content: center !important;
}
.hfg-modal-tn .hfg-modal-content-wrapper{
    max-height: 95vh;
    width: 95%;
    max-width: 1100px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    animation: hfg-modal-appear-tn 0.3s ease-out;
}
.hfg-modal-tn .hfg-modal-content {
    padding: 30px;
    overflow-y: auto; 
    flex-grow: 1;
    position: relative;
}

/* Botón de Cierre Moderno (Dashicon) */
.hfg-modal-tn .hfg-modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 24px;
    color: #A51352; /* Color del botón de cerrar */
    z-index: 10;
    padding: 5px;
    line-height: 1;
    transition: color 0.2s, transform 0.2s;
}
.hfg-modal-tn .hfg-modal-close-btn:hover {
    color: #8C1045; 
    transform: rotate(90deg);
}
.hfg-modal-tn .hfg-modal-close-btn .dashicons {
    width: 20px;
    height: 20px;
    font-size: 20px;
    line-height: 1;
}

.hfg-modal-tn .hfg-modal-title {
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 2em;
    color: #333;
    border-bottom: 2px solid #5a8a30;
    padding-bottom: 10px;
    padding-right: 50px;
}

/* Contenedor Principal: 2 Columnas en Desktop */
.hfg-modal-tn .hfg-modal-main-content {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
}

/* Columna de Galería (ocupa 40% en desktop) */
.hfg-modal-tn #hfg-modal-photos-fichas-section {
    order: 1;
    flex-basis: 100%;
    padding: 0;
    margin: 0;
    border-top: none;
    padding-top: 0;
    max-width: 100%; 
}
/* Estilos para el título de Fotos */
.hfg-modal-tn #hfg-modal-photos-fichas-section strong {
    font-size: 1.1em;
    color: #333;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px dotted #ccc;
}

.hfg-modal-tn #hfg-modal-large-image-display {
    background-color: #f1f7f0; 
    border: 1px solid #e0e0e0;
    padding: 15px;
    margin-top: 0;
    max-width: 100%; 
    box-sizing: border-box;
}
.hfg-modal-tn #hfg-modal-large-image-display img {
    max-height: 60vh;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 4px;
    object-fit: contain; 
}

/* *** CLASES CRÍTICAS PARA EL SCROLL INTERNO (Solución al desbordamiento) *** */

/* 1. Contenedor que LIMITA el ancho del carrete. */
.hfg-modal-tn .hfg-thumbnail-strip-container {
    /* CLAVE: Asegura que nunca sea más ancho que su padre (la sección de fotos) */
    max-width: 100%; 
    /* CLAVE: HABILITA el scroll horizontal SÓLO en esta barra */
    overflow-x: auto; 
    overflow-y: hidden;
    padding: 10px 5px; 
    background-color: #f8f8f8;
    border-radius: 4px;
}

/* 2. El carrete interno que se ESTIRA para forzar el scroll. */
.hfg-modal-tn #hfg-modal-thumbnail-strip {
    /* CLAVE: Mantiene todas las miniaturas en una sola línea */
    display: flex;
    flex-wrap: nowrap; 
    /* CLAVE: Fuerza al elemento a tener el ancho necesario para su contenido */
    width: max-content; 
    padding: 0; 
    gap: 5px; 
    /* Reglas de prioridad alta */
    min-width: 100%; 
}

/* Mensaje sin fotos (estilo) */
.hfg-no-photos-message {
    font-style: italic;
    color: #999;
    text-align: center;
    padding: 20px 0;
}
/* *** FIN CLASES CRÍTICAS *** */


/* Estilos de las miniaturas */
.hfg-modal-tn #hfg-modal-thumbnail-strip img {
    width: 50px; 
    height: 50px; 
    object-fit: cover;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    flex-shrink: 0; 
    
    /* Propiedades para BLOQUEAR el arrastre de imagen */
    user-select: none; 
    -moz-user-select: none; 
    -webkit-user-select: none;
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: auto; 
}
.hfg-modal-tn #hfg-modal-thumbnail-strip img:hover {
    border-color: #5a8a30; 
}
.hfg-modal-tn #hfg-modal-thumbnail-strip img.hfg-thumb-active {
    border-color: #5a8a30;
    box-shadow: 0 0 5px rgba(90, 138, 48, 0.5);
}


/* Columna de Detalles (ocupa 60% en desktop) */
.hfg-modal-tn .hfg-modal-details-sections {
    order: 2;
    flex-basis: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Layout de Órganos: 2 columnas en Desktop */
.hfg-modal-tn .hfg-modal-organ-details {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}
.hfg-modal-tn .hfg-modal-organ-details .hfg-modal-section {
    flex-basis: 100%;
}


/* Estilos de Tarjeta (Card) para secciones de detalles */
.hfg-modal-tn .hfg-modal-section-card {
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 8px;
    background-color: #fafafa;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}


/* Estilo de los encabezados de sección con iconos */
.hfg-modal-tn .hfg-modal-section strong {
    display: inline; 
    margin-bottom: 0; 
    color: #333;
    font-size: 1em;
    font-weight: 700;
    letter-spacing: 0;
}
/* Aplicación del color al icono Dashicon/SVG */
.hfg-modal-tn .hfg-modal-section strong .dashicons,
.hfg-modal-tn .hfg-modal-section strong svg {
    color: #5a8a30; /* Color Dashicon */
    fill: #5a8a30; /* Color SVG */
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin-right: 5px;
    vertical-align: middle;
}

.hfg-modal-tn .hfg-modal-content-body {
    margin-top: 5px;
    font-size: 0.95em;
    line-height: 1.5;
    color: #555;
}

/* Media Query para Desktop: Implementar 2 y 3 Columnas */
@media (min-width: 768px) {
    .hfg-modal-tn .hfg-modal-main-content {
        flex-wrap: nowrap;
    }

    .hfg-modal-tn #hfg-modal-photos-fichas-section {
        flex-basis: 40%;
        max-width: 40%;
    }
    
    .hfg-modal-tn .hfg-modal-details-sections {
        flex-basis: 60%;
        max-width: 60%;
    }
    
    /* Tres columnas para detalles de órganos (Hoja, Flor, Fruto) */
    .hfg-modal-tn .hfg-modal-organ-details {
        flex-wrap: nowrap;
        gap: 15px;
    }
    .hfg-modal-tn .hfg-modal-organ-details .hfg-modal-section {
        flex-basis: calc(33.333% - 10px);
        flex-grow: 1;
    }
    
}


/* Estilos del botón de volver/cerrar (al final del modal) */
.hfg-modal-tn .hfg-modal-back-btn {
    display: block; 
    width: auto;
    margin-top: 30px;
    margin-left: 0;
    padding: 10px 20px;
    background-color: #A51352; /* Color del botón de Volver/Cerrar (asumo que se mantiene) */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s;
    text-align: center;
}
.hfg-modal-tn .hfg-modal-back-btn:hover { background-color: #8C1045; }


/* --- ESTILOS DE PAGINACIÓN --- */
.elementor-widget-tn-ficha-planta-list .tn-species-pagination {
    margin-top: 30px;
    margin-bottom: 60px; 
    text-align: center;
    clear: both; 
    position: relative; 
    z-index: 1; 
}
.elementor-widget-tn-ficha-planta-list .tn-species-pagination ul.page-numbers {
    list-style-type: none !important; 
    padding-left: 0 !important;   
    margin-left: 0 !important;     
    display: inline-block; 
}

.elementor-widget-tn-ficha-planta-list .tn-species-pagination ul.page-numbers li {
    display: inline;      
    margin: 0; 
}

.elementor-widget-tn-ficha-planta-list .tn-species-pagination .page-numbers {
    display: inline-block; 
    padding: 8px 15px; 
    margin: 0 3px; 
    border: 1px solid #ddd; 
    color: #5a8a30;
    background-color: #fff;
    text-decoration: none;
    border-radius: 4px;
}

.elementor-widget-tn-ficha-planta-list .tn-species-pagination a.page-numbers:hover {
    border-color: #ababab;
    cursor: pointer;
}

.elementor-widget-tn-ficha-planta-list .tn-species-pagination span.page-numbers.current {
    background-color: #5a8a30; 
    color: #ffffff !important; 
    border-color: #4a7a20; 
    font-weight: bold;
    cursor: default; 
}

.elementor-widget-tn-ficha-planta-list .tn-species-pagination .page-numbers.dots {
    border-color: transparent;
    background-color: transparent;
    color: #777;
    cursor: default;
    padding: 8px 5px;
}
/* --- FIN ESTILOS DE PAGINACIÓN --- */

.elementor-widget-tn-ficha-planta-list .tn-no-species-found {
    padding: 20px;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    border-radius: 4px;
    text-align: center;
}