/* ==========================================================================
   Contenedores Principales de Rotación e Inicialización Estricta 
   ========================================================================== */
.sc-card-container {
    background-color: transparent;
    perspective: 1000px;
    width: 100%;
}

.sc-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.sc-card-container:hover .sc-card-inner {
    transform: rotateY(180deg);
}

/* ==========================================================================
   Estilos de Caras Base (Frente y Posterior)
   ========================================================================== */
.sc-card-side {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    box-sizing: border-box;
    overflow: hidden;
    display: block;
}

.sc-back {
    transform: rotateY(180deg);
}

/* ==========================================================================
   Manejo de Contenido Flex Interno - Optimizado para Crecimiento Elástico
   ========================================================================== */
.sc-content {
    position: relative;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Cambiado a flex-start para que el espacio sobrante no se distribuya al medio */
    align-items: stretch;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
}

/* ==========================================================================
   Configuración de Imagen Cara Frontal
   ========================================================================== */
.sc-image-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    margin-bottom: 15px;
    border-radius: 0 !important;
}

.sc-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0 !important;
}

/* ==========================================================================
   Bloques de Texto Reactivos e Independientes 
   ========================================================================== */
.sc-front-text,
.sc-back-text {
    width: 100% !important;
    max-width: 100% !important;
    display: block;
    box-sizing: border-box;
    padding: 0 !important;
    margin: 0 !important;
}

/* Permitimos que el bloque de texto trasero se estire y use flexbox para controlar la lista */
.sc-back-text {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0; /* Crucial: Permite que los contenedores hijos flex se reduzcan y activen scroll sin desbordar */
}

.sc-front h3 {
    margin: 0 0 5px 0 !important;
    line-height: 1.2;
}

.sc-role-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    margin: 0 !important;
}

.sc-role-wrapper span {
    line-height: 1.2;
}

/* ==========================================================================
   Elementos del Bloque Posterior (Márgenes dinámicos controlados por Elementor)
   ========================================================================== */
.sc-back h4.sc-back-name {
    margin: 0 !important; /* El margin-bottom dinámico viene del inline CSS de Elementor */
    line-height: 1.2;
    width: 100%;
}

.sc-specialties-title {
    font-weight: 600;
    margin: 0 !important; /* Controlado dinámicamente por Elementor */
    font-size: 0.95em;
    width: 100%;
}

/* ==========================================================================
   Lista de Especialidades (CORREGIDO: Altura adaptable y elástica)
   ========================================================================== */
.sc-specialties-list {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important; /* El margin-bottom dinámico viene controlado por el slider de Elementor */
    width: 100% !important;
    
    /* SOLUCIÓN AL PROBLEMA DE ESPACIADO Y SCROLL: */
    flex-grow: 1;               /* Hace que la lista use de forma elástica solo el espacio que requiera o tenga disponible */
    height: auto !important;     /* Elimina cualquier atadura de tamaño fijo previo */
    max-height: none !important; /* Rompe la limitación rígida de 160px */
    overflow-y: auto;            /* El scroll vertical aparecerá SOLO si el texto excede físicamente el alto de la tarjeta */
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Ítems individuales dentro de la lista */
.sc-specialties-list li {
    margin: 0 0 8px 0 !important;
    padding: 0 !important;
    line-height: 1.4;
    font-size: 0.9em;
    width: 100%;
}

.sc-specialties-list li:last-child {
    margin-bottom: 0 !important;
}

/* Scrollbar minimalista para no romper la estética */
.sc-specialties-list::-webkit-scrollbar {
    width: 5px;
}

.sc-specialties-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03); 
    border-radius: 10px;
}

.sc-specialties-list::-webkit-scrollbar-thumb {
    background: rgba(17, 17, 17, 0.2); 
    border-radius: 10px;
    transition: background 0.3s ease;
}

.sc-specialties-list::-webkit-scrollbar-thumb:hover {
    background: rgba(17, 17, 17, 0.4);
}

/* ==========================================================================
   Contenedor del Botón Posterior - Alineación Exacta sin Desfases
   ========================================================================== */
.sc-button-container {
    margin-top: auto !important; /* Empuja el botón al fondo si queda espacio libre */
    padding: 0 !important;
    box-sizing: border-box;
    width: 100% !important;
    display: block;
}

.sc-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    line-height: 1;
    transition: all 0.3s ease;
    cursor: pointer;
    box-sizing: border-box;
    margin: 0 !important;
}

.sc-button:hover svg {
    transform: translateX(4px);
}