/* Estilos específicos para la sección de Microscopías */

/* Ajuste para que el contenedor principal no sea flex (como en hongos) si no hay sidebar */
main.container { display: block !important; }

.micro-header { background-color: #f8f9fa; padding: 2rem; margin-bottom: 2rem; border-bottom: 1px solid #e9ecef; border-radius: 8px; }
.micro-filters { background: #fff; padding: 1.5rem; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); margin-bottom: 2rem; border: 1px solid #e9ecef; }

/* Estilos del formulario de filtros */
.filter-row { display: flex; gap: 15px; flex-wrap: wrap; align-items: end; margin-bottom: 15px; }
.filter-group { flex: 1; min-width: 200px; }
.search-group { flex: 2; }
.form-control { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }

/* Sección de Medidas */
.measures-section {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    margin-top: 15px;
    margin-bottom: 15px;
}
.measures-title { margin: 0 0 10px 0; font-size: 0.95rem; color: #555; font-weight: 600; border-bottom: 1px solid #ddd; padding-bottom: 5px; }
.measures-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
.measure-item label { display: block; margin-bottom: 4px; font-size: 0.9rem; font-weight: 600; color: #444; }
.input-pair { display: flex; gap: 5px; }
.input-pair input { width: 50%; }

.filter-actions { text-align: right; margin-top: 10px; }
.btn-clear {
    padding: 8px 20px; background-color: #6c757d; color: white; 
    border: none; border-radius: 4px; cursor: pointer; font-weight: bold;
    transition: background-color 0.2s;
}
.btn-clear:hover { background-color: #5a6268; }

.micro-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.micro-card { background: #fff; border: 1px solid #eee; border-radius: 8px; overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; display: flex; flex-direction: column; }
.micro-card:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.micro-card-img { height: auto; overflow: hidden; background: #f0f0f0; position: relative; display: block; }
.micro-card-img img { width: 100%; height: auto; display: block; }
.micro-card-body { padding: 15px; flex: 1; display: flex; flex-direction: column; }
.micro-title { font-size: 1.1rem; font-weight: bold; margin: 0 0 5px 0; color: #333; }
.micro-title a { text-decoration: none; color: inherit; }
.micro-meta { font-size: 0.85rem; color: #777; margin-bottom: 10px; }
.micro-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.micro-footer { margin-top: auto; padding-top: 10px; border-top: 1px solid #f5f5f5; display: flex; justify-content: space-between; align-items: center; }

/* Paginación */
.pagination { display: flex; justify-content: center; gap: 5px; margin-top: 3rem; }
.pagination a, .pagination span { padding: 8px 12px; border: 1px solid #ddd; border-radius: 4px; text-decoration: none; color: #333; }
.pagination a.active { background-color: #63783b; color: #fff; border-color: #63783b; }
.pagination a:hover:not(.active) { background-color: #f5f5f5; }

/* Botones de acción en tarjeta */
.btn-micro-info {
    background: #f8f9fa; border: 1px solid #ddd; color: #555;
    border-radius: 4px; padding: 4px 8px; cursor: pointer;
    font-size: 0.85rem; transition: all 0.2s;
}
.btn-micro-info:hover { background: #63783b; color: #fff; border-color: #63783b; }

/* Estilos Modal Simple */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 2000;
    display: flex; justify-content: center; align-items: center;
}
.modal-content {
    background: #fff; padding: 20px; border-radius: 8px;
    width: 90%; max-width: 500px; max-height: 80vh; overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); position: relative;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.modal-header h3 { margin: 0; font-size: 1.2rem; color: #333; }
.modal-close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #999; }
.modal-close-btn:hover { color: #333; }

/* Estilos Contenido Modal */
.micro-taxonomy {
    display: flex;
    flex-direction: column;
    border: 1px solid #eee;
    border-radius: 6px;
    overflow: hidden;
}
.micro-tax-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    background-color: #fff;
}
.micro-tax-row:last-child { border-bottom: none; }
.micro-tax-row:nth-child(odd) { background-color: #fcfcfc; }
.micro-tax-label { font-weight: 600; color: #555; }
.micro-tax-value { color: #333; font-style: italic; }

.micro-common-names, .micro-synonyms {
    list-style: none;
    padding: 0;
    margin: 0;
}
.micro-common-names li {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
}
.micro-common-names li:last-child { border-bottom: none; }
.micro-common-names img { margin-right: 12px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.micro-common-names .name { font-size: 1rem; color: #333; }

.micro-synonyms li {
    padding: 6px 0;
    border-bottom: 1px solid #f5f5f5;
}
.micro-synonyms li:last-child { border-bottom: none; }
.micro-synonyms .author { color: #888; font-size: 0.85em; margin-left: 6px; }

/* Ajustes responsive */
@media (max-width: 992px) {
    .micro-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .micro-filters form { flex-direction: column; align-items: stretch; }
}

@media (max-width: 600px) {
    .micro-grid { grid-template-columns: 1fr; }
}

/* --- Estilos específicos para filtros de microscopía (Prefijo micro-) --- */
.micro-measures-section {
    width: 100%;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}
.micro-measures-title {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
}
.micro-measures-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}
.micro-measure-item {
    display: flex;
    align-items: center;
    gap: 10px;
}
.micro-measure-item label {
    font-weight: 600;
}
.micro-input-pair {
    display: flex;
    gap: 5px;
}
.micro-input-pair input {
    width: 80px;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* --- Estilos para pestañas de medidas y datos brutos --- */
.micro-tabs-container { margin-top: 10px; }
.micro-tab-headers { display: flex; border-bottom: 1px solid #dee2e6; margin-bottom: 15px; }
.micro-tab-btn {
    background: none; border: none; padding: 10px 15px; cursor: pointer;
    font-weight: 600; color: #6c757d; border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.micro-tab-btn:hover { color: #495057; }
.micro-tab-btn.active { color: #63783b; border-bottom-color: #63783b; }
.micro-tab-content { display: none; animation: fadeIn 0.3s; }
.micro-tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.micro-measure-details p { margin: 5px 0; font-size: 0.95rem; }
.micro-measure-actions { margin-top: 15px; padding-top: 10px; border-top: 1px dashed #eee; }
.btn-raw-data {
    background-color: #17a2b8; color: white; border: none; padding: 5px 10px;
    border-radius: 4px; cursor: pointer; font-size: 0.85rem;
}
.btn-raw-data:hover { background-color: #138496; }
.micro-raw-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.85rem; }
.micro-raw-table th, .micro-raw-table td { border: 1px solid #dee2e6; padding: 5px; text-align: center; }
.micro-raw-table th { background-color: #f8f9fa; }
.raw-data-container { max-height: 200px; overflow-y: auto; margin-top: 10px; }

/* --- Estilos para cabecera de perfil --- */
.micro-header-content {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}
.micro-profile-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    flex-shrink: 0;
}
.micro-header-text h1 {
    margin: 0 0 5px 0;
    line-height: 1.2;
}
.micro-header-text p {
    margin: 0;
}

/* --- Estilos Ficha Detalle --- */
.micro-detail-view {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 8px;
    border: 1px solid #dcdcdc;
}

.micro-citation-bar { text-align: right; margin-bottom: 10px; }
.btn-micro-citation { background: #fff; border: 1px solid #ddd; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 0.85rem; color: #555; margin-left: 5px; transition: all 0.2s; }
.btn-micro-citation:hover { background: #f8f9fa; color: #333; border-color: #ccc; }

.micro-general-banner img { width: 100%; height: auto; display: block; border-radius: 8px 8px 0 0; }
.micro-general-banner { margin-bottom: 20px; background-color: #000;}

.micro-title-block { display: flex; justify-content: space-between; align-items: center; margin-top: -112px; flex-wrap: wrap; gap: 15px; position: relative; z-index: 10; margin-bottom: 25px; }
.micro-species-info h1 { margin: 0; color: #fff; font-size: 1.6rem; line-height: 1.2; word-wrap: break-word; overflow-wrap: break-word; }
.micro-author { margin: 0; font-style: italic; color: #cdcccc; font-size: 1.1rem; word-wrap: break-word; overflow-wrap: break-word; }

.micro-collab-profile { display: flex; align-items: center; gap: 15px; margin-right: 25px; }
.micro-collab-info { text-align: right; }
.micro-collab-name { display: block; font-weight: bold; color: #000; font-size: 1.4rem; background-color: #fff; padding: 0px 15px; border-radius: 4px; margin-right: -22px; }
.micro-collab-img { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; border: 3px solid #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }

.micro-species-banner img { width: 100%; height: auto; box-shadow: 0 4px 10px rgba(0,0,0,0.1); display: block; border-radius: 0 0 8px 8px; }
.micro-species-banner { margin-bottom: 30px; margin-top: -9px; }
.micro-species-info {flex: 1; min-width: 0; margin-top: 20px; margin-left: 10px; }

/* Ajuste para pantallas medianas donde el título se superpone incorrectamente */
@media (max-width: 1200px) {    
    .micro-species-info h1 { font-size: 1.3rem; }
    .micro-author { font-size: 0.96rem; line-height: 0.96rem;}
    .micro-species-info {
        margin-top: 40px; /* Bajado 20px extra */
        margin-bottom: -7px;
    }
    .container {padding: 5px!important;}
    .micro-detail-view {padding: 5px;}    
}

@media (max-width: 900px) {    
    .micro-species-info h1 { font-size: 1.18rem; }
    .micro-author { font-size: 0.9rem; line-height: 0.9rem;}
    .micro-species-info {
        margin-top: 50px; /* Bajado 20px extra */ 
        margin-bottom: -11px;       
    }
}

@media (max-width: 750px) {
    .micro-species-info h1 { font-size: 1.08rem; }
    .micro-author { font-size: 0.88rem; line-height: 0.88rem;}
    .micro-species-info {
        margin-top: 56px; /* Bajado 10px extra */   
        margin-bottom: -18px;    
    }
    .micro-collab-img { width: 45px; height: 45px; border-width: 2px; }
    .micro-collab-name { font-size: 1.05rem; padding: 0 11px; margin-right: -16px; }
    .micro-collab-profile { gap: 11px; margin-right: 19px; margin-top: 30px; margin-bottom: -3px; }
    .micro-header-text h1 { font-size: 1.8em;}
}

@media (max-width: 600px) {
    .micro-species-info h1 { font-size: 0.98rem; }
    .micro-author { font-size: 0.78rem; line-height: 0.78rem;}
    .micro-species-info {
        margin-top: 60px; /* Bajado 10px extra */   
        margin-bottom: -16px;    
    }
    .micro-collab-img { width: 34px; height: 34px; border-width: 1px; }
    .micro-collab-name { font-size: 0.8rem; padding: 0 8px; margin-right: -12px; }
    .micro-collab-profile { gap: 8px; margin-right: 14px; margin-top: 43px; margin-bottom: -3px; }   
    .micro-header-text h1 { font-size: 1.6em;} 
}
@media (max-width: 500px) {
    .micro-species-info h1 { font-size: 0.78rem; }
    .micro-author { font-size: 0.68rem; line-height: 0.68rem;}
    .micro-species-info {
        margin-top: 65px; /* Bajado 10px extra */   
        margin-bottom: -15px;    
    }
}
@media (max-width: 450px) {
    .micro-species-info h1 { font-size: 0.68rem; }
    .micro-author { font-size: 0.58rem; line-height: 0.58rem; }
    .micro-species-info {
        margin-top: 69px; /* Bajado 10px extra */   
        margin-bottom: -16px;    
    }
    .micro-collab-img { width: 31px; height: 31px; border-width: 1px; }
    .micro-collab-name { font-size: 0.72rem; padding: 0 7px; margin-right: -11px; }
    .micro-collab-profile { gap: 7px; margin-right: 13px; margin-top: 53px; margin-bottom: -10px; }
    .btn-micro-info { width: 100%;}
    .micro-header-text h1 { font-size: 1.2em;}
}
@media (max-width: 350px) {
    .micro-species-info h1 { font-size: 0.55rem; }
    .micro-author { font-size: 0.46rem; line-height: 0.46rem; }
    .micro-species-info {
        margin-top: 70px; /* Bajado 10px extra */   
        margin-bottom: -20px;    
    }
    .micro-collab-img { width: 29px; height: 29px; border-width: 1px; }
    .micro-collab-name { font-size: 0.65rem; padding: 0 6px; margin-right: -10px; }
    .micro-collab-profile { gap: 6px; margin-right: 12px; margin-top: 53px; margin-bottom: -10px; }
}

/* --- Ajuste responsive para cabecera de perfil --- */
@media (max-width: 600px) {
    .micro-header-content {
        flex-direction: column;
        text-align: center;
    }
}

/* --- Layout Descripción + Mapa --- */
.micro-content-row {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-top: 30px;
    align-items: flex-start;
}
.micro-description-block {
    flex: 2; /* Ocupa 2 partes (aprox 66%) */
    min-width: 0; /* Evita desbordamientos */
}
.micro-map-block {
    flex: 1; /* Ocupa 1 parte (aprox 33%) */
    min-width: 300px;
}
@media (max-width: 900px) {
    .micro-content-row {
        flex-direction: column;
    }
    .micro-description-block, .micro-map-block {
        width: 100%;
        flex: none;
    }
}

/* --- Botones de acción en ficha detalle --- */
.micro-detail-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* --- Galerías Macroscopía y Microscopía --- */
.micro-galleries-row {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-top: 40px;
    align-items: flex-start;
}
.micro-gallery-col {
    flex: 1;
    min-width: 300px;
}
.micro-gallery-title {
    font-size: 1.2rem;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 10px;
    margin-bottom: 15px;
}
.micro-gallery-wrapper {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.micro-gallery-main {
    position: relative;
    aspect-ratio: 4/3;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}
.micro-main-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
}
.micro-gal-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.4);
    color: white;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 1.5rem;
    transition: background 0.2s;
    z-index: 20;
}
.micro-gal-btn:hover { background: rgba(0,0,0,0.7); }
.micro-gal-btn.prev { left: 0; border-radius: 0 4px 4px 0; }
.micro-gal-btn.next { right: 0; border-radius: 4px 0 0 4px; }
.micro-gal-counter {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: bold;
}
.micro-gal-caption {
    padding: 12px 15px;
    font-size: 0.95rem;
    color: #555;
    border-top: 1px solid #eee;
    min-height: 45px;
    background: #fff;
}
.micro-gal-expand {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.4);
    color: white;
    border: none;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
    z-index: 20;
}
.micro-gal-expand:hover { background: rgba(0,0,0,0.7); }

/* Modal de Galería Específico */
.micro-gallery-overlay {
    background: rgba(0,0,0,0.9);
    flex-direction: row; /* Para alinear flechas e imagen */
    justify-content: space-between;
    padding: 0 20px;
}
.micro-gallery-content {
    position: relative;
    text-align: center;
    max-width: 85%;
    max-height: 90vh;
}
.micro-gallery-modal-img {
    max-width: 100%;
    max-height: 85vh;
    display: block;
    margin: 0 auto;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.micro-gallery-caption {
    color: #fff;
    margin-top: 10px;
    background: rgba(0,0,0,0.6);
    padding: 8px 15px;
    border-radius: 4px;
    display: inline-block;
    font-size: 1rem;
}
.micro-gallery-nav {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 3rem;
    cursor: pointer;
    padding: 0 20px;
    transition: color 0.2s;
    z-index: 2001;
    margin-right: 15px;
}
.micro-gallery-nav:hover, .gallery-close:hover { color: #fff; }
.gallery-close {
    position: absolute;
    top: 20px;
    right: 50px;
    color: #999;
    font-size: 3rem;
    opacity: 0.8;
    z-index: 2002;
}
@media (max-width: 768px) {
    .micro-galleries-row {
        flex-direction: column;
    }
    .micro-gallery-nav { font-size: 2rem; padding: 0 10px; }
}

.micro-gallery-counter {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #fff;
    font-size: 1.2rem;
    z-index: 2002;
    background: rgba(0,0,0,0.5);
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: bold;
}

/* --- Estilos para la sección de genética --- */
.micro-genetics-row {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}
.micro-genetics-title {
    font-size: 1.25rem;
    color: #2c3e50;
    margin-bottom: 1rem;
    border-bottom: 2px solid #63783b;
    padding-bottom: 0.5rem;
    display: inline-block;
}
.micro-genetics-content {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}
.micro-genetics-tree {
    flex: 0 0 100%;
    max-width: 100%;
}
@media (min-width: 768px) {
    .micro-genetics-tree {
        flex: 0 0 40%;
        max-width: 40%;
    }
}
.micro-genetics-tree img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
}
.micro-genetics-files {
    flex: 1;
    min-width: 300px;
}
.genetics-file-item {
    margin-bottom: 10px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
}
.genetics-file-summary {
    padding: 10px 15px;
    cursor: pointer;
    background-color: #fff;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.genetics-file-summary:hover {
    background-color: #f1f3f5;
}
.genetics-file-content {
    padding: 15px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    overflow-x: auto;
}
.genetics-file-content pre {
    margin: 0;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-all;
    color: #495057;
}

/* --- Estilos comunes para botones de acción --- */
.btn-micro-action {
    display: inline-block;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background-color: #63783b;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-right: 10px;
    line-height: 1.5;
    font-family: inherit;
    box-sizing: border-box;
}
.btn-micro-action:hover {
    background-color: #4e5d2e;
    color: #fff;
}
.btn-micro-action i {
    margin-right: 6px;
}

/* --- Adaptación móvil para botones de descarga AB1 --- */
@media (max-width: 768px) {
    .micro-ab1-actions .btn-micro-action {
        display: block;
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
        text-align: center;
    }
}