/* css/funerarias.css */

/* --- Page Header --- */
.page-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    text-align: center;
    padding: 80px 0 60px;
    margin-bottom: 0;
}

.page-header h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* --- Search Section --- */
.search-section {
    background: var(--bg-light);
    padding: 40px 0;
}

.search-bar {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input-container {
    flex: 1;
    position: relative;
    min-width: 300px;
}

.search-input-container i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.search-input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    box-sizing: border-box;
}

.search-input:focus {
    border-color: var(--accent-color);
    outline: none;
}

.filter-controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    /* Importante para responsive */
}

/* Estilo mejorado de los Selects */
.filter-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: white;
    padding: 12px 40px 12px 15px;
    border: 1px solid #e0e0e0;
    /* Borde más sutil */
    border-radius: 8px;
    font-size: 0.95rem;
    color: #555;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.filter-select:hover {
    border-color: var(--primary-color);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* --- Listings --- */
.funerarias-listings {
    padding: 40px 0 80px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e9ecef;
}

.view-toggle {
    display: flex;
    gap: 5px;
}

.view-btn {
    padding: 10px;
    border: 1px solid #e9ecef;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}

.view-btn.active,
.view-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* --- Cards Grid View --- */
.funerarias-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
}

.funeraria-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.funeraria-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.funeraria-header {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.funeraria-header img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.funeraria-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent-color);
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
}

.funeraria-content {
    padding: 25px;
}

.funeraria-content h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.funeraria-info {
    margin-bottom: 1.5rem;
}

.funeraria-info p {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.funeraria-info i {
    color: var(--accent-color);
    width: 16px;
}

.services-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 1.5rem;
}

.service-tag {
    background: var(--bg-light);
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.funeraria-actions {
    display: flex;
    gap: 10px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
    flex: 1;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

/* --- List View Overrides --- */
.funerarias-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.funerarias-list .funeraria-card {
    display: flex;
    align-items: center;
}

.funerarias-list .funeraria-header {
    width: 200px;
    flex-shrink: 0;
}

.funerarias-list .funeraria-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
}

/* --- Join CTA --- */
.join-cta {
    background: var(--primary-color);
    color: white;
    padding: 80px 0;
    text-align: center;
}

.join-cta h2 {
    color: white;
}

.join-cta p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2rem;
    max-width: 600px;
    margin: 0 auto 2rem;
}

/* ========================================= */
/* === ESTILOS DEL MODAL (RESPONSIVE FIX) === */
/* ========================================= */

.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Importante para que el body principal no scrollee */
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s;
}

/* Contenedor Flex para el modal */
.modal-content {
    background-color: #fff;
    margin: 4vh auto;
    /* Margen vertical */
    padding: 0;
    border: none;
    width: 90%;
    max-width: 750px;

    /* PROPIEDADES CLAVE PARA EL SCROLL */
    max-height: 90vh;
    /* Altura máxima fija */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Cortamos lo que sobra */

    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
    position: relative;
    animation: slideUp 0.3s;
}

/* Botón de cerrar */
.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-modal-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Contenedor interno que genera el JS */
#detailsContent {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Área Scrolleable */
.modal-body-scroll {
    overflow-y: auto;
    /* Scroll vertical */
    overflow-x: hidden;
    flex: 1;
    /* Ocupa todo el espacio disponible */
    padding-bottom: 20px;
    -webkit-overflow-scrolling: touch;
    /* Scroll suave en iOS */
}

/* Cabecera con Imagen */
.details-header-img {
    width: 100%;
    height: 250px;
    background-color: #f0f0f0;
    position: relative;
    flex-shrink: 0;
    /* No encoger la imagen */
}

.details-header-img img.main-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Galería de miniaturas */
.details-gallery {
    display: flex;
    gap: 8px;
    padding: 10px 20px;
    background: #f8f9fa;
    overflow-x: auto;
    border-bottom: 1px solid #eee;
    justify-content: flex-start;
    flex-shrink: 0;
}

.gallery-thumb {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.gallery-thumb:hover {
    opacity: 1;
    border-color: var(--primary-color);
}

/* Contenido de Texto */
.details-content-wrapper {
    padding: 20px 30px;
}

.details-content-wrapper h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    margin-top: 0;
}

.description {
    color: #555;
    line-height: 1.6;
    margin-bottom: 25px;
    font-size: 1rem;
}

/* Grilla de información */
.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.detail-section h4 {
    color: #333;
    font-size: 1.1rem;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 8px;
    margin-bottom: 12px;
    display: inline-block;
}

.detail-section ul {
    list-style: none;
    padding: 0;
}

.detail-section ul li {
    padding: 4px 0;
    color: #666;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-section ul li i {
    color: var(--accent-color);
    font-size: 0.8rem;
}

/* Caja de Contacto */
.contact-box {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: space-between;
    align-items: center;
}

.contact-info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #444;
}

.contact-info-item i {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.modal-actions {
    display: flex;
    gap: 15px;
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --- MEDIA QUERIES PARA MÓVIL --- */

@media (max-width: 768px) {

    /* Ajustes generales */
    .page-header h1 {
        font-size: 2.5rem;
    }

    /* Barra de búsqueda y Filtros apilados */
    .search-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-controls {
        flex-direction: column;
        /* Apilar filtros verticalmente */
        width: 100%;
        gap: 10px;
    }

    .filter-select {
        width: 100%;
        /* Ancho completo en móvil */
    }

    /* Grilla de tarjetas */
    .funerarias-grid {
        grid-template-columns: 1fr;
    }

    .results-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    /* --- Ajustes Modal Móvil --- */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        /* Dejar aire arriba y abajo */
        margin: 5vh auto;
    }

    .details-header-img {
        height: 180px;
        /* Imagen más chica para ver texto */
    }

    .details-content-wrapper {
        padding: 15px;
    }

    /* Botón cerrar más grande y visible */
    .close-modal-btn {
        width: 40px;
        height: 40px;
        background: rgba(0, 0, 0, 0.7);
    }

    .details-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .contact-box {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal-actions {
        flex-direction: column;
        width: 100%;
    }

    .modal-actions .btn-primary,
    .modal-actions .btn-secondary {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}