/* =========================================================================
   SERVICIOS EXPANDING PANELS CSS
   ========================================================================= */

/* Contenedor de las tarjetas: Forzamos Flexbox y ancho completo en desktop */
#servicios .max-w-7xl.grid {
    display: flex !important;
    flex-wrap: wrap;
    /* Permitir wrap en mobile/tablet */
    max-width: 100% !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
}

/* Base de la tarjeta */
.servicio-card {
    position: relative;
    overflow: hidden;
    height: 500px;
    flex: 1 1 100%;
    /* Default mobile: full width */
    cursor: pointer;
    transition: flex 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s ease;
    border-radius: 0 !important;
    /* Sin bordes redondeados para que encajen perfectos */
}

/* Imagen de fondo */
.servicio-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease-in-out;
}

/* Overlay base */
.servicio-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    /* Ligeramente más oscuro base */
    transition: background-color 0.4s ease;
    z-index: 10;
}

/* Contenido */
.servicio-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    text-align: center;
    padding: 1.5rem;
    /* Reducido levemente para dar más espacio al texto */
    pointer-events: none;
    /* Dejar que los clics pasen al card */
}

/* Título */
.servicio-title {
    color: white;
    font-size: 1.8rem;
    /* Ajustado para mejor adaptabilidad */
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: none;
    /* No animar el texto */
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
    width: 100%;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    /* Asegura que el texto pueda ocupar varias líneas */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    /* Máximo 3 líneas antes de truncar */
    line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* Botón: oculto por defecto */
.servicio-btn {
    margin-top: 1.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: background-color 0.3s ease, opacity 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    background-color: #F7942E;
    color: white;
    font-weight: bold;
    padding: 0.75rem 2.5rem;
    border-radius: 0.5rem;
    pointer-events: auto;
    border: none;
    box-shadow: 0 4px 15px rgba(247, 148, 46, 0.3);
}

.servicio-btn:hover {
    background-color: #D67A1C;
    /* Naranja más oscuro */
}

/* --- RESPONSIVE & EXPANSION --- */

/* TABLET: 2 Columnas */
@media (min-width: 768px) {
    .servicio-card {
        flex: 1 1 50%;
    }
}

/* DESKTOP: Expanding Panels logic (Solo en pantallas grandes) */
@media (min-width: 1024px) {
    #servicios .max-w-7xl.grid {
        flex-wrap: nowrap;
        /* Todos en una fila */
        overflow: hidden;
    }

    .servicio-card {
        flex: 1;
        /* Todos iguales al inicio */
        min-width: 0;
        /* Permite que el flex-item se achique correctamente */
    }

    /* Al pasar el mouse, el panel se expande y los otros se encogen */
    #servicios .max-w-7xl:hover .servicio-card {
        flex: 0.6;
        /* Un poco menos agresivo para evitar que el texto sufra tanto */
    }

    .servicio-card:hover {
        flex: 3 !important;
        /* El activo se expande más */
    }

    .servicio-card:hover .servicio-img {
        transform: scale(1.08);
        /* Zoom sutil y profesional */
    }

    .servicio-card:hover .servicio-overlay {
        background-color: rgba(0, 0, 0, 0.7);
        /* Overlay más oscuro al hacer hover */
    }

    .servicio-card:hover .servicio-btn {
        opacity: 1;
        transform: translateY(0);
    }

    /* Efecto para los títulos cuando otro está expandido */
    #servicios .max-w-7xl:hover .servicio-card:not(:hover) .servicio-title {
        font-size: 1rem;
        /* Reducimos el tamaño para los que se encogen */
        opacity: 0.8;
    }
}

/* En mobile/tablet el botón debe ser visible siempre para permitir la interacción */
@media (max-width: 1023px) {
    .servicio-btn {
        opacity: 1;
        transform: translateY(0);
    }

    .servicio-card {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
}

/* --- Estilos para la lista de servicios --- */
.servicio-list {
    margin-top: 1rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    line-height: 1.4;
    text-align: left;
    list-style: none;
    padding: 0;
    max-width: 300px;
    opacity: 0;
    transform: translateY(10px);
    transition: none;
    /* No animar el texto */
    /* Un ligero delay después del título */
}

.servicio-list li {
    margin-bottom: 0.75rem;
    position: relative;
    padding-left: 1.5rem;
}

.servicio-list li::before {
    content: "•";
    color: #F7942E;
    font-weight: bold;
    position: absolute;
    left: 0;
    font-size: 1.2rem;
}

/* Mostrar lista al hover en desktop */
@media (min-width: 1024px) {
    .servicio-card:hover .servicio-list {
        opacity: 1;
        transform: translateY(0);
    }
}

/* En mobile/tablet mostrar siempre o con sutil scroll */
@media (max-width: 1023px) {
    .servicio-list {
        opacity: 1;
        transform: translateY(0);
        text-align: center;
        padding-left: 0;
    }

    .servicio-list li {
        padding-left: 0;
    }

    .servicio-list li::before {
        display: none;
    }
}

/* =========================================================================
   MODAL CSS (REDESIGNED)
   ========================================================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.5rem; /* Reducido para móviles */
}

/* Padding responsivo para desktop */
@media (min-width: 768px) {
    .modal-overlay {
        padding: 1.5rem;
    }
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    max-height: 92vh;
    max-width: calc(100% - 2rem); /* Evitar overflow horizontal - usar % en lugar de vw */
    width: 95%; /* Limitado en móviles */
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: scale(0.95) translateY(20px);
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: #0B1215;
    overflow-x: hidden; /* Protección contra overflow horizontal */
    box-sizing: border-box; /* Incluir padding en el ancho */
}

/* Ancho responsivo para desktop */
@media (min-width: 768px) {
    .modal-container {
        width: 90%;
    }
}

@media (min-width: 1024px) {
    .modal-container {
        width: 85%;
    }
}

.modal-overlay.active .modal-container {
    transform: scale(1) translateY(0);
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #0B1215;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #F7942E;
}

/* Smooth scrolling for mobile */
.custom-scrollbar {
    -webkit-overflow-scrolling: touch;
}

/* Modal Title Shadow for readability over images */
#modal-title {
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 2px 10px rgba(0, 0, 0, 0.4);
}

/* Ensure images don't deform */
#modal-carousel-track img {
    object-position: center;
}

/* Smooth active state for dots */
#carousel-dots button.bg-highlight {
    background-color: #F7942E !important;
}

/* Media Queries for Modal Height and Spacing */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 0.5rem;
    }

    .modal-container {
        max-height: 100vh;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
    }
}