/* ===== GUÍA DE MANEJO - ESTILOS LIMPIOS ===== */

/* Layout Principal */
.guide-layout {
    display: flex;
    gap: 2rem;
    padding: 2rem;
    padding-top: 2rem; /* Espacio mínimo para el navbar fijo */
    max-width: 1400px;
    margin: 0 auto;
    align-items: flex-start;
    position: relative;
    scroll-padding-top: 120px; /* Offset para scroll suave - altura del header fijo */
}

/* Contenido Principal */
.guide-content {
    flex: 1;
    margin-left: 0;
    min-width: 0;
    background: var(--gray-50);
    border-radius: 1rem;
}

/* Secciones de la Guía */
.guide-content .section {
    padding: 2rem;
    position: relative;
    scroll-margin-top: 120px; /* Offset para scroll suave en cada sección */
}

.guide-content .section:first-child {
    margin-top: 0;
}

/* Contenido de Texto */
.text-content {
    max-width: none;
    margin: 0;
    line-height: 1.8;
    padding: 0;
}

.text-content h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0 0 1rem 0;
    text-align: left;
    position: relative;
    display: inline-block;
}

.text-content h2::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 0;
    width: 100%;
    height: 10px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 10' preserveAspectRatio='none'%3E%3Cpath d='M0,5 Q25,1 50,5 T100,5' stroke='%2387a96b' stroke-width='3' fill='none'/%3E%3C/svg%3E") no-repeat;
    background-size: 100% 100%;
    opacity: 0.8;
}

.text-content h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    margin: 1.25rem 0 0.75rem 0;
    position: relative;
    display: inline-block;
}

.text-content h3::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 100%;
    height: 8px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 8' preserveAspectRatio='none'%3E%3Cpath d='M0,4 Q25,1 50,4 T100,4' stroke='%236b8e23' stroke-width='2.5' fill='none'/%3E%3C/svg%3E") no-repeat;
    background-size: 100% 100%;
    opacity: 0.6;
}

.text-content p {
    margin: 0.75rem 0;
    color: var(--gray-700);
    font-size: 1.1rem;
    text-align: justify;
}

.text-content strong {
    color: var(--primary);
    font-weight: 600;
}

/* Estilos para listas */
.text-content ul {
    margin: 1rem 0;
    padding-left: 2rem;
    list-style-position: outside;
}

.text-content li {
    margin: 0.5rem 0;
    padding-left: 0.5rem;
    color: var(--gray-700);
    font-size: 1.1rem;
    line-height: 1.8;
}

/* ===== ÍNDICE DESKTOP ===== */

/* Contenedor del Índice */
.guide-index-container {
    width: 300px;
    flex-shrink: 0;
}

/* Índice Estático */
.guide-index-static {
    width: 100%;
    background: var(--forest-green);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-medium);
    position: sticky;
    top: calc(80px + 20px); /* Altura típica del header + margen (se ajusta dinámicamente con JS) */
}

/* Índice Fijo (que acompaña al scroll) */
.guide-index-fixed {
    width: 300px;
    background: var(--forest-green);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-large);
    z-index: 100;
    display: none;
}

.guide-index h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    margin-bottom: 1rem;
    text-align: center;
}

.index-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.index-link {
    display: block;
    padding: 0.75rem 1rem;
    color: white;
    text-decoration: none;
    font-weight: 400;
    transition: all 0.2s ease;
    margin-bottom: 0;
    border-radius: 0.25rem;
    border-left: 3px solid transparent;
}

.index-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: var(--sage);
    transform: translateX(5px);
}

/* ===== ÍNDICE MOBILE ===== */

/* Tab Mobile */
.mobile-index-tab {
    display: none;
    position: fixed;
    top: 90px; /* Inicial, se ajusta dinámicamente con JS según altura del header */
    right: 1rem;
    width: 120px;
    background: var(--primary);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    z-index: 150;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-medium);
    transition: all 0.3s ease;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
}

.mobile-index-tab:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.mobile-index-tab i {
    transition: transform 0.3s ease;
}

.mobile-index-tab.active {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.mobile-index-tab.active i {
    transform: rotate(180deg);
}

.mobile-index-tab.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Overlay Mobile */
.mobile-index-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 160;
    display: none;
}

/* Contenido del Índice Mobile */
.mobile-index-content {
    position: fixed;
    top: 90px; /* Inicial, idealmente debería ajustarse dinámicamente */
    left: 1rem;
    right: 1rem;
    background: var(--forest-green);
    z-index: 160;
    display: none;
    padding: 1.5rem;
    box-sizing: border-box;
    border-radius: 0 0 1rem 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-height: calc(100vh - 110px); /* Ajustado para dar más espacio al header variable */
    overflow-y: auto;
}

/* Botón de cerrar del índice mobile */
.mobile-index-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 170;
}

.mobile-index-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.mobile-index-close:active {
    transform: scale(0.95);
}

.mobile-index-content .index-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-width: 500px;
    margin: 0 auto;
    padding-top: 1rem; /* Espacio para el botón de cerrar */
}

.mobile-index-content .index-link {
    display: block;
    padding: 0.75rem 1rem;
    color: white;
    text-decoration: none;
    font-weight: 400;
    font-size: 1rem;
    transition: all 0.2s ease;
    text-align: left;
    border-radius: 0.25rem;
    border-left: 3px solid transparent;
}

.mobile-index-content .index-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: var(--sage);
    transform: translateX(5px);
}

.mobile-index-content .index-link:active {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(2px);
}

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

/* Mobile y Tablet - Vista vertical con botón flotante */
@media (max-width: 1199px) {
    .guide-layout {
        padding: 0.5rem;
        padding-top: 4rem;
    }
    
    .mobile-index-tab {
        display: flex;
    }
    
    .guide-index-container {
        display: none;
    }
    
    .guide-index-fixed {
        display: none !important;
    }
    
    .guide-content {
        width: 100%;
    }
    
    .guide-content .section {
        padding: 1.5rem 1rem;
    }
    
    .text-content {
        max-width: none;
        margin: 0;
        line-height: 1.8;
        padding: 0;
    }
    
    .text-content h2 {
        font-size: 1.75rem;
        margin: 0 0 0.75rem 0;
    }
    
    .text-content h2::after {
        height: 8px;
        bottom: -10px;
    }
    
    .text-content h3 {
        font-size: 1.25rem;
        margin: 1rem 0 0.5rem 0;
    }
    
    .text-content h3::after {
        height: 6px;
        bottom: -6px;
        width: 100%;
    }
    
    .text-content p {
        font-size: 1rem;
        margin: 0.5rem 0;
    }
    
    .text-content ul {
        padding-left: 1.5rem;
        margin: 0.75rem 0;
    }
    
    .text-content li {
        margin: 0.4rem 0;
        padding-left: 0.25rem;
        font-size: 1rem;
    }
    
    .section-title {
        margin-top: 0 !important;
        margin-bottom: 1rem !important;
    }
    
    .fade-in {
        transform: translateY(0) !important;
        opacity: 1 !important;
    }
    
    .index-nav {
        flex-direction: column;
    }
    
    .index-link {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }
}

/* ===== ESTILOS PARA GALERÍAS EN ARTÍCULOS ===== */

/* Overlay para galerías de imágenes en artículos (plagas, enfermedades, etc) */
.guide-content .image-gallery .gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    padding: 2rem 1.5rem 1.5rem;
    transform: translateY(100%);
    transition: all 0.3s ease;
    pointer-events: none;
}

.guide-content .image-gallery .gallery-item:hover .gallery-overlay {
    transform: translateY(0);
}

.guide-content .image-gallery .gallery-overlay h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: white;
}

.guide-content .image-gallery .gallery-overlay p {
    font-size: 0.9rem;
    opacity: 0.9;
    color: white;
    margin: 0;
}

/* Imagen embebida a la derecha (Phytophthora en enfermedades.html) */
.guide-content .section .text-content .phytophthora-image-embedded {
    display: block !important; /* Sobrescribir display: grid de main.css para permitir float */
    float: right;
    width: 350px;
    max-width: 350px;
    margin: 2.5rem 0 1.5rem 1.5rem !important; /* Margen superior para alinear con el párrafo */
    clear: right;
}

.guide-content .section .text-content .phytophthora-image-embedded .gallery-item {
    width: 100%;
    height: auto;
}

/* En mobile, la imagen no flota y está centrada */
@media (max-width: 1199px) {
    .guide-content .section .text-content .phytophthora-image-embedded {
        float: none !important;
        width: calc(100% + 2rem) !important;
        max-width: calc(100% + 2rem) !important;
        margin: 1.5rem -1rem !important;
        display: flex !important;
        justify-content: center;
        clear: both;
    }
    
    .guide-content .section .text-content .phytophthora-image-embedded .gallery-item {
        width: 100%;
        max-width: 500px;
    }
}
